Gregory: Would setting limit.list <- NULL at the start do the trick? See example below:
Analogue of your example: lower <- 0 upper <- 0 limit.list<-data.frame(lower,upper) for(i in 1:12) { some.data <- rnorm(2) lower <- min(some.data) upper <- max(some.data) one.month <- data.frame(lower, upper) limit.list <- rbind(limit.list, one.month) } limit.list Approach that doesn't give zeroes at the start: limit.list <- NULL for(i in 1:12) { some.data <- rnorm(2) lower <- min(some.data) upper <- max(some.data) one.month <- data.frame(lower, upper) limit.list <- rbind(limit.list, one.month) } limit.list -Ian On 5/24/11 7:30 AM, "Graves, Gregory" <ggra...@sfwmd.gov> wrote: >I am trying to create a routine that would take a time series and >generate monthly 25%tile and 75%tile limits based on 12 calendar months. >I have succeeded to create a do loop to do this, but can't figure out >how to initiate the receiving datafile (in this case "limit.list") >without sticking an initial set of zeroes in. I'd like to be able to >insert a new column "i.value" for each time "i" increments 1 thru 12, to >represent the 12 months, but I can't figure out how to join the value of >i to the "lower" and "upper" variables. Close but no cigar here. > >lower=0 >upper=0 >limit.list<-data.frame(lower,upper) >for(i in 1:12){ > s=subset(paleo,month==i); > one.month=with(s, quantile(WBpaleo, c(.25, .75), na.rm=T)); > limit.list<-rbind(limit.list,one.month) >} >limit.list > >which gives me this: >> limit.list > lower upper >1 0.00000 0.00000 >2 25.51786 29.68823 >3 26.09828 30.92770 >4 27.75703 33.04016 >5 29.53395 36.14273 >6 30.89420 37.65727 >7 29.27843 37.59690 >8 27.50141 34.36265 >9 26.40554 32.88533 >10 25.13494 29.83829 >11 23.48982 27.14612 >12 22.88814 27.52782 >13 24.51789 28.24871 > >How do I avoid having row 1 in my list? > >I can delete the first row with: >limit.list = limit.list[-1,] > >but that messes up my month variable > >> limit.list > lower upper >2 25.51786 29.68823 >3 26.09828 30.92770 >4 27.75703 33.04016 >5 29.53395 36.14273 >6 30.89420 37.65727 >7 29.27843 37.59690 >8 27.50141 34.36265 >9 26.40554 32.88533 >10 25.13494 29.83829 >11 23.48982 27.14612 >12 22.88814 27.52782 >13 24.51789 28.24871 > >______________________________________________ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.