sql - R中sqldf中SQL语句的问题?
问题描述
我遇到了一些与 sqldf 有关的非常紧张的问题。
例子:
sqldf("select REGN, NII from dataframe ")
即使使用非常简单的查询,此函数也会返回以下错误:
Ошибка в result_create(conn@ptr, statement) :too many SQL variables
这是我使用的数据样本dput(head(dataframe))
structure(list(REGN = c(1L, 21L, 23L, 52L, 53L, 55L), NII = c(5136380L,
30322L, 291812L, 92561L, 120618L, 140652L)), row.names = c(NA,
6L), class = "data.frame")
编辑:但是当我对这个数据框运行类似的代码时:
structure(list(date_start = c("2008-04-01", "2016-04-01", "2019-04-01",
"2020-04-01", "2021-04-01"), date_end = c("2016-04-01", "2019-04-01",
"2020-04-01", "2021-04-01", "3000-01-01")), row.names = c(NA,
-5L), class = c("tbl_df", "tbl", "data.frame"))
一切正常。
结果sessioninfo()
:
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=Russian_Russia.1251
[2] LC_CTYPE=Russian_Russia.1251
[3] LC_MONETARY=Russian_Russia.1251
[4] LC_NUMERIC=C
[5] LC_TIME=Russian_Russia.1251
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] openxlsx_4.1.0 sqldf_0.4-11
[3] RSQLite_2.1.1 gsubfn_0.7
[5] proto_1.0.0 stringr_1.4.0
[7] reshape2_1.4.3 dplyr_0.8.0.1
[9] readxl_1.3.1 foreign_0.8-71
[11] RevoUtils_11.0.3 RevoUtilsMath_11.0.0
loaded via a namespace (and not attached):
[1] zip_2.0.1 Rcpp_1.0.1 cellranger_1.1.0
[4] pillar_1.3.1 compiler_3.5.3 plyr_1.8.4
[7] tools_3.5.3 RPostgres_1.1.1 digest_0.6.18
[10] bit_1.1-14 memoise_1.1.0 tibble_2.1.1
[13] pkgconfig_2.0.2 rlang_0.3.4 DBI_1.0.0
[16] rstudioapi_0.10 hms_0.4.2 bit64_0.9-7
[19] tidyselect_0.2.5 glue_1.3.1 R6_2.3.0
[22] tcltk_3.5.3 purrr_0.3.2 blob_1.1.1
[25] magrittr_1.5 assertthat_0.2.1 stringi_1.4.3
[28] chron_2.3-53 crayon_1.3.4
结果ls()
:
[1] "complete" "con"
[3] "dateAn" "df"
[5] "df_3" "df_4"
[7] "df_inval" "df_inval_q"
[9] "df_itogo" "df_itogo_q"
[11] "df_itogo2" "df_rub"
[13] "df_rub_q" "df1"
[15] "f102_dates" "f102_maket"
[17] "f102_maket_1" "f102_maket_long"
[19] "f102_maket_long_symb" "i"
[21] "j" "k"
[23] "levelFunc" "listdbf"
[25] "m" "MainPath"
[27] "query_compos" "split"
[29] "subtract"
怎么了?
解决方案
推荐阅读
- flutter - Flutter Build APK:失败 - 任务“:keyboard_visibility:verifyReleaseResources”执行失败
- javascript - 将字符串附加到 DOM 会转换为 JSON
- c - Write() 函数理解十六进制值
- emacs - 导出到 Latex 时在 org-mode 脚注中包含引号
- stripe-payments - 如何在条带 CLI 中传递 --headers?
- sql - 动态枢轴排序
- python - 在 macOS Catalina 上使用“使用进程 ID 附加”在 VSCodium 中调试 Python 超时
- excel - 使用 MacOs Excel (ODBC) 中的参数查询 SnowFlake?
- oracle - Oracle SQL:遇到符号“BEGIN”
- javascript - 使用 intersectionObserver 检查元素是否可见