2014-05-25 1 views
0

for()plot()을 사용할 때 오류가 발생했습니다.
for()에 대한 plot() 오류

> 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 

가 어떻게이 오류를 방지 할 수 있습니다 (I()는 반복에 대한 위해를 사용하여 작업 부하를 줄이기 위해 노력)? 대단히 감사합니다.

답변

0

오타/thinko. aa <- 1+6(i-1)aa <- 1+6*(i-1)이어야합니다 (R은 곱셈으로 병치를 처리하지 않음). 다음 행에서도 마찬가지입니다.

+0

감사합니다. 나는 그런 기본적인 실수를했다고 생각하지 않았다 ... – user2978524