3 ms·
A minor R tip: if you're trying to filter on substrings in dplyr, using grepl() is faster and does not require loading an extra package. That said, this is a g
by minimaxir 11y ago
A minor R tip: if you're trying to filter on substrings in dplyr, using grepl() is faster and does not require loading an extra package.
That said, this is a great, clear writeup, and I wasn't aware R had dendrogram capabilities natively. I'll have to spend more time looking into Igraph too.
- hadley 11y agoI find that surprising. Do you have benchmarks?
- minimaxir 11y agoHuh. Turns out I'm wrong. I ran benchmarking on a 1.8M row dataset of SF crime data w/ 100 replications. Running grepl() via: benchmark(df %>% sample_frac() %>% filter(grepl("ARREST", Resolution))) completed in 257.58 seconds. Running str_detect() via: benchmark(df %>% sample_frac() %>% filter(str_detect(Resolution, "ARREST"))) completed in 248.917 seconds. Overall, str_detect() is faster by 3%. The stringr packages has more surprises than I thought!