r语言 - sqldf包没有看到我的任何数据文件

时间:2017-06-24 02:33:00

标签: r sqldf

我在我的系统上完成了sqldf软件包的全新安装,但每当我运行任何sql查询时,我都会得到

Error in rsqlite_send_query(conn@ptr, statement) : 
  no such table

无论名称或表格如何

我查看了所有关于设置包装等的指南,并阅读了pdf,由于某种未知的原因,它在我的机器上工作时无法正常工作。

示例代码 - "已复制的堆叠溢出的更正答案应该正常工作"

library(sqldf)

apps.rsd <- structure(list(appid = c(173L, 717L, 996L, 209L, 602L, 255L), 
                           cid = c(4L, 15L, 21L, 5L, 13L, 6L), 
                           price = c(0, 0, 0, 1.99, 0, 0.76), 
                           count = c(411, 411, 210, 18, 921, 22), 
                           sum = c(1226, 1870, 871, 66, 3948, 86), 
                           mean = c(2.98296836982968, 4.54987834549878, 4.14761904761905, 3.66666666666667, 4.28664495114007, 3.90909090909091), 
                           sd = c(1.73897694746568, 0.958668345866094, 1.31370760232218, 1.33373734360862, 1.62114131819336), 
                           rcount = c(3, 3, 3, 5, 5, 7), 
                           rsum = c(7, 0, 0, 13, 0, 19), 
                           rsd = c(2.3094010767585, 2.3094010767585, 2.3094010767585, 2.19089023002066, 2.19089023002066, 2.1380899352994)), 
                      .Names = c("appid", "cid", "price", "count", "sum", "mean", "sd", "rcount", "rsum", "rsd"), 
                      class = c("data.table", "data.frame"), 
                      row.names = c(NA, -6L))  

sqldf("SELECT appid FROM 'apps.rsd' WHERE rcount > 50")**

1 个答案:

答案 0 :(得分:0)

将表格的名称放在引号中&#39; &#39;使它工作,因为表的名称在其中有一个fullstop,这会产生SQL

的问题

> sqldf("SELECT appid FROM 'apps.rsd' WHERE rcount > 50")
Loading required package: tcltk
[1] appid
<0 rows> (or 0-length row.names)
Warning message:
Quoted identifiers should have class SQL, use DBI::SQL() if the caller performs the quoting.


> sqldf("SELECT appid FROM apps.rsd WHERE rcount > 50")
Error in rsqlite_send_query(conn@ptr, statement) : 
  no such table: apps.rsd


> sqldf("SELECT appid FROM 'apps.rsd' WHERE rcount > 0")
  appid
1   173
2   717
3   996
4   209
5   602
6   255