[datatable-help] append two factor vectors

el_alisio malnamalja at gmx.de
Mon Dec 28 12:38:12 CET 2015


Hi,

how about:


q1 <- c("a1", "a2" ,"a3")
q2 <- c("b1", "b2", "b3") 
as.factor(c(q1, q2))

In case q1 and q2 are already factors, first convert them into characters:

q1 <- as.factor(q1)
q2 <- as.factor(q2)
as.factor(c(as.character(q1), as.character(q2)))

Cheers,

Jannes


agent dunham wrote
> Dear community, 
> 
> i have two vector factors that i need to join into a single vector, and
> afterwards, a unique over this final vector. 
> Can anybody help?
> 
> Example: 
> 
> q1 <- c("a1","a2","a3")
> q2 <- c("b1","b2","b3")
> 
> q1 <- as.factor(q1)
> q2 <- as.factor(q2)
> 
> I have this q's. Then, I'd need:
> 
> qjoin <- c(q1,q2)
> 
> BUT, then I see: 1 2 3 1 2 3
> rather than "a1" "a2" "a3" "b1" "b2" "b3"





--
View this message in context: http://r.789695.n4.nabble.com/append-two-factor-vectors-tp4715638p4715956.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list