【发布时间】:2021-10-15 00:50:22
【问题描述】:
我有一个过大的数据保存为 SQLite 数据库。我需要重新编码某些列的值,但不幸的是我的代码生成了我真的无法调试的错误。这是我正在使用的代码。
library(RSQLite)
library(inborutils)
library(dplyr)
library(dbplyr)
db <- dbConnect(SQLite(), dbname = "ukbb.sqlite")
dbListTables(db)
bd <- tbl(db, "Uk_Bb")
bd %>%
mutate(f.19.0.0 = recode(bd, f.19.0.0, '1' = "Direct entry",
'2' = "Manual entry",
'3' = "Not performed",
'6' = "Not performed - equipment failure",
'7' = "Not performed - other reason",
.default = NULL))
f.19.0.0 是表中的一列,具有以下值:-
bd %>% select(f.19.0.0)
# Source: lazy query [?? x 1]
# Database: sqlite 3.36.0 [C:\Users\*****\Downloads\UkBB\ukbb.sqlite]
f.19.0.0
<dbl>
1 1
2 1
3 1
4 NA
5 1
6 NA
7 NA
8 1
9 1
10 1
# ... with more rows
我得到的错误是
UseMethod("escape") 中的错误: 没有适用于“escape”的方法应用于类“c('tbl_SQLiteConnection','tbl_dbi','tbl_sql','tbl_lazy','tbl')”的对象 另外:警告信息: SQL 重新编码忽略命名参数
非常感谢任何解决此问题的帮助/解释!
【问题讨论】: