I have the sample code below:
f <- function(x) {
v = 0
start = Sys.time()
for (i in 1:x) {
v = v + 1
}
end = Sys.time()
print(end-start)
print(paste0("f() took: ", end-start))
}
f(10)
The 2 outputs are:
Time difference of 5.960464e-06 secs
"f() took: 5.96046447753906e-06"
My question is why when used with paste0
the output is different.
Edit:
If one wish to get the units of time do the following:
print(paste0("f() took: ", end-start, " ", units(end-start)))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…