n(ddate1$date,date2[4],date2[3]),"Season"]<-2
ddate1[is.between(ddate1$date,date2[6],date2[5]),"Season"]<-3
ddate1[is.between(ddate1$date,date2[8],date2[7]),"Season"]<-4
ddate1
date Season
1 1998-12-29 20:00:33 NA
2 1999-01-02
Thanks arun and Rui; 3 fantastic suggestions.
The Season interval is not always a month so arun's suggestion works better
for this dataset. I couldn't get the as.between function to work on arun's
second suggestion, it only returned NAs.
However, arun's first suggestion worked a treat!
Many th
999-01-02 06:18:36 2
4 1999-02-02 07:06:59 3
5 1999-03-02 07:10:56 4
6 1999-03-02 07:57:18 4
A.K.
- Original Message -
From: penguins
To: r-help@r-project.org
Cc:
Sent: Sunday, August 5, 2012 4:30 PM
Subject: [R] find date between two other dates
Hi,
I am trying to a
"]<-3
ddate1[ddate1$date=date3[7],"Season"]<-4
ddate1
date Season
1 1998-12-29 20:00:33 1
2 1999-01-02 05:20:44 2
3 1999-01-02 06:18:36 2
4 1999-02-02 07:06:59 3
5 1999-03-02 07:10:56 4
6 1999-03-02 07:57:18 4
A.K.
- Origin
Hello,
You can use a function that returns the number you want, not a logical
value.
But first, it's a bad idea to have a data.frame and a vector with the
same name, so, in what follows, I've altered the df name.
ddate <- c("29/12/1998 20:00:33", "02/01/1999 05:20:44", "02/01/1999
06:18:36",
Hi,
I am trying to assign "Season" values to dates depending on when they occur.
For example, the following dates would be assigned the following "Season"
numbers based on the "season" intervals detailed below in the code:
ddate Season
29/12/1998 20:00:33 1
02
6 matches
Mail list logo