[R] how to eliminate first row in datafile created in do loop
Graves, Gregory
ggraves at sfwmd.gov
Tue May 24 14:30:27 CEST 2011
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
More information about the R-help
mailing list