r – Cant draw Histogram, x must be numeric
r – Cant draw Histogram, x must be numeric
Because of the thousand separator, the data will have been read as non-numeric. So you need to convert it:
we <- gsub(,, , we) # remove comma
we <- as.numeric(we) # turn into numbers
and now you can do
hist(we)
and other numeric operations.
Note that you could as well plot directly from ce
(after the comma removing) using the column nameĀ :
hist(ce$Weight)
(As opposed to using hist(ce[1])
, which would lead to the same must be numeric error.)
This also works for a database query result.
r – Cant draw Histogram, x must be numeric
Use the dec argument to set ,
as the decimal point by adding:
ce <- read.table(file.txt, header = TRUE, dec = ,)