0

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

  • 1
    I tried to run your code. It works fine to me. Try to clean your environment and restart R (Ctrl + Shift + F10). Also add the libraries that you use in your example: `library(gratis);library(tsibble);library(purrr);library(forecast)` – Edo Sep 04 '20 at 14:03
  • Thank you for trying to help. I did restart or clean environment. However, that sample in the **R package vignette** file still cannot be knit out. –  Sep 04 '20 at 14:11
  • 1
    have you rebuilt your package correctly before trying to knit your vignette? – Edo Sep 04 '20 at 14:16
  • That's sounds like a very good idea to try. How can I rebuild the package? using ```renv::rebuild("package_name", recursive = TRUE)```? –  Sep 04 '20 at 14:23
  • 1
    you can use rstudio's shortcuts: Ctrl+Shift+D [to recreate the documentation] and Ctrl+Shift+B [to rebuild the package] – Edo Sep 04 '20 at 14:24
  • 1
    Those shortcuts work only if you are in the project of your package, which I assumed you were. – Edo Sep 04 '20 at 14:29
  • I tried location on laptop with ```"C:/Users/mreal/Documents/GitHub/package_name/R"``` or only ```"C:/Users/mreal/Documents/GitHub/package_name"```. And then click ```Ctrl+Shift+B``` in RStudio. (Ctrl +Shift+B does not show anything)Then knit **vignette** again. It's not work. Am I did some step wrong? –  Sep 04 '20 at 14:36
  • 1
    try to run these commands: `devtools::document("C:/Users/mreal/Documents/GitHub/package_name"); devtools::install("C:/Users/mreal/Documents/GitHub/package_name")`. `package_name` should be a folder where all the necessary elements are present (`DESCRIPTION` file and `R` folder) – Edo Sep 04 '20 at 14:51
  • You are very genius! Would you mind add your answer to answer part, so that I can accept it. Thank you so much for your helping. :) –  Sep 04 '20 at 15:09

1 Answers1

0

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
Edo
  • 7,567
  • 2
  • 9
  • 19