Error: No Such Column using SQLDF

前端 未结 3 1978
时光说笑
时光说笑 2021-01-05 22:19

Below are the scripts

> library(sqldf)
> turnover = read.csv(\"turnover.csv\")
> names(turnover)
[1] \"Report.Date\"       \"PersID\"            \"S         


        
3条回答
  •  不知归路
    2021-01-05 22:52

    sqldf(...) does not like . (period) in column names, so you need to change it to something else. Try this:

    library(sqldf)
    turnover = read.csv("turnover.csv")
    colnames(turnover) <- gsub("\\.","_",colnames(turnover))
    turnover_hiredate = sqldf("select Status, Current_Hire_Date from turnover")
    

    The reason is that the period is used in SQL to indicate a table column, e.g. turnover.Status.

提交回复
热议问题