Re: [R] create variables with indexes

2010-07-13 Thread Jeff Newmiller
In virtually every case where people think they need gobs of similarly-named variables, what they really need are vectors or data frames. I strongly recommend reading the Introduction to R document again to learn how to create them and access individual elements and subsets of elements.Data fram

Re: [R] create variables with indexes

2010-07-13 Thread Greg Snow
It looks like you want to use a matrix, then you can do proper indexing. Creating the names will just lead to unnecessary complexity and confusion. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- >

Re: [R] create variables with indexes

2010-07-13 Thread T.D. Rudolph
Here is another way of going about it (presuming we are correct about what you are after): i=1:10 j=1:10 unlist(lapply(i, function(x) paste("X", x, j, sep="_"))) Tyler -- View this message in context: http://r.789695.n4.nabble.com/create-variables-with-indexes-tp2288119p2288171.html Sent from

Re: [R] create variables with indexes

2010-07-13 Thread Erik Iverson
Suppose I want create variables with indexes in their names, e.g., X_1_1, X_1_2, X_1_3, ..., X_1_10, X_2_1, X_2_2, X_2_3, .. X_2_10,..., X_10_1, X_10_2, ... X_10_10. It looks like I need to use 2 indexes I and J so I is looped from 1 to 10, and J is looped from 1 to 10. But I don't know how to

Re: [R] create variables with indexes

2010-07-13 Thread Wenbo Mu
Maybe I misunderstand your problem. For my understanding, it's quite simple.I hope it can help. id <- vector() for(i in 1:10){ for(j in 1:10){ id<-append(id,paste("X",i,j,sep="_")) } } Wenbo Mu On Tue, Jul 13, 2010 at 5:44 PM, He, Yulei wrote: > Hi, there: >