2
Hello !
How do I select a line data.frame
according to some dates ?
ex: select the data from coluna 2
for the dates 2016/12/15, 2016/12/25, 2017/01/08, 2018/01/01.
2
Hello !
How do I select a line data.frame
according to some dates ?
ex: select the data from coluna 2
for the dates 2016/12/15, 2016/12/25, 2017/01/08, 2018/01/01.
4
First I create a data.frame
two-column, coluna1
(containing random values) and coluna2
containing some dates.
dados <- data.frame(coluna1 = rnorm(10), coluna2 = as.Date(c("2016/12/15", "2016/12/20", "2016/12/25", "2016/12/30", "2017/01/05", "2017/01/08", 2018/01/01", "2018/12/31", "2017/11/25", "2017/11/30")))
I separate the dates of interest:
datas <- as.Date(c("2016/12/15", "2016/12/25", "2017/01/08", "2018/01/01"))
I use the command %in%
to select the dates of coluna2
containing the dates of interest
dados$coluna1[dados$coluna2%in%datas]
Browser other questions tagged r rstudio
You are not signed in. Login or sign up in order to post.