I\'ve imported a csv-file to R using RStudio where I am trying to plot points per game against minutes per game. However the minutes per game is in the format mm:ss and I\'m
Some tuning of first solution:
minPerGame <- paste(sample(1:89,100000,T),sample(0:59,100000,T),sep=":")
f1 <- function(){
sapply(strsplit(minPerGame,":"),
function(x) {
x <- as.numeric(x)
x[1]+x[2]/60
}
)
}
#
f2<- function(){
w <- matrix(c(1,1/60),ncol=1)
as.vector(matrix(as.numeric(unlist(strsplit(minPerGame,":"))),ncol=2,byrow=TRUE)%*%w)
}
system.time(f1())
system.time(f2())
system.time(f1()) user system elapsed 0.88 0.00 0.86
system.time(f2()) user system elapsed 0.25 0.00 0.27