I have a time series of surface contacts (in df1
) made by a person, as well as the temperature in the room (measured every few seconds and stored in df2
). I'd like to plot temperature
over Dev.Date.Time
and below the y-axis (or in a facet plot), the Surface
they touched with respect to Dev.Date.Time
. The problem I have is that temperature is recorded every ten seconds whereas the movements happen more often.
head(df1)
ActivityID CareType HCWType Orientation Surface Date Time Dev.Date.Time SurfaceCategories
1 01 IV RN01 leftFacing AlcOutside 2019-08-03 11:08:01 2019-08-03 11:08:01 HygieneArea
2 01 IV RN01 leftFacing In 2019-08-03 11:08:12 2019-08-03 11:08:12 In
3 01 IV RN01 leftFacing Door 2019-08-03 11:08:12 2019-08-03 11:08:12 FarPatient
4 01 IV RN01 leftFacing Door 2019-08-03 11:08:18 2019-08-03 11:08:18 FarPatient
5 01 IV RN01 leftFacing Other 2019-08-03 11:08:22 2019-08-03 11:08:22 FarPatient
6 01 IV RN01 leftFacing Table 2019-08-03 11:10:26 2019-08-03 11:10:26 NearPatient
df2<-data.frame(sample(32:35,100,replace=T),Dev.Date.Time=seq(
from=as.POSIXct("2012-1-1 0","%Y-%m-%d %H", tz="UTC"),
to=as.POSIXct("2012-1-3 23", "%Y-%m-%d %H", tz="UTC"),
by="10 seconds")
)
I can plot the temperature but can't work out how to plot a string of characters over time. Any thoughts are much appreciated!
ggplot(df, aes(x=Dev.Date.Time, y=Temperature)) +
geom_line() +
geom_text()
EDIT:
using:
ggplot(df2, aes(x=Dev.Date.Time, y=Temperature)) +
geom_line() +
geom_text(data=df1, aes(label=Surface))