Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
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 - rnorm(7) lis - lapply(paste(dat, 1:3, sep = ), get) lis sapply(lis, sd) I

Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
(lis, sd) to vector? --- On Wed, 9/17/08, Dimitris Rizopoulos [EMAIL PROTECTED] wrote: From: Dimitris 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

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 create a

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] I have

Re: [R] Loop on vector name

2008-09-17 Thread Greg Snow
Others have answered the question that you asked (it is also a variation of Faq 7.21), but here is an answer to the question that you should have asked: When working with datasets like this, it is better to create a list rather than separate objects with names like dat1, dat2, etc. For