[R] Simple loop code

David Winsemius dwinsemius at comcast.net
Thu Apr 29 19:47:18 CEST 2010


On Apr 29, 2010, at 1:42 PM, Henrique Dallazuanna wrote:

>
>
> On Thu, Apr 29, 2010 at 12:05 PM, David Winsemius <dwinsemius at comcast.net 
> > wrote:
>
snipped

>
>
> ##Then bind to your data
> z <- cbind(y,x)
>
> Oooh. Not a good practice, at least for the newish useR. cbind and  
> rbind create matrices and as a consequence coerce all of their  
> elements to be of the same type. Numeric columns would become  
> character vectors. Not generally a desired result. This would be  
> safer:
>
>
> X is a data.frame, so, the object created is a data.frame.

Thank you for the correction. I probably read at one time that there  
was a cbind.data.frame method but I obviously forgot that point. Good  
to know.

>
> dat.I$ID2.cf  <- as.character( factor(dat.ID$ID2, labels = 1:7)  )
> -- 
> David.
>
>
> Thanks again, I expected it to be more complicated!
>
> Cheers,
>
> Ross

>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list