Dear useRs,
I have the data of following format. I have only pasted some part of the data.
The data starts from 1961 and ends up in december 1987.
dat - read.table(text=Date A B C D1-Jan-61 0.00 1.27 8.128 0.252-Jan-61 6.10
9.144 94.742 15.493-Jan-61 0.00 0.508 1.27 0.004-Jan-61 0.00 0 NA
Hello,
Maybe the following will do.
library(zoo)
ym - as.yearmon(dat$Date, %d-%B-%y)
aggregate(dat[,-1], list(ym), FUN = sum, na.rm = TRUE)
Also, please use dput() to post data examples.
Hope this helps,
Rui Barradas
Em 31-03-2014 18:31, eliza botto escreveu:
Dear useRs,
I have the data
...@hotmail.com; r-help@r-project.org
Subject: Re: [R] monthly sum
Hello,
Maybe the following will do.
library(zoo)
ym - as.yearmon(dat$Date, %d-%B-%y)
aggregate(dat[,-1], list(ym), FUN = sum, na.rm = TRUE)
Also, please use dput() to post data examples.
Hope this helps,
Rui Barradas
not to be working. I am
getting the following error.
Error in FUN(X[[1L]], ...) : invalid 'type' (character) of argument
Any idea? :(
Thanks,
Eliza
Date: Mon, 31 Mar 2014 18:48:08 +0100
From: ruipbarra...@sapo.pt
To: eliza_bo...@hotmail.com; r-help@r-project.org
Subject: Re: [R] monthly sum
] On
Behalf
Of eliza botto
Sent: Monday, March 31, 2014 12:12 PM
To: ruipbarra...@sapo.pt; r-help@r-project.org
Subject: Re: [R] monthly sum
Dear Rui,
Here is the complete data.
dput(dat)
structure(list(Date = c(1-Jan-61, 2-Jan-61, 3-Jan-61, 4-Jan-61,
5-Jan-61, 6-Jan-
61, 7-Jan-61, 8-Jan
...@sapo.pt
To: eliza_bo...@hotmail.com; r-help@r-project.org
Subject: Re: [R] monthly sum
Hello,
Sorry, but I have no idea why the error message, with me it works
correctly. Are you sure that the four columns A, B, C and D are numeric?
What does str(dat) say?
Rui Barradas
Em 31-03-2014 19
= c(NA, 20L), class =
data.frame)
Thanks,
Eliza
From: eliza_bo...@hotmail.com
To: ruipbarra...@sapo.pt; r-help@r-project.org
Date: Mon, 31 Mar 2014 19:11:34 +
Subject: Re: [R] monthly sum
Dear Rui,
Here is the complete data.
dput(dat)
structure(list(Date = c(1-Jan-61, 2
From: eliza_bo...@hotmail.com
To: ruipbarra...@sapo.pt; r-help@r-project.org
Date: Mon, 31 Mar 2014 19:11:34 +
Subject: Re: [R] monthly sum
Dear Rui,
Here is the complete data.
dput(dat)
structure(list(Date = c(1-Jan-61, 2-Jan-61, 3-Jan-61,
4-Jan-61, 5-Jan-61, 6-Jan-61, 7-Jan-61
8 matches
Mail list logo