[R] Analyse the effect of group membership

Noah Marconi noah.marconi at noah-marconi.com
Mon Mar 24 22:08:06 CET 2014


Does this help?

set.seed(500)
mtx <- matrix(round(runif(100,0,1)),
        ncol=5,
        dimnames=list(Subject=1:20,
                      Group=c('A','B','C','D','E')))

groupCombo <- apply(mtx, 1, function(x){
   x <- paste(
     names(x)[as.logical(x)],
     collapse='+'
   );
   return(x)
})

as.factor(groupCombo)


On 2014-03-24 13:50, Tom Wright wrote:
> Hi,
> Given a matrix
> set.seed(500)
> matrix(round(runif(100,0,1)),
> 	ncol=5,
> 	dimnames=list(Subject=1:20,
> 	Group=c('A','B','C','D','E')))
> 
> Is there an easy way to identify which combinations of groups exist,
> i.e. subject2 is a member of group 'A+B+D+E' however no one is a member
> of 'A+B+C+D'.
> 
> I want to analyze if particular combinations of groups have worse
> outcomes than others. I admit I'm not really sure how to do this, if
> anyone has any pointers I'll be happy to hear them.
> 
> Thanks,
> Tom
> 
> ______________________________________________
> R-help at r-project.org 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.




More information about the R-help mailing list