RE: [R] Create a vector of combinations based on a table column names

2004-11-23 Thread Andy Bunn
t;"B, C""A, B" > Those nested applies make my head hurt. HTH, Andy > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Henrik Andersson > Sent: Tuesday, November 23, 2004 10:41 AM > To: [EMAIL PROTECTED] >

[Fwd: [R] Create a vector of combinations based on a table column names]

2004-11-23 Thread Adaikalavan Ramasamy
., collapse=" ") collapses all the names of the elements with value 1 apply( mat[ , 4:9], 1, ... ) applies the above process for every row Regards, Adai -Forwarded Message- From: Henrik Andersson <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: [R] Create a vector of combi

Re: [R] Create a vector of combinations based on a table column names

2004-11-23 Thread Eric Lecoutre
Hi, Here is something that does the job (though I am sure other people will find smarter solutions!): > samp=matrix(sample(0:1,size=100,replace=TRUE ,prob=c(0.8,0.2)),ncol=10) > colnames(samp)<-LETTERS[1:10] > unlist(lapply(apply(samp,1,FUN=function(vec) colnames(samp)[as.logical(vec)] ),paste,c

[R] Create a vector of combinations based on a table column names

2004-11-23 Thread Henrik Andersson
I want to create a character vector based on the table (shortened for display) below: Where there are ones in the matrix I want the column name to appear and where there are zeros nothing, which would make the vector in this shortened case: combinations <- ("A B","A C","A E H","A F G","B C D","