Using SQLDF to select specific values ​​from a column

SQLDF newbie here.

I have a data frame that contains about 15,000 rows and 1 column. The data looks like this:

cars
autocar
carsinfo
whatisthat
donnadrive
car
telephone
...

I wanted to use the sqldf package to scroll through a column and select all the values ​​that contain “car” anywhere at their cost. However, the following code generates an error.

> sqldf("SELECT Keyword FROM dat WHERE Keyword="car")
Error: unexpected symbol in "sqldf("SELECT Keyword FROM dat WHERE Keyword="car"

There is no unexpected symbol, so I'm not sure what happened.

So first, I want to know all the meanings containing "car". then I want to know only those values ​​that contain only "car".

Can someone help.

EDIT:

In order, an unexpected symbol appeared, but it gives me only a car, and not everyone that contains a "car".

> sqldf("SELECT Keyword FROM dat WHERE Keyword='car'")
  Keyword
1     car
+3
source share
4

= .

, like % _. % , _ .

- car, . "", "" ..:

sqldf("SELECT Keyword FROM dat WHERE Keyword like '%car%'")

"" "":

sqldf("SELECT Keyword FROM dat WHERE Keyword like 'car_'")
+7

sqldf; SQL- . :

dat <- data.frame(Keyword=c("cars","autocar","carsinfo",
  "whatisthat","donnadrive","car","telephone"))
sqldf("SELECT Keyword FROM dat WHERE Keyword like '%car%'")
#    Keyword
# 1     cars
# 2  autocar
# 3 carsinfo
# 4      car
+3

. grepl (TRUE/FALSE), , . , :

#Using @Joshua dat data.frame
subset(dat, grepl("car", Keyword, ignore.case = TRUE))

   Keyword
1     cars
2  autocar
3 carsinfo
6      car
+2

, @Chase. , grep, grepl:

df <- data.frame(keyword = c("cars", "autocar", "carsinfo", "whatisthat", "donnadrive", "car", "telephone"))
df[grep("car", df$keyword), , drop = FALSE] # or
df[grepl("car", df$keyword), , drop = FALSE]

   keyword
1     cars
2  autocar
3 carsinfo
6      car

, "hsa.." ( )

0

All Articles