R Barchar在For循环中不起作用 [英] R Barchar does not work in For loop
本文介绍了R Barchar在For循环中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 中使用了 barchart
,在 中,
I am using barchart
in For loop that goes on years, the barchart
command is ok outside the loop, but inside - something goes wrong.
这是我的代码:
for(i in 2006:2016){
htr2 = htr[htr$year==i , ]
barchart(year ~ y_kayam , groups=shlav, htr2, auto.key = list(columns = 2) )
Sys.sleep(5) }
这是我的资料
Here is my data
year vaada shlav tm38 y_kayam y_mevukash
2013 410 1 1 12.00
2013 410 2 1 12.00
2013 410 1 1
2013 410 1 1 8.00 15.00
2013 410 3 1 8.00 15.00
2013 410 1 8.00 15.00
2013 410 1 1 15.00 28.00
2013 410 3 1 15.00 28.00
谢谢!
推荐答案
a> function。
par(mfrow=c(3,3))
for(i in 2006:2016){
htr2 = htr[htr$year==i , ]
barchart(year ~ y_kayam , groups=shlav, htr2, auto.key = list(columns = 2) )
Sys.sleep(5) }
现在,您可以使用 dev.copy()将其保存为PNG(或其他图片类型)。
Now, you can use dev.copy() to save it as a PNG (or another image type).
dev.copy(png, 'myPlots.png')
dev.off()
这篇关于R Barchar在For循环中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文