它不会读标题:
d_df %>%
mutate ( Year = substr(Date, 7, 10)) %>%
mutate(Structures = ifelse(ID %in% tnnls, "tunnelS", "bridges")) %>%
filter( Year %in% yrs_wnt) %>%
group_by(Year, Structures) %>%
summarise( Total = sum(EZPass)+ sum(Cash)) %>%
pivot_wider (names_from= Structures, values_from= Total) %>%
mutate( Percentb = (bridges / (tunnels + bridges)))
字符串
这就是错误:summarise()
已按“Year”对输出进行分组。您可以使用.groups
参数进行覆盖。mutate()
中的错误:在参数中出现错误:Percentb = (bridges/(tunnels + bridges))
。在组1中出现错误:Year = "2012"
我以为会有另一个关于桥梁比例的专栏。
1条答案
按热度按时间pgky5nke1#
为了更好地理解,请分享您的示例dataFrame。在计算时,错误似乎是由于除以零而引起的:
mutate( Percentb = (bridges / (tunnels + bridges)))
你可以这样处理:
字符串