Greetings,
I have reduced a dataset to 4 variables, all of which were imported as factors.
> head(dat.time)
bedtime bt.sleep waketime wt.wake
1 10:00 P.M. 5:00 A.M.
2 11:00 P.M. 6:30 A.M.
3 10:30 P.M. 7:00 A.M.
4 11:00 P.M. 7:00 A.M.
5 10:00 P.M. 7:30 A.M.
6 10:30 P.M. 7:00 A.M.
> class(dat.time$bedtime)
[1] "labelled" "factor"
> class(dat.time$bt.sleep)
[1] "factor"
> class(dat.time$waketime)
[1] "labelled" "factor"
> class(dat.time$wt.wake)
[1] "factor"
>
I am trying to create 2 new variables
- Sleep - from columns 1 & 2
- Wake - from columns 3 & 4
My goal is to then calculate a third variable
- Time in bed
Which will be the difference of 2 - 1
I have tried several packages including
I tried these but the result input today's date.
dat.time$bedtime2 <- as.character(dat.time$bedtime)
dat.time$bedtime3 <- as.POSIXct(dat.time$bedtime2,
format = '%H:%M')
As an #rstatsnewbie, any help would be greatly appreciated.
Jason