dcossyleon / firstclasspackage Goto Github PK
View Code? Open in Web Editor NEWthis content has been moved to the rstudio4edu book
Home Page: https://rstudio4edu.github.io/firstclasspackage/
this content has been moved to the rstudio4edu book
Home Page: https://rstudio4edu.github.io/firstclasspackage/
Hey @dcossyleon,
Working through the tutorial, and I have a few larger structural suggestions now that we can see it all together- which is why this draft is so helpful. This is my current thinking, based on working through this demo data package...
I think it is unfulfilling to start with barebones --> optional description --> fun stuff. I think our abstract thinking about this lead us to a slow start.
To fix this, I think you should start with use_data_raw()
and add a simple .R script (this is a manual step that seemed left out in the current version) that takes a built-in dataset that is like iris
or even anscombe
, just read it in and do something very simple to it, then use_data(overwrite = TRUE)
at the end of the script to export the .rda file. The benefit here is that users will (I hope) get the flow of a .R
script from data-raw/
-> .rda
in the data/
first.
After this series of steps, I did this locally and got my first hurrah moment 🎉
> devtools::load_all()
Loading datarrraw
> anscombe_set1
x1 y1
1 10 8.04
2 8 6.95
3 13 7.58
4 9 8.81
5 11 8.33
6 14 9.96
7 6 7.24
8 4 4.26
9 12 10.84
10 7 4.82
11 5 5.68
But now we have also created a bit of tension in their heads: what if I want to use my own data? Perhaps with my silly 🍣 analogy (issue #4 ), we say "but what if I want to catch my OWN fish??" Then we say, we hear you, we get it- as an educator, you really want to use your own stuff. Let's show you how to do that by saving your .csv
to the data-raw/
folder.
Now the question is, what should my .R
script look like now? Let's make a new one (again, manually) called xxx_load.R
(see: https://github.com/jennybc/repurrrsive/tree/master/data-raw). This should be just readr::read_csv()
in the .csv
, then use_data()
out to .rda
.
Trust but verify (second 🎉)
> devtools::load_all()
Loading datarrraw
> bakeoff_ratings
Now we can introduce check I think.
❯ checking for missing documentation entries ... WARNING
Undocumented code objects:
‘anscombe_set1’ ‘bakeoff_ratings’
Undocumented data sets:
‘anscombe_set1’ ‘bakeoff_ratings’
All user-level objects in a package should have documentation entries.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
Whoops! You have 3 warnings b/c nothing is documented. That's ok, and actually you could use this data package "as is" if you commit/push to your GitHub. But let's document your datasets because it will save you time and help your learners if they can use ?dataset
to see all the info about the variables. So you do use_r()
here, then unfortunately copy/paste from here: https://r-pkgs.org/data.html#documenting-data then edit, then ?bakeoff_ratings
works (third 🎉 )
Use the MIT license (or anyone) and edit DESCRIPTION (I forgot to do this, DESCRIPTION should go first I think), then run document/check again.
I also documented my first dataset, anscombe_set1
to get rid of warnings; document, check again, then ?anscombe_set1
-- hurray 🎉 .
Add package level documentation using usethis::use_package_doc()
, then do usethis::use_tibble()
(issue #7 - with the package-level doc open), and it will update it for you. Then update Run devtools::document()
/devtools::check()
. Yay 🎉 .
Finally (FINALLY), devtools::install()
. Then test drive: library(datarrraw)
; follow Jenny and print one of the datasets- it should be a pretty printed tibble 💐
Next you may want to demo editing the raw .csv
before exporting it. Maybe call the new .R script something like xxx_prep.R
and include a bit of wrangling code here to showcase how you can do that, and that you can use tidyverse
code here (and that because this folder is build ignored, you can use whatever packages you want- it doesn't need to affect the depends/suggests in the pkg description because these scripts are only run manually by you). here was mine
Optional things: adding a README, adding R functions (go elsewhere for all of these things, we link out to r-pkgs)
Also we need a call-out for advanced workflow with GitHub PAT set up
Another link dump:
After running "Check" on my dataset package, getting warnings about needing this dependence. Where could this be coming from? Esp. if all my clean-up scripts are in data-raw/ which should be getting ignored, right?
❯ checking data for ASCII and uncompressed saves ... WARNING
Warning: package needs dependence on R (>= 2.10)
0 errors ✔ | 1 warning ✖ | 0 notes ✔
>
��
��
Something weird must have happened when I transferred this repo. I'm not unable to edit the link for the page site or access the repo settings. @apreshill
Followed these instructions: http://ismayc.github.io/ecots2k16/template_pkg/
But I don't see the template after the package is installed. Is this an issue with there being so many subdirectories?
In the R Packages book, what is the purpose of suggesting that the following be added to the package-level .R script for its documentation?
#' @docType package
#' @name foo
Also, it's confusing that the usethis::use_package_doc()
does not produce the same output that matches what we see in the example of R Packages, documenting packages.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.