My First R Package (Part 2)
In Part 1, I set up RStudio with usethis, and created my first Minimum Viable R Package (MVRP?) which was then pushed to Github to create a new repository.
I added a README:
> use_readme_rmd() ✔ Writing 'README.Rmd' ✔ Adding '^README\\.Rmd$' to '.Rbuildignore' ● Modify 'README.Rmd' ✔ Writing '.git/hooks/pre-commit'
Things were moving along just fine, until I got this unkind message (what do you mean NOT an R package???!! What have I been doing the past hour?)
> use_testthat() Error: `use_testthat()` is designed to work with packages. Project 'easyMTS' is not an R package. > use_mit_license("Nicole Radziwill") ✔ Setting active project to 'D:/R/easyMTS' Error: `use_mit_license()` is designed to work with packages. Project 'easyMTS' is not an R package.
Making easyMTS a Real Package
I sent out a tweet hoping to find some guidance, because Stack Overflow and Google and the RStudio community were coming up blank. As soon as I did, I discovered this button in RStudio:
The first time I ran it, it complained that I needed Rtools, but that Rtools didn’t exist for version 3.6.1. I decided to try finding and installing Rtools anyway because what could I possibly lose. I went to my favorite CRAN repository and found a link for Rtools just under the link for the base install:
I’m on Windows 10, so this downloaded an .exe which I quickly right-clicked on to run… the installer did its thing, and I clicked “Finish”, assuming that all was well. Then I went back into RStudio and tried to do Build -> Clean and Rebuild… and here’s what happened:
IT WORKED!! (I think!!!)
It created a package (top right) and then loaded it into my RStudio session (bottom left)! It loaded the package name into the package console (bottom right)!
I feel like this is a huge accomplishment for now, so I’m going to move to Part 3 of my blog post. We’ll figure out how to close the gaps that I’ve invariably introduced by veering off-tutorial.
Pingback: My First R Package (Part 1) ⋆ Quality and Innovation
Pingback: My First R Package (Part 2) – Technology Revolution
Pingback: My First R Package (Part 1) – Data Science Austria