I had a data from 1980-2019. My study years were only 2017-2019. I subset the data using this command in R.
amt_789<-amtlich_1984_bis_2019_ana_d[amtlich_1984_bis_2019_ana_d$date >= "2017-01-01" &
amtlich_1984_bis_2019_ana_d$date <= "2019-12-31",]
I want the subset data ie amt_789 to contain all days from 2017-2019 in a time series format. How can i check if there are any missing dates in the amt_789 dataframe?
I have checked and no other questions at stack platform answer my query. I would be glad if someone could help me with the command?
Create a vector of all the dates you want, and see what's missing:
all_dates = seq(
from = as.Date("2017-01-01"),
to = as.Date("2019-12-31"),
by = "day"
)
missing_dates = setdiff(all_dates, amt_789$date)
This assumes your date
column is of class Date
--if it isn't, you should convert it with as.Date()
.
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.