Selecting data frame rows based on partial string match in a column

后端 未结 4 1220
轻奢々
轻奢々 2020-11-22 09:16

I want to select rows from a data frame based on partial match of a string in a column, e.g. column \'x\' contains the string "hsa". Using sqldf -

4条回答
  •  天涯浪人
    2020-11-22 10:06

    LIKE should work in sqlite:

    require(sqldf)
    df <- data.frame(name = c('bob','robert','peter'),id=c(1,2,3))
    sqldf("select * from df where name LIKE '%er%'")
        name id
    1 robert  2
    2  peter  3
    

提交回复
热议问题