Suppose I have the following data:
foo <- data.frame(Company = c("company1", "foo", "test", "food"), Metric = rnorm(4, 10))
> foo
Company Metric
1 company1 10.539970
2 foo 9.487823
3 test 9.663994
4 food 9.499327
Why does the following code return 0 results (instead of the second and fourth rows)?
library(dplyr)
library(data.table)
foo %>% dplyr::filter(Company %like% "%foo%")
I'm trying to use the SQL-equivalent wildcard filter on a particular input string to dplyr::filter
, using the %like%
operator from the data.table
package.
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…