Mr_Pag
October 17th, 2009, 10:58 AM
Hi Folks,
I have a question regarding wildcards in R, could I simplify this following code using control structures? i.e a for statement for (i in 1:n)
yarn1 <- yarn[which(yarn$spinner=='1'),]
yarn2 <- yarn[which(yarn$spinner=='2'),]
yarn3 <- yarn[which(yarn$spinner=='3'),]
...
yarnn <- yarn[which(yarn$spinner=='n'),]
I can't figure out how to directly itegrate wildcards into variable names. I had a look through the R archives, but have had no luck.
Can anyone point me in the direction of a solution, or has a solution?
Thanks in advance,
Alan
I have a question regarding wildcards in R, could I simplify this following code using control structures? i.e a for statement for (i in 1:n)
yarn1 <- yarn[which(yarn$spinner=='1'),]
yarn2 <- yarn[which(yarn$spinner=='2'),]
yarn3 <- yarn[which(yarn$spinner=='3'),]
...
yarnn <- yarn[which(yarn$spinner=='n'),]
I can't figure out how to directly itegrate wildcards into variable names. I had a look through the R archives, but have had no luck.
Can anyone point me in the direction of a solution, or has a solution?
Thanks in advance,
Alan