我有数据集,包括TimeStamp和风速:
TimeStamp MeanWindSpeed102.5 MeanWindSpeed100.0 MeanWindSpeed76.6
2 2013-08-27 17:30:00 4.25 4.19 3.94
3 2013-08-27 17:40:00 4.39 4.34 4.16
4 2013-08-27 17:50:00 4.83 4.76 4.29
5 2013-08-27 18:00:00 4.96 4.91 4.22
6 2013-08-27 18:10:00 5.22 5.18 4.47
7 2013-08-27 18:20:00 5.18 5.15 5.01
我尝试使用dplyr包,如下所示:
a = data %>%
dplyr::select(TimeStamp, matches("MeanWindSpeed")) %>%
dplyr::mutate(m = month(TimeStamp)) %>%
dplyr::group_by(m) %>%
dplyr::summarise_each(funs(mean(., na.rm = TRUE)))
我收到的错误如下:
Error in mutate_impl(.data, dots) :
Evaluation error: could not find function "month".
但我的TimeStamp格式是正确的:
str(data$TimeStamp)
POSIXct[1:54459], format: "2013-08-27 17:30:00" "2013-08-27 17:40:00" "2013-08-27 17:50:00" ...
如果我只是评论该行继续如下:
a = data %>%
dplyr::select(TimeStamp, matches("MeanWindSpeed")) %>%
#dplyr::mutate(m = month(TimeStamp)) %>%
#dplyr::group_by(m) %>%
dplyr::summarise_each(funs(mean(., na.rm = TRUE)))
summerise_each
功能不起作用:
`summarise_each()` is deprecated.
Use `summarise_all()`, `summarise_at()` or `summarise_if()` instead.
To map `funs` over all variables, use `summarise_all()`
我错过了什么吗?知道为什么我会收到这些错误吗?