[問題] excel無法計算變項
目前想學習R
剛試用卻遇到困難
自己做了一個excel如下
檔名為test
age
52
46
20
25
26
60
35
25
36
68
42
匯入到Rstudio的語法為:
> library(readxl)
> test <- read_excel("~/R/test.xlsx", col_types = c("numeric"))
但我輸入平均值 mean(test)
卻出現這樣的訊息 Warning message:
In mean.default(test) : argument is not numeric or logical: returning NA
再輸入標準差 sd(test)
出現Error in is.data.frame(x) :
(list) object cannot be coerced to type 'double'
平均值的部分我有使用colmeans有成功,
但我疑問是若使用scan()自行輸入資料跑mean(test)和sd(test)是能成功的
煩請各位解惑
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.117.176.170
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1504114085.A.EE5.html
推
08/31 03:45, , 1F
08/31 03:45, 1F
L大這樣就無法將excel匯入了
※ 編輯: scts1215 (101.10.2.211), 08/31/2017 09:28:57
→
08/31 09:55, , 2F
08/31 09:55, 2F
→
08/31 10:00, , 3F
08/31 10:00, 3F
→
08/31 10:01, , 4F
08/31 10:01, 4F
→
08/31 10:02, , 5F
08/31 10:02, 5F
F大我使用as.numeric成功了,不過若我有兩個以上的變項可以同時看他們的平均值或標
準差嗎?
※ 編輯: scts1215 (117.19.148.245), 08/31/2017 11:01:18
推
08/31 11:13, , 6F
08/31 11:13, 6F
→
08/31 11:13, , 7F
08/31 11:13, 7F
→
08/31 11:15, , 8F
08/31 11:15, 8F
→
08/31 11:15, , 9F
08/31 11:15, 9F
感謝F大
※ 編輯: scts1215 (101.13.145.84), 08/31/2017 13:10:19
→
08/31 19:39, , 10F
08/31 19:39, 10F
→
08/31 19:39, , 11F
08/31 19:39, 11F
W大我目前跟著教材練習,只是我直接用excel做匯入遇到此問題,大大有建議的教材嗎?
※ 編輯: scts1215 (117.19.64.5), 08/31/2017 20:31:09
推
08/31 23:49, , 12F
08/31 23:49, 12F
推
09/01 00:09, , 13F
09/01 00:09, 13F
→
09/01 00:11, , 14F
09/01 00:11, 14F
→
09/01 00:11, , 15F
09/01 00:11, 15F
→
09/01 00:12, , 16F
09/01 00:12, 16F
→
09/01 00:13, , 17F
09/01 00:13, 17F
原來如此,感謝大大講解
※ 編輯: scts1215 (101.12.225.254), 09/01/2017 09:23:42