Search code examples
rpackagecran

After finish creating R function; proof the correction by using this function with sample values in vignette. The error said "unused argument (...)"


I am trying to update R package version on CRAN by updating function. I met a wired situation where, after the function be created. And the sample is in the vignette file

The sample code I used is

my_function(seasonal.periods = c(7, 365), n = 800, nComp = 2, output_format = "tsibble")

The outcome can appears as a lovely tsibble format within R. However, the vignette document contain this sample cannot be knit out! And the error said

unused argument (output_format=tsibble) enter image description here

But I already defined this parameter within the function. And it can give a result within R (as picture shown below). I wonder if that is because I did not define this parameter properly? Anyone know how to fix that?

I wonder is that because vignette cannot be knit out due to new function does not upload to cran? But it should not be?

enter image description here


Solution

  • As we understood in our dialog between the comments, the problem was related to the fact that you didn't re-build your package before knitting your vignettes. Therefore, the vignettes were still loading the package with the old function that didn't have that extra argument.

    Thus, to build (and document) your package from R console run these commands:

    devtools::document("path/to/your/package/folder/") # to create the documentation
    devtools::install("path/to/your/package/folder/")  # to build the package
    

    The path has to lead to the folder where the DESCRIPTION file and the R folder are present. Those are the only absolutely necessary pieces of a minimal package.

    Or as RStudio shortcuts (only when you are in the project):

    Ctrl + Shift + D
    Ctrl + Shift + B