Using read.csv.sql to select multiple values from a single column

后端 未结 2 1714
闹比i
闹比i 2020-12-18 14:43

I am using read.csv.sql from the package sqldf to try and read in a subset of rows, where the subset selects from multiple values - these values ar

2条回答
  •  Happy的楠姐
    2020-12-18 15:33

    1) fn$ Substitution can be done with fn$ of gsubfn (which is automatically pulled in by sqldf). See the fn$ examples on the sqldf home page. In this case we have:

    fn$read.csv.sql("mtcars.csv", 
      sql = "select * from file where carb in ( `toString(cc)` )")
    

    2) join Another approach would be to create a data.frame of the carb values desired and perform a join with it:

    Carbs <- data.frame(carb = cc)
    read.csv.sql("mtcars.csv", sql = "select * from Carbs join file using (carb)")
    

提交回复
热议问题