[R] c/cbind/rbind of factor variables

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sat Feb 1 21:03:03 CET 2003


Chong Gu <chong at stat.purdue.edu> writes:

> I guess this is a feature
> 
> > c(as.factor(2),as.factor(3))
> [1] 1 1
> 
> But is there a way to turn off the feature and return the following?
> 
> [1] 2 3
> 
> Thanks for any pointer.

How about 

cc <- function(...) do.call("c", lapply(list(...),as.character))
cc(as.factor(2),as.factor(3))

?

(or as.integer(do.call.....) if you really want integers back)
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list