create column by date

i want to create a data.frame with 4 columns: date, hour, site, pm25.

the date column has to contain 24 values per day that correspond to the 24 hours that a day has and do it for the 30 days that a month contains

the hour column has to go from 0 to 23

column pm25 has to contain NA

Would something liek this work for you?

Dates <- seq.Date(as.Date("2020-01-01"), as.Date("2020-01-30"), by = "day")
DF <- data.frame(Date = rep(Dates, each = 24), Hour = rep(1:24, 30), pm25 = NA)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.