R将字符转换为ggplot的数字

时间:2015-02-27 18:58:20

标签: r ggplot2

我导入以下csv。我设置了stringAsFactors = FALSE和as.numeric但是列仍然不是数字,即使class()告诉我它是

代码是:

read.csv('customer.csv',header=TRUE , as.is= TRUE ,stringsAsFactors=FALSE)->data

Client   | Volume
Bob         34.23
Bob        100.09
Bob        250.00
Jason        3.12
May           .98
May          1.00

data$Volume <- as.numeric(data$Volume)
class(data$Volume) 
> "numeric"

看起来像是一个常见的问题 http://www.r-bloggers.com/type-conversion-and-you-or-and-r/

但是当我尝试时:

(p <- ggplot(data, aes(x=Industry, y=vol )+geom_boxplot()))
>Error in aes(x = Industry, y = vol) + geom_boxplot() : 
non-numeric argument to binary operator

我知道它,因为Column Volume实际上不是数字,但我似乎无法导入为数字或将其转换为数字。

0 个答案:

没有答案