R as.numberic returning wrong number

24 views Asked by At

I would like to summarize a dataframe ignoring the case. Because a column of my data frame was read in as a factor I first convert this column into a numeric. Doing this, the numbers somehow get mixed up.

My code:

    aggregated = as.data.frame(sapply(data, tolower))
    aggregated

returns

   hashtags   Freq   Company
#33contest   2   @Company1
#cebu   1   @Company1
#community   1   @Company1
#cost   1   @Company1
#countries   1   @Company1
#drug   1   @Company1

when I now convert column three into a numeric the results seem to be messed up

    aggregated$Freq <-as.numeric(aggregated$Freq)
    aggregated 

hashtags    Freq    Company
#33contest    9    @Company1
#cebu    1    @Company1
#community    1    @Company1
#cost    1    @Company1
#countries    1    @Company1
#drug    1    @Company1

What can I do about this?

0

There are 0 answers