How to Include Data in Your R Package

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024
  • Including data in an R package can be very useful. Here we create an R package from scratch that offers a function to calculate a user-defined customer score from strictly defined variable names. To showcase the function, we need data, so we include an example dataset in the package and document it using roxygen tags. Data documentation is somewhat different to function documentation. We use the great usethis package for our convenience.
    To find out more, read the great R Packages book by Hadley Wickham and Jenny Bryan: r-pkgs.org/ind...
    Contact me, e. g. to discuss (online) R workshops / trainings / webinars:
    LinkedIn: / wolfriepl
    Twitter: / statistikindd
    Xing: www.xing.com/p...
    Facebook: / statistikdresden
    statistik-dres...
    R Workshops: statistik-dres...
    Blog (German, translate option): statistik-dres...
    Playlist: Music chart history
    • Music Chart History

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

  • @dominicacri5395
    @dominicacri5395 15 дней назад

    Very helpful. thank you!

  • @kabilans9666
    @kabilans9666 2 года назад +3

    Simple and easy to understand. Nice explanation

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

    Thanks, quick and easy to follow. Best,

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

    Nice. This was really handy!

  • @saimajahan8317
    @saimajahan8317 2 месяца назад

    I like that video. I have a question is it possible to add data from a package (which is not mine) to t? If possible, then how?

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

      You can add any data that you can get in the Global Environment.
      If it is already in a package, you may also add that package to Suggests or Imports.

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

      So how: load data into Global Environment. Then proceed as in video.
      I'm just not sure if I'd like the same data in different packages. But there may be situations where it makes sense. E. g. to avoid dependency on that other package, maybe because it contains a lot more than the data, or because it is difficult to access in your environment.

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

    How do you document the dataset if you are reading in a csv file?

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

      Good question. As far as I know, data documentation works for R objects. csv is a non-native format from R's perspective.
      Some packages contain data (as R-native objects) and additionally make the same data available in .csv or .tsv format, like palmerpenguins and gapminder.
      r-pkgs.org/data.html#sec-data-extdata

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

    Thanks alot! This has been absolutely helpful. But how do i push this now to github? Or how do i create a new package project and link it to github?

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

      If it's not a local project, make it one. In RStudio, you can use the "New Project" option in the projects menu in the top right corner.
      If it's a local project, but without a git repository, create one. You can use usethis::use_git() to that end.
      If it's a local project with a git repository that is not yet on github, you can push it there using usethis::use_github(). Check the help page to see about the options, e. g. how to make it a private repository.

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

      @@StatistikinDD aha! thanks for the ultra-fast answer. gonna test it tonight...

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

    Why do you waste so much time on explaining what the function inhouse_calc does? No one cares it scales, no one cares it's not exactly between 0 and 100, etc. The video title says this is about including data in your R package so it would be better to focus on that and leave everything distracting aside.

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

      Thanks for your comment, Robert. I'll try to stick more to the point next time.

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

      @@StatistikinDD Clearly explained and straight to point. Saved me a lot of time just by watching this video. Thank you!

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

      You have a very logical point but some information about other stuff comes with main topic's wind. You don't just go from point a to b. You also see where the supermarket on your way to point b. This kind of informations is crucial for some people, and showing it with a realistic and alive example is also important. You can simply skip it. Anyways. Great tutorial @StatistikinDD keep it rooling!