简体   繁体   中英

select even numbered days from data frame

I have a data.frame of a time series of data, I would like to thin the data by only keeping the entries that are measured on every even day number. For example:

set.seed(1)
RandData <- rnorm(100,sd=20)
Locations <- rep(c('England','Wales'),each=50)
today <- Sys.Date()
dseq <- (seq(today, by = "1 days", length = 100))

Date <- as.POSIXct(dseq, format = "%Y-%m-%d")

Final <- data.frame(Loc = Locations,
                    Doy = as.numeric(format(Date,format = "%j")),
                    Temp = RandData)

So, how would I reduce this data frame to only contain every entry that is measured on even numbered days such as Lloc, day, and temp on day 172, day 174 and so on...

关于什么:

Final[Final$Doy%%2==0,]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM