, R "", , .. , lm glm lm.fit glm.fit . cor .Internal(cor(x, y, na.method, FALSE)) . (1) (2) , , :
library(rbenchmark)
x <- y <- runif(1000)
benchmark(cor(x,y),.Internal(cor(x,y,4,FALSE)),replications=10000)
test replications elapsed relative user.self
1 cor(x, y) 10000 1.131 5.004425 1.136
2 .Internal(cor(x, y, 4, FALSE)) 10000 0.226 1.000000 0.224
- : , , ( , , )...
x <- y <- rnorm(5e5)
benchmark(cor(x,y),.Internal(cor(x,y,4,FALSE)),replications=500)
test replications elapsed relative user.self
1 cor(x, y) 500 5.402 1.013889 5.384
2 .Internal(cor(x, y, 4, FALSE)) 500 5.328 1.000000 5.316
source
share