Displaying 10 results from an estimated 10 matches for "wyr".
Did you mean:
war
2017 Jun 07
4
Determining which.max() within groups
Using the dataset below, I got close to what I'm after, but not quite all
the way there. Any suggestions appreciated:
Daily <- read.table(textConnection(" Date wyr Q
1911-04-01 1990 4.530695
1911-04-02 1990 4.700596
1911-04-03 1990 4.898814
1911-04-04 1990 5.097032
1911-04-05 1991 5.295250
1911-04-06 1991 6.569508
1911-04-07 1991 5.861587
1911-04-08 1991 5.153666
1911-04-09 1992 4.445745
1911-04-10 1992 3.737824
1911-04-11 1992 3.001586
1911-04-12 1992...
2017 Jun 07
0
Determining which.max() within groups
cumsum() seems to be what you need.
This can probably be done more elegantly, but ...
out <- aggregate(Q ~ wyr, data = Daily, which.max)
tbl <- table(Daily$wyr)
out$Q <- out$Q + cumsum(c(0,tbl[-length(tbl)]))
out
## yields
wyr Q
1 1990 4
2 1991 6
3 1992 9
4 1993 15
5 1994 18
I leave the matter of Julian dates to you or others.
Cheers,
Bert
Bert Gunter
"The trouble with having an o...
2017 Dec 18
2
Finding center of mass in a hydrologic time series
...ich
requires the library EGRET for pulling an example dataset) works, but
probably can be replaced with some version of the apply functionality? So
far, I've been unable to figure out how to enter the arguments to the apply
function. The idea is this: for each unique water year (variable 'wyrs' in
example below) in a 27 year continuous time series of daily values, find
the date of the 'center of mass', and build a vector of those dates.
Thanks, -Eric M
library(EGRET)
StartDate <- "1990-10-01"
EndDate <- "2017-09-30"
siteNumber <- "10310000...
2017 Dec 18
0
Finding center of mass in a hydrologic time series
...EndDate <- "2017-09-30"
siteNumber <- "10310000"
QParameterCd <- "00060"
Daily <- readNWISDaily(siteNumber, QParameterCd, StartDate, EndDate)
# Define 'center of mass' function
com <- function(x) {
match(TRUE, cumsum(x/sum(x)) > 0.5) - 1
}
wyrs <- unique(Daily$waterYear)
x <- as.Date(sapply( wyrs, function(yr) { Df <-
Daily[Daily$waterYear==yr,]; Df$Date[com(Df$Q)] } ), "1970-01-01")
On Mon, Dec 18, 2017 at 4:47 PM, Morway, Eric <emorway at usgs.gov> wrote:
> Eric B's response provided just the kind o...
2012 Jun 11
2
Define a variable on a non-standard year interval (Water Years)
Hello,
I am trying to define a different interval for a "year". In hydrology,
a "water year" is defined as the period between October 1st and
September 30 of the following year. I was wondering how I might do
this in R. Say I have a data.frame like the following and I want to
extract a variable with the water year specs as defined above:
2004 Jun 10
3
Package installation
...-c wyclust.c -o
wyclust.o
gcc -I/usr/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES
-mieee-fp -fPIC -O2 -g -pipe -march=i386 -mcpu=i686 -c wygrps.c -o
wygrps.o
gcc -I/usr/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES
-mieee-fp -fPIC -O2 -g -pipe -march=i386 -mcpu=i686 -c wyr.c -o wyr.o
gcc -I/usr/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES
-mieee-fp -fPIC -O2 -g -pipe -march=i386 -mcpu=i686 -c wyutils.c -o
wyutils.o
gcc -I/usr/lib/R/include -I/usr/local/include -D__NO_MATH_INLINES
-mieee-fp -fPIC -O2 -g -pipe -march=i386 -mcpu=i686 -c wyuvar.c -o
w...
2011 Apr 22
1
Paste problem when looping variable assignments
...(yr)
for(n in 1:len){
WY[n]<-if(mo[n]>=10){
yr[n]+1
}else{
yr[n]}
}
partialpeakind<-which(round(q,2)>=round(pds_TD[i],2))
partialpeaksd<-dates[partialpeakind]
partialpeaksq<-q[partialpeakind]
partialpeaksWY<-WY[partialpeakind]
for(q in 1:length(partialpeaksWY)){
wyrs<-seq(min(partialpeaksWY),max(partialpeaksWY),by=1)
POTWY[[q]]<-sum(partialpeaksWY == wyrs[q])
POTWY_cut<-as.numeric(na.omit(POTWY))
paste(pds_gagehandles[[i]],"_pdswy",sep="")<-POTWY_cut}
pds_dropdates<-data.frame(partialpeaksWY,partialpeaksd,partialpeaksq)...
2017 Dec 16
0
Finding center of mass in a hydrologic time series
Hi Eric,
How about
match( TRUE, cumsum(hyd/sum(hyd)) > .5 ) - 1
HTH,
Eric
On Sat, Dec 16, 2017 at 3:18 PM, Morway, Eric <emorway at usgs.gov> wrote:
> The small bit of script below is an example of what I'm attempting to do -
> find the day on which the 'center of mass' occurs. In case that is the
> wrong term, I'd like to know the day that essentially cuts
2017 Dec 16
3
Finding center of mass in a hydrologic time series
The small bit of script below is an example of what I'm attempting to do -
find the day on which the 'center of mass' occurs. In case that is the
wrong term, I'd like to know the day that essentially cuts the area under
the curve in to two equal parts:
set.seed(4004)
Date <- seq(as.Date('2000-09-01'), as.Date('2000-09-30'), by='day')
hyd <-
2009 Jul 23
1
[PATCH server] changes required for fedora rawhide inclusion.
...&QzE$L8(uhNZKseeL_a)E_(C$tJS6stS>%Y3eC&TITbw
zAB~0>A_1*!$AG0?iIgQve?n#iN4^+-U9p-SKyx_&N!G408`>^3nNtEd6%Mz_X~^w+
z*e2hC$~CM(nbl3HzmU~2OOVs`wMd`WPhO6r02nF&JI%N@?0zhz-JZeH0$)+-B!UNv
zMu4GQ;Xq~FEukwEo`P;yMC=@O9x#RDERC`PD}orXcth#9;CiI&nT!MKIwZX6EB!{t
zsJTWojU%vFz(Ol7JpU8E@?Xrwyrw)-5(j&E$0$v~9!Ve(*6%%VOYO{13ir(m4ck#T
zLZ)g!^}PRsQN+0Or5i8O<UYPx>!2Hos1=HN_$cvG0=|;W1O=e+A%I4_EOT~=acLvy
zypqIX%`W*R5F!Y;&pNeavzDJaTXVguv*btnyvG}sp}hsA1j`1Gg|p;hKh~tDzAM-u
zgXY`XazPFk0=TU5`!@yTuV&u>Xx>La$|>L!eIYH-&Z?%%_N3u}?zNy+4Q}_LlnBOC
z*}@x at Iv<K1fXQhbr0Vjlew...