[R] (no subject)

Chuck White chuckwhite8 at charter.net
Mon Jan 25 19:46:40 CET 2010


Hello -- I would like to know of a more efficient way of writing the following piece of code. Thanks.

options(stringsAsFactors=FALSE)
orig <- c(rep('11111111',100000),rep('22222222',200000),rep('33333333',300000),rep('44444444',400000))
orig.unique <- unique(orig)
system.time(df <- as.data.frame(sapply(orig.unique, function(x) ifelse(orig==x, 1, 0))))



More information about the R-help mailing list