worked fine for me (after removing 'data=xx' which may have caused
caused problems since it is supposed to be a dataframe or a list, not
a matrix)
> par(mfrow=c(3,2))
> for(i in 2:7)
+ {
+ boxplot(xx[,i]~xx[,1],xlab="lev")
+ print(i)
+ }
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
On Mon, Oct 6, 2008 at 12:55 PM, Shanta Man Shakya <sm_shakya at
yahoo.com> wrote:> Dear R users,
>
> I am new users of this software. I want to make box plot. Here, i have
simulated data set with following commands:
>
> x<-matrix(rnorm(90),nrow=10,ncol=9)
> x
> a<-matrix(c(1,1,1,1,1,2,2,2,2,2),nrow=10,ncol=1)
> xx<-cbind(a,x)
>
colnames(xx)<-c("a","b","c","d","e","f","g","h","i","j")
>
rownames(xx)<-c("bro","cc","tu","so","ys","vt","ft","pc","ro","rc")
> xx
> factor(xx[,1])
>
> Here, i want to make boxplot of group "1" and "2" of
column "a" by using "for" loop because i have very large
real data set.
> I tried by using following "for" loop but it is not working.
>
>> par(mfrow=c(3,2))
> for(i in 2:7)
> {
> boxplot(xx[,i]~xx[,1],data=xx,xlab="lev")
> print(i)
> }
> # I am getting following message:
>
> Error in eval(expr, envir, enclos) :
> only 0's may be mixed with negative subscripts
>
> I could not find what's wrong in writing "for" loop. I think
this is very simple for regular users. I request for finding my mistakes and
correction on it.
>
> Thanks,
>
> SHANT
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?