# NOT RUN {
# throw an error? or assign type according to first argument?
c(as.icd9("E998"), as.icd10("A10"))
# benchmark subsetting to justify using .subset2 (5% faster)
library(microbenchmark)
j <- list(as.icd9cm("E990"), as.icd9cm("10010"))
k <- list(rep(as.icd9cm("E990"), times = 500))
microbenchmark(j[[1]], .subset2(j, 1),
k[[1]], .subset2(k, 1),
times = 1e6)
# logical list to vector
a <- list(T,T)
microbenchmark(as.logical(a), c(a, recursive = TRUE), times = 1e6)
# c(..., recursive = TRUE) vs unlist
l = list(c("100", "440", "999"), c("123", "234"))
microbenchmark::microbenchmark(c(l, recursive = TRUE),
c(unlist(l)),
times = 1e6)
stopifnot(identical(c(l, recursive = TRUE), c(unlist(l))))
# }
Run the code above in your browser using DataLab