You're totally right Jeff. My mistake! to use with, we write it like this:
DF$season <- factor ( with ( *DF*, ifelse (( month == 12 | nonth == 1 |
month == 2 ), "Win",
ifelse ((month == 3 | nonth == 4 | month == 5 )
, "Spr",
ifelse
67
4 2006 Q4 2.47
A.K.
- Original Message -
From: jeff6868
To: r-help@r-project.org
Cc:
Sent: Wednesday, August 1, 2012 4:57 AM
Subject: [R] how to calculate seasonal mean for temperatures
Hello everybody,
I need to calculate seasonal means with temperature data for my work.
I h
Here is my approximation:
# Creation of the temporal variables
DF$year <- as.numeric(format(DF$date, format = "%Y"))
DF$month <- as.numeric(format(DF$date, format = "%m"))
# For years with data from 2006 to 2008
DF_type1 <- DF [ - which (year == 2006 & month ==1 | year == 2006 & month ==
2 |
Hello,
See if this is it.
fun <- function(DF, FUN = mean){
month <- as.integer(format(DF$date, format="%m"))
year <- format(DF$date, format="%Y")
month[month %in% 1:2] <- 13
DF$season <- NA
DF$season[month %in% 12:13] <- paste(year[month %in% 12:13], "Winter")
DF$season[
It's working now!
The problem was not for winter, but with the "with" you had in your object
"DF$season. I got an error: invalid 'envir' argument.
I removed it and now it seems to be OK.
Thank you very much for your help ricardo.
--
View this message in context:
http://r.789695.n4.nabble.com/
Thank you both for your answers.
I found a best way to delete the first 2 months (Jan + Feb) and the last
month (Dec), which should work everytime:
DF$year <- as.numeric(format(DF$Day, format = "%Y"))
DF$month <- as.numeric(format(DF$Day, format = "%m"))
# delete first 2 months
for(i in DF[1,3]
Hi
Something like
aggregate(DF$data, list(quarters(DF$date), format(DF$date, "%Y")), mean)
Regards
Petr
>
> Hello everybody,
>
> I need to calculate seasonal means with temperature data for my work.
> I have 70 files coming from weather stations, which looks like this for
> example:
>
> sta
Hello everybody,
I need to calculate seasonal means with temperature data for my work.
I have 70 files coming from weather stations, which looks like this for
example:
startdate <- as.POSIXct("01/01/2006", format = "%d/%m/%Y")
enddate <- as.POSIXct("05/01/2006", format = "%d/%m/%Y")
date <- seq(
8 matches
Mail list logo