R 为()绘制()时出错
在R 为()绘制()时出错,r,function,for-loop,plot,R,Function,For Loop,Plot,在for()中使用plot()时出错 (我试图通过使用for()进行重复来减少工作量) >head(data.6times[3:7])#data.6times有40列 cyear ccode scode国家年 26 1301998 130 ECU厄瓜多尔1998 251301997 130厄瓜多尔1997 27 1302000 130 ECU厄瓜多尔2000 >country.n表示(1中的i:country.n){ +aaTypo/thinko.aa > head(data.6t
for()
中使用plot()
时出错(我试图通过使用for()进行重复来减少工作量)
>head(data.6times[3:7])#data.6times有40列
cyear ccode scode国家年
26 1301998 130 ECU厄瓜多尔1998
251301997 130厄瓜多尔1997
27 1302000 130 ECU厄瓜多尔2000
>country.n表示(1中的i:country.n){
+aaTypo/thinko.aa
> head(data.6times[3:7]) #data.6times has 40 columns
cyear ccode scode country year
26 1301998 130 ECU Ecuador 1998
25 1301997 130 ECU Ecuador 1997
27 1302000 130 ECU Ecuador 2000
> country.n <- length(data.6times$country) / 6
> for (i in 1:country.n){
+ aa <- 1+6(i-1)
+ bb <- 6+6(i-1)
+ plot.data <- data.6times[aa:bb,]
+ par(yaxt="n")
+ plot(plot.data$year,plot.data$cluster,ylim=c(0.8, 3.2))
+ text(plot.data$year, plot.data$cluster,labels=plot.data$country, cex=0.6, pos=1, col="blue")
+ text(plot.data$year, plot.data$cluster,labels=plot.data$transition, cex=0.6, pos=3, col="blue")
+ text(plot.data$year, plot.data$cluster,labels=plot.data$prior, cex=0.6, pos=2, col="blue")
+ text(plot.data$year, plot.data$cluster,labels=plot.data$post, cex=0.6, pos=4, col="blue")
+ par(yaxt="s")
+ axis(2, c(1,2,3), c("1","2","3"))
+ filename <- paste(c("/Users/Dropbox/Study/Dissertation/Result_fig/"),c("6times-"),i,c(".jpg"),sep="")
+ dev.copy(jpeg,file=filename,width=1200,height=800)
+ dev.off()
+ }
Error: attempt to apply non-function