Re: [R] Combined variable names

2004-12-03 Thread Martin Maechler
> "Richard" == Richard A O'Keefe <[EMAIL PROTECTED]> > on Fri, 3 Dec 2004 14:53:04 +1300 (NZDT) writes: Richard> I wrote about the perennial "assign to V1 ... Vn" problem: >> >What I want to know is *WHY* people are doing this? Richard> I failed to make myself clear.

Re: [R] Combined variable names

2004-12-02 Thread Richard A. O'Keefe
I wrote about the perennial "assign to V1 ... Vn" problem: > >What I want to know is *WHY* people are doing this? I failed to make myself clear. What I meant was "what happens NEXT? Once someone has got past the stage of generating V1 ... V100 (or whatever the magic number is), what do t

Re: [R] Combined variable names

2004-12-02 Thread Peter Dalgaard
[EMAIL PROTECTED] (Bjørn-Helge Mevik) writes: > Peter Dalgaard writes: > > > There are irregularities, e.g. the fact that you do help(foo), not > > help("foo"), but they tend to get a pain in the long run (How do you > > get help on a name contained in a variable? > > v <- "lm"; help(v) > works

Re: [R] Combined variable names

2004-12-02 Thread Bjørn-Helge Mevik
Peter Dalgaard writes: > There are irregularities, e.g. the fact that you do help(foo), not > help("foo"), but they tend to get a pain in the long run (How do you > get help on a name contained in a variable? v <- "lm"; help(v) works for me :-) (But I totally agree that the regularity of R (or S

Re: [R] Combined variable names (two concrete suggestions)

2004-12-01 Thread Douglas Bates
Tiago R Magalhaes wrote: For loops are conceptually very easy to understand. Lists are not easy to understand (why list[[1]] instead of list[1]? it's not completely intuitive) . I try to explain it as comparable to the difference between a subset that consists of one element (the "[" function al

Re: [R] Combined variable names

2004-12-01 Thread Peter Dalgaard
Kjetil Brinchmann Halvorsen <[EMAIL PROTECTED]> writes: > >This is, of course, a FAQ. It's such a FAQ that I must have seen it > >once a day for the last several days. > > > >What I want to know is *WHY* people are doing this? > > > Bad habits from less expressive languages? Actually, from less

Re: [R] Combined variable names

2004-12-01 Thread Kjetil Brinchmann Halvorsen
Richard A. O'Keefe wrote: Tobias Muhlhofer <[EMAIL PROTECTED]> wrote: I am trying to define a large number of variables through a loop construct. He wants to do for (i in 1:100) { assign(paste("v", i, sep=""), something or other...) } This is

Re: [R] Combined variable names (two concrete suggestions)

2004-12-01 Thread Tiago R Magalhaes
Very interesting topic. "What I want to know is *WHY* people are doing this?" Here goes my view - I've used many for loops, and each time I realize how stupid that is... AFTER I learned how to avoid it. But it's difficult to avoid them without knowing how to do it. (Monsieur de LaPalice wouldn'

Re: [R] Combined variable names

2004-12-01 Thread Douglas Bates
Richard A. O'Keefe wrote: Tobias Muhlhofer <[EMAIL PROTECTED]> wrote: I am trying to define a large number of variables through a loop construct. He wants to do for (i in 1:100) { assign(paste("v", i, sep=""), something or other...) } This is

Re: [R] Combined variable names

2004-11-30 Thread Richard A. O'Keefe
Tobias Muhlhofer <[EMAIL PROTECTED]> wrote: I am trying to define a large number of variables through a loop construct. He wants to do for (i in 1:100) { assign(paste("v", i, sep=""), something or other...) } This is, of course, a FAQ. It's

Re: [R] Combined variable names

2004-11-30 Thread Peter Dalgaard
Tobias Muhlhofer <[EMAIL PROTECTED]> writes: > I am trying to define a large number of variables through a loop construct. > > I have my loop variable i being cycled through 1:100 and I would like > the variables produced by this to be called > > vi (i.e. v1 v2 v3 etc) > > so, for example I'm g

Re: [R] Combined variable names

2004-11-30 Thread Jean Eid
see ?assign and ?get i,e instead ob below have something like assign(paste("v", i, sep=""), a[i:N]) and if you need to loop over calling them say get(paste("v", i, sep="")) of course typing v1 will call the variable... Jean On Tue, 30 Nov 2004, Tobias Muhlhofer wrote: > I am trying to defin

Re: [R] Combined variable names

2004-11-30 Thread Sean Davis
See the R-FAQ here: http://cran.r-project.org/doc/FAQ/R-FAQ.html Number 7.21. However, as the FAQ also points out, you might be better served using lists. a <- list() for (i in 1:100) { a[[i]] <- some stuff } Sean On Nov 30, 2004, at 5:42 PM, Tobias Muhlhofer wrote: I am trying to define a lar

Re: [R] Combined variable names

2004-11-30 Thread Thomas Lumley
On Tue, 30 Nov 2004, Tobias Muhlhofer wrote: I am trying to define a large number of variables through a loop construct. I have my loop variable i being cycled through 1:100 and I would like the variables produced by this to be called vi (i.e. v1 v2 v3 etc) Look at FAQ 7.21, which explains how to

[R] Combined variable names

2004-11-30 Thread Tobias Muhlhofer
I am trying to define a large number of variables through a loop construct. I have my loop variable i being cycled through 1:100 and I would like the variables produced by this to be called vi (i.e. v1 v2 v3 etc) so, for example I'm going: for(i in 1:100) { <- a[i:N] # or whatever else you want