Re: [R] Recoding multiple TRUE/FALSE columns into a single list of TRUE columns

2011-12-25 Thread David Epstein
Jim, Wow, that does it! I think I can use strsplit and unlist to convert the string of row names into a R list. thank you! -david __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http:

Re: [R] Recoding multiple TRUE/FALSE columns into a single list of TRUE columns

2011-12-25 Thread jim holtman
Try this: > x <- read.table(text = " P1 P2 P3 P4 + 1 0011 + 2 0111 + 3 1000 + 4 0000 + 5 1111 ", header = TRUE) > labs <- apply(x, 1, function(.row){ + indx <- which(.row == 1) + if (length(indx) > 0) return(pas

[R] Recoding multiple TRUE/FALSE columns into a single list of TRUE columns

2011-12-25 Thread David Epstein
Hi everyone, I need to recode multiple columns in a dataframe into a single column in a variety of different ways. Often the values will be TRUE/FALSE and I want a list of the columns that are true as in the Result column below: P1 P2 P3 P4 Result 1 0011P3,P4 2