在运行R数据帧的dplyr中,它很容易运行
df <- df %>%
mutate(income_topcoded = ifelse(income > topcode, income, topcode)
Run Code Online (Sandbox Code Playgroud)
我现在正在使用大型SQL数据库,使用dplyr将命令发送到SQL服务器.当我运行相同的命令时,我会回来
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not Retrieve the result : ERROR:
function ifelse (boolean, numeric, numeric) does not exist
HINT: No function matches the given name and argument types. You may need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)
你会如何建议实施ifelse()声明?我对PivotalR中的东西很好(这似乎支持ifelse(),但我不知道如何将它与dplyr集成,并且在SO上找不到任何示例),我可以在线使用的一些SQL语法在这里,或者dplyr的一些我不知道的特征.
(我有同样的问题,我想grepl()用作in-db操作,但我不知道该怎么做.)
我想做一些我认为非常简单的操作 - 将每个人的数字列添加到具有(可能)重复名称列表的数据集中.我认为我很亲密.此代码查看名称的数据集,进行成对比较,并附加列是否存在可能的匹配.现在我只想更进一步 - 而不是删除重复项,我想提出一个唯一的标识符.
彼得
例:
彼得
彼得
彼得
康纳
马特
会成为
例:
彼得 - 1
彼得 - 1
彼得 - 1
康纳 - 2
马特 - 3
library(RecordLinkage)
data(RLdata10000)
rpairs <- compare.dedup(RLdata10000, blockfld = 5)
p=epiWeights(rpairs)
classify <- epiClassify(p,0.7)
summary(classify)
match <- classify$prediction
results <- cbind(classify$pairs,match)
Run Code Online (Sandbox Code Playgroud)