I didn’t see how your data was stored so I invented a database.
This sequence of operations will take only the period from 20/06 to 20/09 of all the years that are at the base.
library(lubridate)
library(dplyr)
dados <- data.frame(
datas = seq(as.Date('1900-01-01'),as.Date('2000-12-31'),by = 1),
valor = 1:36890
)
dados %>% tbl_df %>%
# pegar apenas os meses de junho a setembro
filter(month(datas) <= 9, month(datas) >= 6) %>%
# se for junho, só pegar os dias maiores que 20
filter(!(month(datas) == 6 & day(datas) < 20)) %>%
# se for setembro pegar os dias menores do que 20
filter(!(month(datas) == 9 & day(datas) > 20))
Source: local data frame [9,393 x 2]
datas valor
(date) (int)
1 1900-06-20 171
2 1900-06-21 172
3 1900-06-22 173
4 1900-06-23 174
5 1900-06-24 175
6 1900-06-25 176
7 1900-06-26 177
8 1900-06-27 178
9 1900-06-28 179
10 1900-06-29 180
.. ... ...
what you need in this period ? days, weeks, hours, ... ?
– Thiago Friedman
I am working with climate data, I need to rescue the date and the average temperature of this period.
– Rafaela Troian Donatti
maybe these two links can help you: https://biologyforfun.wordpress.com/2014/05/importing-100-years-of-climate-change-into-r/ and https://ropensci.org/blog/2013/08/18/sciordata/
– Thiago Friedman
Thanks, I’ll take a look.
– Rafaela Troian Donatti