简体   繁体   English

R中的sqldf生成错误

[英]sqldf in R generating an Error

I am trying to merge two tables in R by using the following command: 我正在尝试使用以下命令在R中合并两个表:

library(gsubfn)
library(proto)
library(RSQLite)
library(sqldf)
sqldf("SELECT Gender, Pmu.try.Sat.Ltd, Online.Campus.Student, Residency,
           tutorial_avg_score
           FROM A JOIN B
           USING(userID)")

The system generates the following error: 系统产生以下错误:

Error in result_create(conn@ptr, statement) : near ".": syntax error

Could anyone kindly advise what could be the issue here? 谁能建议这里的问题是什么? The column names are bit weird but they are very similar to the actual names that I have in the provided data. 列名有些奇怪,但是它们与我在提供的数据中使用的实际名称非常相似。 I had a look at the following question: Error in rsqlite_send_query(conn@ptr, statement) : near "(": syntax error But it does not help me either. 我看了以下问题: rsqlite_send_query(conn @ ptr,statement)中的错误:“(”附近:语法错误,但它也无济于事。

Looking for your kind advice on this! 在此寻找您的好建议!

The following solutions resolved the error that I had been facing: 以下解决方案解决了我一直面临的错误:

sqldf('SELECT Gender, "Pmu.try.Sat.Ltd", "Online.Campus.Student", Residency,
       tutorial_avg_score
       FROM A JOIN B
       USING(userID)')

OR 要么

sqldf('SELECT Gender, `Pmu.try.Sat.Ltd`, `Online.Campus.Student`, Residency,
       tutorial_avg_score
       FROM A JOIN B
       USING(userID)')

OR 要么

sqldf('SELECT Gender, [Pmu.try.Sat.Ltd], [Online.Campus.Student], Residency,
       tutorial_avg_score
       FROM A JOIN B
       USING(userID)')

Many thanks @G. 非常感谢@G。 Grothendieck for your kind comments! Grothendieck提出您的意见!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM