【问题标题】:Error in `mutate()`: ! Problem while computing `weekday = wday(started_at, label = TRUE)``mutate()` 错误:!计算 weekday = wday(started_at, label = TRUE) 时出现问题
【发布时间】:2023-01-17 00:41:49
【问题描述】:
combined_databike_2 %>%
  mutate(weekday = wday(started_at, label = TRUE)) %>%  #creates weekday field using wday()
  group_by(member_casual, weekday) %>%  #groups by usertype and weekday
  summarise(number_of_rides = n(#calculates the number of rides and average duration 
        ,average_duration = mean(ride_length)) %>%      # calculates the average duration
  arrange(member_casual, weekday) %>% 
  ggplot(aes(x = weekday, y = number_of_rides, fill = member_casual)) +
  geom_cmol(position = "dodge")

如果给我一个错误 Error in mutate(): ! Problem while computing weekday = wday(day_of_week, label = TRUE)'

我不知道我应该做什么

【问题讨论】:

  • 请用dput展示一个可重现的小例子,即dput(head(combined_databike_2, 20))
  • started_atDate 类吗?你能成功运行wday(combined_databike_2$started_at[1])吗?
  • started_at 是日期时间。该条目的结果 wday(combined_databike_2$started_at[1]) 是 7

标签: r


【解决方案1】:

块引用 乘车次数 = n(

你应该关闭 paranthezis 然后它就会工作。

乘车次数 = n(),

顺便说一句,我假设你安装并加载了“lubridate”包。

【讨论】:

    猜你喜欢
    • 2020-12-29
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多