我有一个带有以下因子列的 Spark 数据框 tbl_pred:
**Value**
13,3
11
5,3
我喜欢将这些“字符串”转换为数值。我可以使用 as.numeric 函数,但这不起作用,因为我的分隔符是逗号。
tbl_pred <- tbl_bun %>% mutate(value = as.numeric(value))
通常我会使用 sub 函数将 , 替换为 . 但此功能不适用于我的 Spark 数据框对象。
Error: org.apache.spark.sql.AnalysisException: Undefined function: 'SUB'. This function is neither a registered temporary function nor a permanent function registered in the database 'xxx'.; line 1 pos 417
有人有将值转换为数字的解决方案吗?
提前致谢,
J。