[R] Generate strings from multiple variables

Johannes Radinger JRadinger at gmx.at
Fri May 4 15:10:55 CEST 2012


Hi,

it is easiest to explain what I want to do by an example:

lets assume there are two factors/variables:
A <- c(1,2,3)
B <- c(1,3,3)

Now I would like to generate a list of strings that should look like
("A1_B1","A1_B2","A2_B1","A2_B2"). So actually the string
contains all possible combinations of A and B (separated by _). This should
be also possible for more variables. Is there simple way
to that? I thought about looping over A and B (nested for-loop)
but maybe there is a straight foward solution to get such strings.

/johannes


-- 

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a



More information about the R-help mailing list