Skip to content
Prev 308688 / 398503 Next

What is behind class coercion of a factor into a character

WARNING:  Use with caution!

There is a way to effect the catenation of factors:  The data.frame
method for rbind() does this.  E.g.

set.seed(42)
f1 <- factor(sample(letters[1:3],42,TRUE))
f2 <- factor(sample(letters[1:4],66,TRUE))
d1 <- data.frame(f=f1)
d2 <- data.frame(f=f2)
dd <- rbind(d1,d2)
ff   <- dd[,1]

et voila, ff is the "desired" catenation of f1 and f2.
But heed Bert's words of caution below!

     cheers,

         Rolf Turner
On 23/10/12 02:58, Bert Gunter wrote: