Hello,
How can I join two datasets using a similar minute of datetime column?
So, I want to add temp from temp.data to df using the same minute.
1st value of temp will be the 1st row in df and the second value will be in the last row of df.
y=as.POSIXct("1976-09-03 23:00:00")
y=as.data.frame(y)
colnames(y)=c("datetime")
(df=y%>%
add_row(datetime = as_datetime(y$datetime)+minutes(15)) %>%
add_row(datetime = as_datetime(y$datetime)+minutes(30)) %>%
add_row(datetime = as_datetime(y$datetime)+minutes(45)))
(temp.data <- data.frame(
datetime=as.POSIXct(c("1977-01-06 19:00:00","1977-01-06 19:45:00")),
temp=c(0,2.54)))
Expected output:
(df <- data.frame(
datetime=as.POSIXct(c("1976-09-04 04:00:00","1976-09-04 04:15:00",
"1976-09-04 04:30:00","1976-09-04 04:45:00")),
temp=c(0,NA,NA,2.54)))