How about this -
library(dplyr)
data(iris)
filter(iris, grepl("nica",Species))
EDIT: - %like% data.table()
library(dplyr)
data(iris)
Iris <- iris[
rep(seq_len(nrow(iris)),each=5000),
]
dim(Iris)
[1] 750000 5
library(microbenchmark)
library(data.table)
Dt <- data.table(Iris)
setkeyv(Dt,cols="Species")
foo <- function(){
subI <- filter(Iris, grepl("nica",Species))
}
foo2 <- function(){
subI <- Dt[Species %like% "nica"]
}
foo3 <- function(){
subI <- filter(Iris, Species %like% "nica")
}
Res <- microbenchmark(
foo(),foo2(),foo3(),
times=100L)
> Res
Unit: milliseconds
expr min lq median uq max neval
foo() 114.31080 122.12303 131.15523 136.33254 214.0405 100
foo2() 23.00508 30.33685 39.77843 41.49121 129.9125 100
foo3() 18.84933 22.47958 29.39228 35.96649 114.4389 100