Hello Everybody,
I'm working with a dataframe that has 18 columns. I would like to subset the
data in one of these columns, "present", according to combinations of data in
six of the other columns within the data frame and then save this into a text
file. The columns I would like to use to subset "present" are:
* answer (1:4) [answer takes the values 1 to 4]
*p.num (1:18)
* session (1:2)
* count (1:8)
* type (1:3)
So there are a total of 3456 possible subsetting combinations.
At present, I have been using the following and manually changing the values in
each line and re-running the code.
input<-subset(input, answer==1)
input.s2g<-subset(input, p.num == 1)
input.s2g<-subset(input.s2g, session == "S2")
input.s2g<-subset(input.s2g, count==8)
input.s2g<-subset(input.s2g, type==1)
write.table(s2g, file = "1_1_S2_8_1", sep = "\t", col.names = F, row.names = F)
But this takes me hours and is obviously prone to error. There must be an
easier way?
Thanks for any help!
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.