[问题类型]:
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
新手(没写过程式,R 是我的第一次)
[问题叙述]:
我用下面这行读取资料
expenses <- read.csv("expenses.csv", stringsAsFactors=FALSE)
资料内字段有字串也有数字与日期
但用str(expenses)查看时
所有字段都显示chr如下,不能做数字计算
'data.frame': 605 obs. of 7 variables:
$ Date : chr "1/22/2017" "1/13/2017" "1/22/2017" "2/19/2017" ...
$ Day : chr "22" "13" "22" "19" ...
$ Month : chr "Jan" "Jan" "Jan" "Feb" ...
$ Weekday : chr "Sunday" "Friday" "Sunday" "Sunday" ...
$ Amount : chr "3" "13" "15" "36" ...
$ Category: chr "Grooming and Health" "Grooming and Health" "Grooming and
Health" "Grooming and Health" ...
$ Comment : chr "Hajmola" "Crocin" "Digeine" "Sinarest" ...
我试了as.numeric(expenses$amount)
还是没把格式改成numeric
整个卡住 ><
请问要怎么做?
谢谢大家