【发布时间】:2021-05-04 13:31:48
【问题描述】:
我在循环中遇到 ggplot 问题。 单独使用效果很好。
如下:
*plotgg<-
ggplot(renewalplot, aes(x = Month,y=Rate)) +
stat_summary(fun = mean, na.rm = TRUE,geom="bar")+
labs(x = "Month") +
ggtitle("Rate Change Distribution")+
theme(axis.text.x = element_text(angle = 90, hjust = 1))+
facet_grid(cols = vars(Year))
print(plotgg)*
当我把它们放在循环中时,它给了我错误:
vars <- colnames(detailinfo_renewal_1)
varslist1 = vars[c(13)]
for (i in varslist1) {
renewalplot <- detailinfo_renewal_1 %>%
filter(Product=="FI")
plotgg<-
ggplot(renewalplot, aes(x = renewalplot[, i],y=Rate)) +
stat_summary(fun = mean, na.rm = TRUE,geom="bar")+
labs(x = i) +
ggtitle("Mean of Rate Change Distribution")+
theme(axis.text.x = element_text(angle = 90, hjust = 1))+
facet_grid(cols = vars(Year))
print(plotgg)
}
非常感谢! 液晶
【问题讨论】:
-
错误是“不知道如何为 tbl_df/tbl/data.frame 类型的对象自动选择比例。默认为连续。is.finite(x) 中的错误:未实现默认方法对于类型“列表””
-
请使用
dput或我们可以复制和使用的东西添加数据。了解how to ask a good question 和how to give a reproducible example。