1

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

Spears
  • 2,102
  • 1
  • 17
  • 27
paolo
  • 33
  • 5
  • 3
    I don't see a definition of `data` in the examples. – Roland Mar 15 '19 at 11:46
  • 2
    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 Mar 15 '19 at 11:47
  • 2
    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 Mar 15 '19 at 11:58
  • @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 Mar 15 '19 at 14:45
  • @Aaron Hayman thank you, that solved it – paolo Mar 15 '19 at 14:47
  • @snair1591 using the name for a variable will seldom cause trouble, since it R can generally tell when a function is being used as a function and will look for a function and the default functions will remain on the search path. I ran into trouble once though with a function that I built after someone loaded a library which had its own `range` function. I had to modify my function to use `base::range` – Aaron Hayman Mar 15 '19 at 15:03

0 Answers0