gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 06:39:19 26 4
gpt4 key购买 nike

我已经在我的系统上全新安装了 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")**

最佳答案

将表名放在引号 ' ' 中使其有效,因为表名中有一个句号,这会导致 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

关于r 语言 - sqldf 包看不到我的任何数据文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44732187/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com