Error in hist.default(fruitveg) : 'x' must be numeric

so I was trying to convert my data fruit veg into numeric

I used class(fruit veg) and it showed [1] data.frame

then I used

my_data_num <- as.numeric(fruitveg)

so it showed this error

Error: 'list' object cannot be coerced to type 'double'

what am I doing wrong??

You can't convert the entire data frame at once, you have to convert individual columns. Should all of the columns be converted or are there some character or date columns that should not be converted?

fruitveg dataframe was created from

fruit <- g[,'fruit']
veg <- g[,'veg']
fruitveg <- fruit + veg
table(fruitveg)

here g is csv file

hey solved the problem :slight_smile:

used this link.

Thank you for replying

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.