Displaying 1 result from an estimated 1 matches for "timeinseconds".
2011 Aug 12
2
Finding an average time spent
...to just seconds:
time.to.seconds <- function(time) {
time <- strsplit(time, ":")[[1]]
return ((as.numeric(time[1]) * 60 * 60) + (as.numeric(time[2]) * 60) +
(as.numeric(time[3])))
}
# I've tried many things to then create a new variable in the dataset
visitors:
visitors$TimeInSeconds <- time.to.seconds(time=c(visitors$Time.Spent))
# Or
visitors$TimeInSeconds <- time.to.seconds(visitors$Time.Spent)
I figure it has something to do with the fact that strsplit() makes a list?
Do I need a loop to go through each variable? I know this is a huge question
but any hints at al...