Skip to content
Prev 311609 / 398502 Next

Data Extraction - benchmark()

Hi Berend,

I see you are one of the contributors to the rbecnhmark package. 

I am sorry that I am bothering you again.  I have tried to run your  code (slightly tweaked)  involving the benchmark function, and I am getting the following error message. What am I doing wrong?


Error in benchmark(d1 <- s1(df), d2 <- s2(df), d3 <- s3(df), d4 <- s4(df),  : 
  could not find function "s1"
Error: unexpected ',' in "identical (d1,d2),"
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rbenchmark_1.0.0

loaded via a namespace (and not attached):
[1] tools_2.15.1



I would appreciate receiving your help if your time permits ..


Thanks and regards,

Pradip Muhuri

#####  Berend's code extended
N <- 100000
set.seed(13)
df<-data.frame(matrix(sample(c(1:10,NA),N, replace=TRUE),ncol=50))
s1 <- df[complete.cases(df),]
s2 <- na.omit(df)
s3 <- df[apply(df, 1, function(x)all(!is.na(x))), ]
s4 <- function(df) {df[apply(df, 1, function(x)all(!is.na(x))),][,1:ncol(df)]}
s5 <- function(df) {df[!is.na(rowSums(df)),][1:ncol(df)]}
s6 <- function(df) {df[complete.cases(df),][1:ncol(df)]}

require(rbenchmark)
 
benchmark( d1 <- s1(df), d2 <- s2(df), d3 <- s3(df), d4 <- s4(df), d5 <- s5(df), d6 <- s6(df),
                    columns=c("test","elapsed", "relative", "replications") )

identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), identical (d1,d6)