[R] Strange behaviour of cbind

Dirk Vandekerckhove dvdkerc at yahoo.com
Tue Jun 6 22:44:28 CEST 2006


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.vector(a))
> a
[1] 1 2 3
Levels: 1 < 2 < 3
> cbind(a)
     a
[1,] 1
[2,] 2
[3,] 3

#now it works...

I am running R 2.3.0 on a windows system.



Regards,

Dirk Vandekerckhove



More information about the R-help mailing list