[R] expand the inside of command with rep ?

Xu Wang xuwang762 at gmail.com
Wed Feb 10 21:27:42 CET 2010


I would like to be able to repeat a string within a command. I think there
is an easy way but I can not figure out how.

Here is an example.

I would like to turn this into the following matrix:

But I would like to do so by having a command that repeats x within the
cbind command. Does that make sense? I have tried various things mainly
involving the commands "rep" and "paste" but cannot get it.


I am guessing that this is not good programming etiquette? Something seems
off about it. But still, I would like to know how to do it.

I do understand that I can use a for loop to easily accomplish the desired
output but am looking for a solution similar to the above syntax. 

Thank you for any ideas,

Xu Wang
View this message in context: http://n4.nabble.com/expand-the-inside-of-command-with-rep-tp1476420p1476420.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list