Certainly closer, and I can get by with this ... but ... would like to not have the "one.month"s .
limit.list<-NULL for(i in 1:12){ s=subset(paleo,month==i); one.month=with(s, quantile(WBpaleo, c(.25, .75), na.rm=T)); one.month=c(as.character(i),one.month); limit.list<-rbind(limit.list,one.month) } > limit.list 25% 75% one.month "1" "25.51786389" "29.68823492" one.month "2" "26.09827974" "30.9276985" one.month "3" "27.757034405" "33.040163045" one.month "4" "29.53395155" "36.1427293975" one.month "5" "30.894195075" "37.657271835" one.month "6" "29.27843098" "37.59689852" one.month "7" "27.5014142975" "34.36265367" one.month "8" "26.4055425" "32.88533117" one.month "9" "25.1349430375" "29.838291435" one.month "10" "23.48982439" "27.14611846" one.month "11" "22.88814497" "27.52782293" one.month "12" "24.5178851225" "28.248711925" -----Original Message----- From: Ian Gow [mailto:iand...@gmail.com] Sent: Tuesday, May 24, 2011 8:58 AM To: Graves, Gregory; Nungesser, Martha; r-help@r-project.org Cc: Kemp, Susan K SAJ; patrick_pi...@fws.gov Subject: Re: [R] how to eliminate first row in datafile created in do loop 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.