我有一个通过dplyr设置的sql表,如下所示:
num gameday_link stand b_height px pz type
1 1 gid_2016_04_05_houmlb_nyamlb_1 R 5-6 0.194 3.225 B
2 1 gid_2016_04_05_houmlb_nyamlb_1 R 5-6 0.510 1.965 S
3 1 gid_2016_04_05_houmlb_nyamlb_1 R 5-6 -1.367 2.459 B
我想要做的是添加一个名为correct的附加列,它保存名为isCallCorrectV的自定义函数的T或F结果 . isCallCorrectV的参数是表中的列 .
以下是运行中isCallCorrectV的示例:
> isCallCorrectV(c(0.0, 2.5), c(2.5, 0), c("S", "B"), c("6-0", "5-0"), c("R", "L"))
[1] TRUE FALSE
我尝试使用此命令,但我收到错误 .
dplyr::mutate(noswings, correct = isCallCorrectV(px, pz, type, b_height, stand))
Error in sqliteSendQuery(conn, statement) :
error in statement: no such function: ISCALLCORRECTV
1 回答
Per @Gregor 's comments, it isn'可以在sql数据库的dplyr中使用自定义函数 . 只能使用定义here的函数 .
所以我的选择是:
我可以使用dplyr collect命令将数据读入R.