How to Document a Function in Your R Package

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024

Комментарии • 23

  • @oseifrancis9957
    @oseifrancis9957 Год назад +1

    Thank you very much for this tutorial. Very usefull

  • @davidfreedman1552
    @davidfreedman1552 2 года назад +1

    Thanks. Very helpful

  • @farnooshsheikhi
    @farnooshsheikhi 9 месяцев назад +1

    Hi this is really helpful, I was able to follow everything but when documenting the functions I got an error on "sew" in package knir . the man file wasn't created. I have 3 functions in one script

    • @StatistikinDD
      @StatistikinDD  9 месяцев назад

      Can you post the full error message? At what exact moment does it appear?

  • @nickportugal95
    @nickportugal95 2 года назад +1

    it's a good tutorial guys!

  • @fmri4301
    @fmri4301 2 года назад +1

    Do you know how to best convert an existing project into a project? Is there some usethis chain that helps?

    • @StatistikinDD
      @StatistikinDD  2 года назад

      You mean from project to package? I'd create a new package in a new folder and import the R scripts. I'd feel safer to keep the original project protected "as-is". When you're happy with the package, you still have enough time to delete the old project, if needed. Some steps will have to be manual, like filling in the documentation.
      Note that you can create a package from a markdown document. I haven't tried that out yet, but I know it was recommended at thinkr, a place of very able R programmers.
      rtask.thinkr.fr/fusen-create-a-package-from-a-single-rmarkdown-file/

  • @shaimasoltane8445
    @shaimasoltane8445 2 года назад

    ❤❤❤❤❤❤👌👌👌👌👌👌 thank you

  • @huiqiao5251
    @huiqiao5251 11 месяцев назад +1

    Thank you so much for loading the videos, they have been super helpful! I tried Build -> More -> Load All and got this error message. The folder did have the processx and processx.rdb files, so I'm not sure what the error means. Could you please advise? Error in gzfile(file, "rb") : cannot open the connection
    In addition: Warning message:
    In gzfile(file, "rb") :
    cannot open compressed file '\\mypackages/processx/R/processx.rdx', probable reason 'No such file or directory'
    Error: unable to load R code in package ‘processx’meaasge

    • @StatistikinDD
      @StatistikinDD  10 месяцев назад

      Hi,
      I'm on holidays, just a quick idea: maybe an invalid file path? I think I got similar problems when my file path contained spaces.

  • @lahaale5840
    @lahaale5840 2 года назад +1

    it's nice but why do not you build upon the last project and create a project for each tutorial?

    • @StatistikinDD
      @StatistikinDD  2 года назад

      Thanks for your feedback! No deep reason, I just had self-contained videos in mind.

  • @olofjosefsson4424
    @olofjosefsson4424 2 года назад +1

    Hi! How do you write the same type of documentation but for the whole package instead?

    • @StatistikinDD
      @StatistikinDD  2 года назад +1

      Good question! I plan to do a video on that as well. My preferred way would be vignettes. There can be one or several. The dplyr and data.table packages are good examples, see help(package = "dplyr") or help(package = "data.table") and click on the link "User guides, package vignettes and other documentation".
      Vignettes are R Markdown documents, but with a special Yaml header. To get startet, you can use the usethis package (which is loaded alongside devtools): usethis::use_vignette("Name of vignette"). This sets up the basic infrastructure and a skeleton of the vignette, which you can fill in. (It works only inside an RStudio project of type R Package.)
      Note that vignettes are not installed by default when you use "Install and Restart" from the Build tab. You can install from github, if you host your package there, and set the build_vignettes parameter to TRUE. Or use Build - More - Build Source Package, then use Packages - Install - from Package Archive - and browse to the source package (file type .tar.gz).

    • @StatistikinDD
      @StatistikinDD  2 года назад +1

      The video about how to include a vignette in your R package is here:
      ruclips.net/video/3N0klPMNyLY/видео.html

  • @shaimasoltane8445
    @shaimasoltane8445 2 года назад +1

    How can i published my package for all users R. Thanks again.

    • @StatistikinDD
      @StatistikinDD  2 года назад

      The easier way is on github. Installation via remotes::install_github("yourgithubusername/package").
      There are similar services such as gitlab or bitbucket.
      Harder way is on CRAN. Takes patience and time.
      r-pkgs.org/release.html
      cran.r-project.org/doc/manuals/r-release/R-exts.html

  • @user-mh2pu1pe2n
    @user-mh2pu1pe2n Год назад +1

    Thanks this is great! Would you know what the problem is with Error in .get_package_metadata(pkgdir) :
    Files 'DESCRIPTION' and 'DESCRIPTION.in' are missing

    • @StatistikinDD
      @StatistikinDD  Год назад

      Do you have a DESCRIPTION text file at the top level of the package? Did you create the package using RStudio - New Project - Package?

    • @user-mh2pu1pe2n
      @user-mh2pu1pe2n Год назад

      @@StatistikinDD Thanks for your prompt reply! yes i do have a DESCRIPTION text file at the top level and I am creating the package using RStudio - New Project - Package.

    • @StatistikinDD
      @StatistikinDD  Год назад

      @@user-mh2pu1pe2n Looks like a known issue.
      github.com/rstudio/rstudio/issues/12945
      github.com/r-lib/devtools/issues/2512
      Maybe try updating as much as possible, e. g. RStudio, devtools, pkgbuild

    • @user-mh2pu1pe2n
      @user-mh2pu1pe2n Год назад

      @@StatistikinDD Thank you!