Re: [R] help with loops

2011-08-12 Thread Paul Hiemstra
t;> Cc: r-help@r-project.org >> Subject: Re: [R] help with loops >> >> No problem, >> >> By the way, you can't (or at least shouldn't) use return() outside of a >> function -- that was the source of your old error message. >> >> If you, f

Re: [R] help with loops

2011-08-11 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of R. Michael > Weylandt > Sent: Thursday, August 11, 2011 10:09 AM > To: Srinivas Iyyer > Cc: r-help@r-project.org > Subject: Re: [R] help with loops >

Re: [R] help with loops

2011-08-11 Thread R. Michael Weylandt
t; --- On *Thu, 8/11/11, R. Michael Weylandt *wrote: > > > From: R. Michael Weylandt > Subject: Re: [R] help with loops > To: "Srinivas Iyyer" > Cc: r-help@r-project.org > Date: Thursday, August 11, 2011, 12:49 PM > > > unlist() > > Michael Weylandt > &g

Re: [R] help with loops

2011-08-11 Thread Srinivas Iyyer
Thank you. that was very easy. -srini --- On Thu, 8/11/11, R. Michael Weylandt wrote: From: R. Michael Weylandt Subject: Re: [R] help with loops To: "Srinivas Iyyer" Cc: r-help@r-project.org Date: Thursday, August 11, 2011, 12:49 PM unlist() Michael Weylandt On Thu, Aug 11, 201

Re: [R] help with loops

2011-08-11 Thread R. Michael Weylandt
unlist() Michael Weylandt On Thu, Aug 11, 2011 at 12:46 PM, Srinivas Iyyer wrote: > hi I need help with list object. > > I have a list object > > > a <- c('apple','orange','grape') > > b <- c('car','truck','jeep') > > c <- list(a,b) > > names(c) <- c('fruit','vehicle') > > c > $fruit > [1] "appl

[R] help with loops

2011-08-11 Thread Srinivas Iyyer
hi I need help with list object. I have a list object > a <- c('apple','orange','grape') > b <- c('car','truck','jeep') > c <- list(a,b) > names(c) <- c('fruit','vehicle') > c $fruit [1] "apple" "orange" "grape" $vehicle [1] "car" "truck" "jeep" I want to write all the elements of this l

Re: [R] Help with Loops

2010-05-13 Thread David Winsemius
On May 13, 2010, at 10:49 AM, Amit Patel wrote: Hi I have tried many attempts but cant get the loop right, as I am not a strong programmer. What I am basically trying to do is compare 2 spreadsheets. The problem is that one of them only contain a portion of the overall data (TESTSAMP), w

Re: [R] Help with Loops

2010-05-13 Thread Steve Lianoglou
Hi, On Thu, May 13, 2010 at 10:49 AM, Amit Patel wrote: > Hi > > I have tried many attempts but cant get the loop right, as I am not a strong > programmer. What I am basically trying to do is compare 2 spreadsheets. The > problem is that one of them only contain a portion of the overall data >

Re: [R] Help with Loops

2010-05-13 Thread Sarah Goslee
You don't need a loop for this, I think. Since you don't provide an example it's hard to know how your data are set up, but look at this: > FULLSAMP <- data.frame(A = 1:10, B=letters[1:10]) > TESTSAMP <- data.frame(A = c(2,4,5,8), C=1:4) > FULLSAMP A B 1 1 a 2 2 b 3 3 c 4 4 d 5 5 e 6

[R] Help with Loops

2010-05-13 Thread Amit Patel
Hi I have tried many attempts but cant get the loop right, as I am not a strong programmer. What I am basically trying to do is compare 2 spreadsheets. The problem is that one of them only contain a portion of the overall data (TESTSAMP), where the other has a full datasetFULLSAMP. From the com

[R] help with loops

2009-10-14 Thread Marcio Resende
Hi guys, my doubt is quite simple, I´ll try to explain: test = matrix(0, nrow = 783, ncol = 12) for (x in 1:9){ for (y in 1:12){ ### In the original script for each y its generated a vector (87x1) ### 87 times 9(x) = 783 (equals the number of rows I want to fill in the "test" matrix } } W

Re: [R] Help with loops

2009-05-15 Thread Jorge Ivan Velez
Dear Amit, The following should get you started. What I'm doing is creating an identifiers (g) with the "names" of the columns you want to group for and then use a combination of apply() and tapply() to get the mean for each row in the levels of g. In your case, you have more columns than I have in

Re: [R] Help with loops

2009-05-15 Thread David Freedman
I'm not quite sure what you want to do, but this might help: d=data.frame(replicate(40, rnorm(20))) d$sample=rep(c('a','b','c','d'),each=5) lib(doBy) summaryBy(.~sample,da=d) David Freedman Amit Patel-7 wrote: > > > Hi > I am trying to create a loop which averages replicates in my data. > The

[R] Help with loops

2009-05-15 Thread Amit Patel
Hi I am trying to create a loop which averages replicates in my data. The original data has many rows. and consists of 40 column zz[,2:41] plus row headings in zz[,1] I am trying to average each set of values (i.e. zz[1,2:3] averaged and placed in average_value[1,2] and so on. below is my script

Re: [R] Help with loops and how R stores data

2008-02-04 Thread Ted Harding
On 02-Feb-08 21:16:41, R-novice wrote: > > I am trying to make an array c(3,8) that contains the averages of what > is in another array c(9,8). I want to average rows 1:3, 4:6, 7:9 and > have a loop replace the generic 1:24 values in my array with the > average of the three rows. > > The probl

[R] Help with loops and how R stores data

2008-02-03 Thread R-novice
I am trying to make an array c(3,8) that contains the averages of what is in another array c(9,8). I want to average rows 1:3, 4:6, 7:9 and have a loop replace the generic 1:24 values in my array with the average of the three rows. The problem I am having is that R only replaces the last value