[問題類型]:
程式諮詢(我想用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
整個卡住 ><
請問要怎麼做?
謝謝大家