【发布时间】: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_at是Date类吗?你能成功运行wday(combined_databike_2$started_at[1])吗? -
started_at 是日期时间。该条目的结果 wday(combined_databike_2$started_at[1]) 是 7
标签: r