0
votes

I am building my R package. However, when compiling it using CMD, the build fails because of the examples. I show you my function header for clarity:

#' @param data a dataframe containing the data to be modelled  
#' @param string identifying the location  
#' @param parameters a dataframe where the parameters for all the functions   
needed are saved  
#' @param period string saying whether the horizon to model  
#'  
#' @import dplyr  
#'  
#' @return list  
#' @export  
#' @examples   
Runner(data=data,Site="ABC",parameters=parameter,period="6-month")

Runner <- function(data, 
Site="ABC",parameters=parameter,period="6-month"){

  if(!is.data.frame(data)){
    stop("data must be a data.frame")
  }

and so on. I have only included the first test because it seems to be the following error message seems to refer to it.

When compiling, I get the following error message:

Running examples in ‘SiteRunner.R’ failed The error most likely occurred in:

base::assign(".ptime", proc.time(), pos = "CheckExEnv")

Name: Runner

Title: Feature engineer and Model the chosen location

Aliases: Runner

** Examples

Runner(data=data,Site="ABC",parameters=parameter,period="6-month") Error in Runner(data = data, Site = "ABC", parameters = parameter, : data must be a data.frame Execution halted

Any help? I see it often is the case that @export is missing, but it is not my case. Thank you very much for your help

I don't see a definition of data in the examples. - Roland
unless data is an object exported in your package, then it will be interpreted as a function, which will cause your example to fail. You should define data in your example - Aaron Hayman
To add to the comment of Aaron, it's always better not to name a variable with the same name as R's functions. This will always creates further complications than necessary. - snair.stack
@snair1591 I actually find these complications extremely rare, not an "always" thing. I would wager that 99.9% of the questions on SO that use data or df as data frame names created no complications. Variables need to be defined, whether or not the name is being re-used. - Gregor Thomas
@Aaron Hayman thank you, that solved it - paolo