rapache-sparktidyversedatabricksazure-databricks

What is the meaning of : Warning in do.call(.f, args, envir = .env) : "what" must be a function or character string


This is the exact message:

Warning in do.call(.f, args, envir = .env) :
  'what' must be a function or character string

Working in an Azure Databricks environment for data processing using R, spark and the tidyverse. This message appears even when running an empty command cell.

# library(sparklyr)
# library(lubridate)
# library(dplyr)
# library(purrr)
# library(httr)
# library(jsonlite)
# library(tidyr)
# library(arrow)
# library(stringr)
# library(DBI)
# library("readxl")

and I use

# if(!require(*library*)){
#   install.packages(*"library"*)
# }

Is this something I should worry about with this warning or that I should be checking? I don't understand the warning and could not find the right documentation on google.


Solution

  • Looks to me if some genius package maintainer has masked (~overwritten) something important or uses a (function's) name rather than a character string in do.call.

    You can reproduce the issue like so.

    do.call(rbind, list())  ## using the name works as expected
    # NULL
    

    Now let's mask rbind

    rbind <- 1
    do.call(rbind, list())  ## using the name fails
    # Error in do.call(rbind, list()) : 
    #   'what' must be a function or character string
    

    Voilá.

    It's safer to use the character string here, which won't fail.

    do.call('rbind', list())
    # NULL
    
    rm(rbind)  ## unmask `rbind`.
    

    The solution is tricky, since you're loading a ton of libraries. You could do the following though:

    1. Close R-session, if working with RStudio, uncheck Tools > Global Options > General > Restore .RData (maybe the uncheck already solves the issue!)
    2. Check Renviron.site and Renviron.site files for unusual entries (can be found in the /etc/R/ folder on Linux), alternatively maybe start a R -vanilla session
    3. Start a fresh R session
    4. Load each library one by one until the error occurs