[R] Strange behaviour of cbind

2006-06-06 Thread Dirk Vandekerckhove
Hi, Is this intended behaviour of cbind? > a<-c(0,1,2,3) > a [1] 0 1 2 3 > a<-as.ordered(a) > a [1] 0 1 2 3 Levels: 0 < 1 < 2 < 3 > a<-a[a!=0] #remove the zero from a > a [1] 1 2 3 Levels: 0 < 1 < 2 < 3 > cbind(a) a [1,] 2 [2,] 3 [3,] 4 #cbind adds +1 to each element > a<-as.ordered(as.ve

Re: [R] Strange behaviour of cbind

2006-06-06 Thread Marc Schwartz (via MN)
On Tue, 2006-06-06 at 13:44 -0700, Dirk Vandekerckhove wrote: > Hi, > > Is this intended behaviour of cbind? > > > a<-c(0,1,2,3) > > a > [1] 0 1 2 3 > > a<-as.ordered(a) > > a > [1] 0 1 2 3 > Levels: 0 < 1 < 2 < 3 > > a<-a[a!=0] #remove the zero from a > > a > [1] 1 2 3 > Levels: 0 < 1 < 2 < 3 >

Re: [R] Strange behaviour of cbind

2006-06-06 Thread Sarah Goslee
Hi, It doesn't have anything to with cbind, but rather with as.ordered - you converted it to a factor in that step. In the cbind step, you are actually getting the position of that ordered factor, rather than anything to do with the values themselves. > a <- c(1,7,5,3) > a <- as.ordered(a) > a [