3
I need to generate a new table only with the hourly rounds.
For example, from this table:
This data would remain:
How best to solve this problem in R?
3
I need to generate a new table only with the hourly rounds.
For example, from this table:
This data would remain:
How best to solve this problem in R?
2
One of the ways I see it is to check if the minute is equal to 0, so it would be an exact time.
You can use the lubridate package to make this easier.
##install.packages("lubridate") #É necessário instalar o pacote se você ainda não o tem instalado.
library(lubridate)
library(dplyr) #Vou usar o dplyr para filtar os dados pois também acho mais fáicl, porém, não é estritamente necessário.
## Criando dados fakes
data <- c("01/01/2010 00:50", "01/01/2010 01:00", "01/01/2010 01:20", "01/01/2010 02:00")
chuva <- c(0,0.2,0,0.4)
## Criando o df, e utilizando o lubridate dmy_hm, para identificar e converter os dados das datas para o formato POSIXct
df <- data.frame(data = dmy_hm(data), chuva = as.numeric(chuva))
##Filtrando os dados onde os minutos são igual a zero
dplyr::filter(df, minute(data) == 0)
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.
thanks for the suggestion. Excellent. I also found another possibility, which I share:
#selecionando apenas horários terminados em 00

df1<- df[grep(":00",df$data),]
– João dos Reis