[R] all subset of a data frame column
Hamid Hamid
hamid200356 at gmail.com
Mon Feb 2 21:56:34 CET 2009
Dear All,
I have a data frame (mydata), with let say 5 columns V1,V2,...,V5.
(we know the power set of {V1,V2,..,V5} has 2^5-1 elements). I need
to construct a vector T of length 5 which its i-th element is the
maximum of (let say) mean values obtained based on the columns subset
of size i.
I mean:
T[1]=max(mean(mydata[,1]),...,mean(mydata[,5]))
T[2]=max(mean(mydata[,c(1,2)],mean(mydata[,c(1,3)],...,mean(mydata[,c(1,5])
T[3]=max(mean(mydata[,c(1,2,3)],mean(mydata[,c(1,2,4)],...,mean(mydata[,c(3,4,5)])
....
T[5]=max(mean(mydata[,c(1,2,3,4,5)]
Many thanks in advance.
Hamid
More information about the R-help
mailing list