I'm extremely new to R, and I am using it to analyze a massive data set. Currently my variable B4S1 looks like this (e.g., 10:30, 11:00, 9:45), and I need it to look like this (e.g., 10.5, 11, 9.45). I tried really hard to figure out how to accomplish this, but I don't really understand what is going in the strptime function. Here is what I have...
SleepTime <- (usedata$B4S1)
SleepTime <- as.character(SleepTime)
sapply(strsplit(SleepTime,":"),
function(x) {
x <- as.numeric(x)
x[1]+x[2]/60
}
)
If there are obvious mistakes it would be extremely helpful if you could point them out and tell me where I'm going wrong. Being new at this, I don't fully have a grasp on what I'm doing. Thanks a bunch! :)