> On 31-12-2014, at 08:27, thanoon younis <thanoon.youni...@gmail.com> wrote: > > Dear all members > I have a problem with the code below when i wanted to change the continuous > random variables to mixed ordered categorical and dichotomous as follow > > #transform theta to ordinal variables > yo <- array(0, dim=c(i,5,100)) > for(j in 1:5){ > if(v[j] < 0.25){ > yo[i,j,t] = 1 > }else if(v[j] >=0.25 & v[j] < 0.5){ > yo[i,j,t] = 2 > }else if(v[j] >=0.5 & v[j] < 0.75){ > yo[i,j,t] = 3 > }else{ > yo[i,j,t] = 4 > } > }} > > #transform theta1 to dichotomousvariables > for (j in 6:9) { if (v[j]>0) yo[i,j,t]<-1 else yo[i,j,t]<-0 } > > i found this error > > > *Error in yo[i, j, t] <- 1 : subscript out of bounds* > > > > any Guidance would highly appreciated. >
How can we? You have not provided sufficient information. Where are i and t given values? What are the values? Why don’t you just try print(i) and print(t) before the for (j in 6:9) ? Also have a look at the expression creating y0. You specify 5 columns. In the final loop you assign to column j with values starting at 6 and ending at 9; larger than 5. Berend > Regards > -- > Thanoon Y. Thanoon > PhD Candidate > Department of Mathematical Sciences > Faculty of Science > University Technology Malaysia, UTM > E.Mail: thanoon.youni...@gmail.com > E.Mail: dawn_praye...@yahoo.com > Facebook:Thanoon Younis AL-Shakerchy > Twitter: Thanoon Alshakerchy > H.P:00601127550205 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.