[R] recode categorial vars into binary data
Chris Stubben
stubben at lanl.gov
Tue May 7 19:54:58 CEST 2013
> First off, stop using cbind() when it is not needed. You will not see the reason
> when the columns are all numeric but you will start experiencing pain and puzzlement
> when the arguments are of mixed classes. The data.frame function will do what you want.
>(Where do people pick up this practice anyway?)
Maybe from help( data.frame)?
It's in most of the examples and is not needed ...
L3 <- LETTERS[1:3]
(d <- data.frame(cbind(x=1, y=1:10), fac=sample(L3, 10, replace=TRUE)))
## The same with automatic column names:
data.frame(cbind( 1, 1:10), sample(L3, 10, replace=TRUE))
Chris
--
Chris Stubben
Los Alamos National Lab
Bioscience Division
MS M888
Los Alamos, NM 87545
More information about the R-help
mailing list