Hi Alyssa
Several of the D-RUG people are at the useR! conference so are probably busy.
1) There are many ways and packages to help you do this. You may want to use packages such as dplyr.
However, the core R facilities are good to master, also.
Since you already have month as a separate column from the date, you don't have to deal with the
date column.
# read the data into a data frame.
d = read.table("Alyssa.dat", stringsAsFactors = FALSE)
# Subset the rows corresponding to April-November inclusive.
tmp = d[ d$Mes >= 4 & d$Mes <= 11, ]
# Group the value observations in tmp by year and for each of these
# call sum() to add up all the elements.
tapply(tmp$value, tmp$Ano, sum)
1967 1968
NA 28.4
This gives a missing value for 1967. If we want to omit these
when performing the sum(),
tapply(tmp$value, tmp$Ano, sum, na.rm = TRUE)
1967 1968
11.0 28.4
Please let me know if I've made a mistake or misunderstood the task.
And I see Brandon has just given you the dplyr version.
D.
> --
> Check out our R resources at
http://d-rug.github.io/
> ---
> You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
davis-rug+...@googlegroups.com <mailto:
davis-rug+...@googlegroups.com>.
--
Director, Data Sciences Initiative, UC Davis
Professor, Dept. of Statistics, UC Davis
http://datascience.ucdavis.edu
http://www.stat.ucdavis.edu/~duncan