找不到函数“switch_lang”

Posted

技术标签:

【中文标题】找不到函数“switch_lang”【英文标题】:could not find function "switch_lang" 【发布时间】:2019-11-12 08:48:04 【问题描述】:

得到这个错误,有没有人知道是什么触发了它?

#### sc is a spark connection

require(dplyr)
require(tidyr)
require(tibble)
require(sparklyr)
require(ggplot2)
require(scales)
require(DBI)
require(lubridate)


set.seed(.111)

my_df <- data.frame(test_col = sample(letters, 10, replace = FALSE))

my_spark_df <- copy_to(sc, my_df, overwrite = TRUE)

my_spark_df

# Source: spark<my_df> [?? x 1]
# test_col
# <chr>   
# 1 x       
# 2 g       
# 3 i       
# 4 n       
# 5 t       
# 6 e       
# 7 r       
# 8 v       
# 9 l       
# 10 k       


my_spark_df %>% mutate(test_col = toupper(test_col))

# 
# Error in switch_lang(call, inlined = , namespaced = ,
#                      recursive = eval_bare(call,  : could not find function "switch_lang"

这是引用

traceback()

# 
# 19: lang_partial_eval(call, vars, env)
# 18: switch_type(call, `NULL` = NULL, symbol = sym_partial_eval(call, 
#                                                                vars, env), language = lang_partial_eval(call, vars, env), 
#                 logical = , integer = , double = , complex = , string = , 
#                 character = call, formula = 
#                   f_rhs(call) <- partial_eval(f_rhs(call), vars, f_env(call))
#                   if (length(call) == 3) 
#                     f_lhs(call) <- partial_eval(f_lhs(call), vars, f_env(call))
#                   
#                   call
#                 , list = 
#                   if (inherits(call, "lazy_dots")) 
#                     call <- dplyr:::compat_lazy_dots(call, env)
#                   
#                   map(call, partial_eval, vars = vars, env = env)
#                 , abort(glue("Unknown input type: ", class(call))))
# 17: partial_eval(f_rhs(call), vars, f_env(call))
# 16: switch_type(call, `NULL` = NULL, symbol = sym_partial_eval(call, 
#                                                                vars, env), language = lang_partial_eval(call, vars, env), 
#                 logical = , integer = , double = , complex = , string = , 
#                 character = call, formula = 
#                   f_rhs(call) <- partial_eval(f_rhs(call), vars, f_env(call))
#                   if (length(call) == 3) 
#                     f_lhs(call) <- partial_eval(f_lhs(call), vars, f_env(call))
#                   
#                   call
#                 , list = 
#                   if (inherits(call, "lazy_dots")) 
#                     call <- dplyr:::compat_lazy_dots(call, env)
#                   
#                   map(call, partial_eval, vars = vars, env = env)
#                 , abort(glue("Unknown input type: ", class(call))))
# 15: FUN(X[[i]], ...)
# 14: lapply(.x, .f, ...)
# 13: map(call, partial_eval, vars = vars, env = env)
# 12: switch_type(call, `NULL` = NULL, symbol = sym_partial_eval(call, 
#                                                                vars, env), language = lang_partial_eval(call, vars, env), 
#                 logical = , integer = , double = , complex = , string = , 
#                 character = call, formula = 
#                   f_rhs(call) <- partial_eval(f_rhs(call), vars, f_env(call))
#                   if (length(call) == 3) 
#                     f_lhs(call) <- partial_eval(f_lhs(call), vars, f_env(call))
#                   
#                   call
#                 , list = 
#                   if (inherits(call, "lazy_dots")) 
#                     call <- dplyr:::compat_lazy_dots(call, env)
#                   
#                   map(call, partial_eval, vars = vars, env = env)
#                 , abort(glue("Unknown input type: ", class(call))))
# 11: partial_eval(dots, vars = op_vars(.data))
# 10: mutate.tbl_lazy(., test_col = toupper(test_col))
# 9: mutate(., test_col = toupper(test_col))
# 8: function_list[[k]](value)
# 7: withVisible(function_list[[k]](value))
# 6: freduce(value, `_function_list`)
# 5: `_fseq`(`_lhs`)
# 4: eval(quote(`_fseq`(`_lhs`)), env, env)
# 3: eval(quote(`_fseq`(`_lhs`)), env, env)
# 2: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
# 1: my_spark_df %>% mutate(test_col = toupper(test_col))

这里是会话信息

sessionInfo()


# 
# 
# R version 3.4.1 (2017-06-30)
# Platform: x86_64-redhat-linux-gnu (64-bit)
# Running under: Amazon Linux AMI 2018.03
# 
# Matrix products: default
# BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
# 
# locale:
# [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
# [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
# [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
# [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
# [1] lubridate_1.7.4 DBI_1.0.0       scales_1.0.0    ggplot2_3.2.0   sparklyr_1.0.0  tibble_2.1.3   
# [7] tidyr_0.8.3     dplyr_0.8.1    
# 
# loaded via a namespace (and not attached):
# [1] Rcpp_1.0.1       pillar_1.4.2     compiler_3.4.1   dbplyr_1.2.1     r2d3_0.2.3       base64enc_0.1-3 
# [7] tools_3.4.1      zeallot_0.1.0    digest_0.6.15    jsonlite_1.5     gtable_0.3.0     pkgconfig_2.0.2 
# [13] rlang_0.4.0      cli_1.0.0        rstudioapi_0.7   parallel_3.4.1   yaml_2.1.19      stringr_1.3.1   
# [19] withr_2.1.2      httr_1.3.1       vctrs_0.1.0      generics_0.0.2   htmlwidgets_1.3  rprojroot_1.3-2 
# [25] grid_3.4.1       tidyselect_0.2.5 glue_1.3.1       forge_0.2.0      R6_2.4.0         fansi_0.4.0     
# [31] purrr_0.2.5      magrittr_1.5     backports_1.1.2  htmltools_0.3.6  ellipsis_0.1.0   assertthat_0.2.1
# [37] colorspace_1.4-1 config_0.3       utf8_1.1.4       stringi_1.2.3    openssl_1.0.1    lazyeval_0.2.1  
# [43] munsell_0.5.0    crayon_1.3.4    

【问题讨论】:

你加载了哪些包?请在您的代码中包含所有相关的library 调用。 我的印象是 sessionInfo() 输出足够了 好的,所以你在最后隐藏了最重要的信息,需要读者滚动。也许,不是最好的方法... 没有隐藏的意图,我调用了一个不同的文件来安装和加载包,此外,正如我所指出的,我认为人们更喜欢 sessionInfo()。该问题已被编辑以包含加载的库。 是的,事实上看起来dbplyr 确实有问题。这里有一个提交删除了switch_lang 函数:github.com/tidyverse/dbplyr/commit/…。我认为您至少需要版本 v1.3.0 才能进行更改。你有版本v1.2.1 【参考方案1】:

switch_lang() 存档在 rlang 0.4 中。你需要一个previous version。

【讨论】:

您可以尝试重新安装最新的软件包。对我来说是install.packages("dbplyr")

以上是关于找不到函数“switch_lang”的主要内容,如果未能解决你的问题,请参考以下文章

Linux开发,内核代码,找不到内核宏定义,找不到内核函数

Linux开发,内核代码,找不到内核宏定义,找不到内核函数

为啥 DetourFindFunction() 找不到函数的地址?

ios的SDL开发,找不到SDL_Overlay类和SDL_SetVideoMode函数,有替代方案么?

函数一直返回true,找不到错误?

Opengl“找不到当前函数的边界”