Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
]> > Subject: Re: [R] Loop on vector name > To: [EMAIL PROTECTED] > Date: Friday, September 19, 2008, 11:20 AM > hi: i'm not sure if i'm understanding your question > because the sapply > output is a vector. see below. > > > dat1 <- rnorm(5) > dat2 &l

Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
Rizopoulos <[EMAIL PROTECTED]> > Subject: Re: [R] Loop on vector name > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Date: Wednesday, September 17, 2008, 5:32 PM > you need to get(), e.g., try this: > > dat1 <- rnorm(5) > dat2 <- rnorm(6) > dat3 <- r

Re: [R] Loop on vector name

2008-09-17 Thread Greg Snow
object, etc. Hope this helps, > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org] On Behalf Of Megh Dal > Sent: Wednesday, September 17, 2008 5:51 AM > To: [EMAIL PROTECTED] > Subject: [R] Loop on vector name > > [My previous mess

Re: [R] Loop on vector name

2008-09-17 Thread Dimitris Rizopoulos
you need to get(), e.g., try this: dat1 <- rnorm(5) dat2 <- rnorm(6) dat3 <- rnorm(7) lis <- lapply(paste("dat", 1:3, sep = ""), get) lis sapply(lis, sd) I hope it helps. Best, Dimitris Megh Dal wrote: [My previous message rejected, therefore I am sending same one with some modification]

Re: [R] Loop on vector name

2008-09-17 Thread Henrique Dallazuanna
Try this: sapply(ls(patt="^dat[0-9]"), function(x)sd(get(x))) On Wed, Sep 17, 2008 at 8:50 AM, Megh Dal <[EMAIL PROTECTED]> wrote: > [My previous message rejected, therefore I am sending same one with some > modification] > > I have 3 vectors with object name : dat1, dat2, dat3 > > Now I want to

[R] Loop on vector name

2008-09-17 Thread Megh Dal
[My previous message rejected, therefore I am sending same one with some modification] I have 3 vectors with object name : dat1, dat2, dat3 Now I want to create a loop, like : for (i in 1:3) { cat(sd(dati)) } How I can do this in R? Regards,