[英]R: How to plot 4 graphs using a loop statement with the plot function
[英]How to plot graph using plot function inside a function using if loop in R
crime.value = 1
crime.bar <- function() {
bp<-ggplot(df_category, aes(x=Category, y=Frequency, fill=Category)) + geom_bar(stat="identity") +
theme(axis.text.x=element_blank())
bp
}
if (crime.value == 1) {
crime.bar()
}
Plot function 在我单独调用crime.bar()
时起作用。 但是当通过 if 循环调用时,它不起作用。 请帮忙。
您需要在循环中使用print(bp)
来强制 output。 感谢@Dave2e
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.