1
不顯示我有這樣的數據集:SD值dplyr
structure(list(CAMPAMENTO = c("Futura Esperanza", "Futura Esperanza",
"Futura Esperanza", "Futura Esperanza", "Futura Esperanza", "Nuevo Amanecer",
"Nuevo Amanecer", "Nuevo Amanecer", "Nuevo Amanecer", "Nuevo Amanecer",
"Nuevo Amanecer", "Laderas de Angelmó", "Laderas de Angelmó",
"Laderas de Angelmó", "Laderas de Angelmó", "Laderas de Angelmó",
"Laderas de Angelmó", "Laderas de Angelmó", "Pelluhuin 1",
"Pelluhuin 1", "Pelluhuin 1", "Pelluhuin 1", "Pelluhuin 1", "Pelluhuin 1",
"Pelluhuin 1", "Pelluhuin 2", "Pelluhuin 2", "Pelluhuin 2", "Pelluhuin 2",
"Pelluhuin 2", "Mediaguas", "Mediaguas", "Mediaguas", "Mediaguas",
"Mediaguas", "Mediaguas", "Mediaguas", "Mediaguas", "Mediaguas",
"Mediaguas"), CEO = c(1L, 4L, 2L, 0L, 0L, 0L, 0L, 1L, 2L, 0L,
0L, 2L, 2L, 0L, 6L, 0L, 1L, 0L, 1L, 3L, 2L, 0L, 0L, 0L, 0L, 0L,
0L, 3L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 2L, 3L), ceo = c(0L,
0L, 0L, 1L, 5L, 0L, 0L, 2L, 0L, 4L, 9L, 0L, 0L, 0L, 0L, 6L, 1L,
0L, 0L, 0L, 3L, 2L, 8L, 7L, 3L, 1L, 0L, 2L, 7L, 4L, 0L, 1L, 2L,
0L, 1L, 0L, 1L, 3L, 0L, 0L)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -40L), .Names = c("CAMPAMENTO", "CEO", "ceo"
))
我可以計算列CEO和CEO的均值和標準差,例如:
mean(df$ceo, na.rm = T)
[1] 1
和SD,
sd(df$ceo, na.rm = T)
[1] 3
但當
df %>%
group_by(CAMPAMENTO) %>%
summarise(n = n(),
"CEO" = mean(CEO), "SD CEO" = sd(CEO),
"ceo" = mean(ceo), "SD ceo" = sd(ceo))
結果是
但沒有SD結果顯示。
我在做什麼錯了?
在此先感謝。
可能是因爲他們是整數值,嘗試將這些用的cols'as.double' –
沒有,'sd','mean'等嘗試coherce如果可能。整數是沒有問題的,因爲它們被簡化爲雙倍。 –