[R] Combine factorial column intp a new column

Beatriz R. Gonzalez Dominguez aguitatierra at hotmail.com
Thu May 22 10:05:48 CEST 2014


Dear R-users,

I'd be very greatful if you could help me with the following as after a 
few tests I haven't still been able to get the right outcome.

I've got this data:
dd_1 <- data.frame(ID = c("1","2", "3", "4", "5"),
                  Class_a = c("a",NA, "a", NA, NA),
                  Class_b = c(NA, "b", "b", "b", "b"))

And I'd like to produce a new column 'CLASS':
dd_2 <- data.frame(ID = c("1","2", "3", "4", "5"),
                  Class_a = c("a",NA, "a", NA, NA),
                  Class_b = c(NA, "b", "b", "b", "b"),
                  CLASS = c("a", "b", "a-b", "b", "b"))

Thanks a lot!



More information about the R-help mailing list