Created
August 30, 2013 11:02
-
-
Save andilabs/6388734 to your computer and use it in GitHub Desktop.
run R function on certain columns of data frame and then paste the result to the whole data frame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time_spent <- function(from,to) { | |
op <- options(digits.secs = 3) | |
x<-as.numeric((strptime(to, "%Y-%m-%d %H:%M:%OS")-strptime(from, "%Y-%m-%d %H:%M:%OS")),units="secs") | |
data.frame(time_spent=x) | |
} | |
dane_evaluations<-data.frame(dane_evaluations,time_spent=apply(dane_evaluations[,c('documentevaluation_start','documentevaluation_end')],1,function(x) time_spent(x[1], x[2]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment