-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small fixes to standardize titles and author names
- Making all titles sentence case - Removing "Dr." or "Pr." because they aren't applied in a standard way to all PIs / Ph. D.s
- Loading branch information
1 parent
79519f7
commit 4cf1866
Showing
23 changed files
with
61 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
^development\.R$ |
4 changes: 2 additions & 2 deletions
4
.quarto/_freeze/posts/2021-05-04-building-r-packages/index/execute-results/html.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"hash": "df96dd7b0c06e257f0066e58be1df75f", | ||
"hash": "2759d1707cdb7cd48df6fad351b0353b", | ||
"result": { | ||
"markdown": "---\ntitle: \"Building R packages\"\ndescription: |\n This practical training will cover the basics of modern package development in R with a focus on the following three aspects: (1) how to turn your code into functions, (2) how to write tests and documentation, and (3) how to share your R package on GitHub..\nauthor: Andrew MacDonald\ndate: \"2021-05-04\"\ncategories: [Technical, EN]\ntoc: true\nnumber-sections: true\nnumber-depth: 1\n---\n\n\n\n\n<iframe src=\"https://giphy.com/embed/HGe4zsOVo7Jvy\" width=\"480\" height=\"270\" frameBorder=\"0\" class=\"giphy-embed\" allowFullScreen>\n\n</iframe>\n\n<p><a href=\"https://giphy.com/gifs/sesame-street-cookies-cookie-monster-HGe4zsOVo7Jvy\">via GIPHY</a></p>\n\nR packages! they are kind of like cookies:\n\n- Almost everyone enjoys them\n\n- delicious when homemade\n\n- Lots of storebought options available\n\n- Great skill to have\n\n- not necessary to sell them!\n\n <aside>here \"selling\" cookies is a metaphor for taking your package public, i.e. by submitting to CRAN or even simply by releasing it on a public-facing GitHub page.</aside>\n\nBut most of all: cookies are delicious for what they *contain*: chocolate chunks, candy, oats, cocoa. However, all cookies share some fundamental ingredients and nearly identical structure. Flour, saturated with fat and sugar hydrated only with an egg, flavoured with vanilla and salt. The basic formula is invariant and admits only slight deviation -- otherwise, it becomes something other than a cookie.\n\nThis workshop is devoted to the study of cookie dough.\n\n### *Mise en place* : development environment\n\nWe'll explore a few useful packages in this workshop. The first two in particular are very popular tools for modern-day R package development:\n\n``` r\ninstall.packages(\"devtools\")\ninstall.packages(\"usethis\")\ninstall.packages(\"testthat\")\ninstall.packages(\"assertthat\")\n```\n\nBuilding an R package also requires specific tools for compiling the finished package. Run the following line to make sure you have the development environment:\n\n``` r\ndevtools::has_devel()\n```\n\nIf you do not have the software to build R packages, you should see a message which will help you find the correct links to download what you need!\n\nWindows will need RTools. First do the check above to see if you are already set up. If not then [download the software here](https://cran.r-project.org/bin/windows/Rtools/).\n\nand Install. After that, open R and run the following:\n\n``` r\nwriteLines('PATH=\"${RTOOLS40_HOME}\\\\usr\\\\bin;${PATH}\"', con = \"~/.Renviron\")\n```\n\nand restart R. Then run the check above once more to confirm\n\n<aside>**During the training I will be calling on learners with different Operating Systems and/or Text Editors to share their experience!**</aside>\n\n## The structure: flour and sugar\n\n> No cookies without carbs\n\nAn R package is essentially a folder on your computer with specific structure. We will begin by creating an empty R package and taking a tour!\n\nOpen your R code editor, and find out where you are:\n\n``` r\ngetwd()\n```\n\nThis is to prepare for the next step, where we will choose a location for our R package folder. Please be intentional about where you place your R package! Do not place it in the same space as another package, Rstudio project or other project. Create a new and isolated location for it.\n\nI am working from an existing R project in my typical R Projects folder, so I go up one level:\n\n``` r\nusethis::create_package(\"../netwerk\")\n```\n\n<aside>we are sticking with `usethis` because we want to keep this general. All of these steps can be manual, and indeed for many years they were!</aside>\n\n\n\nLet's run R CMD CHECK right away. We will do this MANY TIMES.\n\n``` r\ndevtools::check()\n```\n\nWe should see some warnings! let's keep these in mind as we continue our tour.\n\n### The DESCRIPTION file\n\nThe most important file to notice is the DESCRIPTION. This gives general information about the entire package. It is written in a specific file format\n\n``` dcf\nPackage: netwerk\nTitle: Werks with Networks\nVersion: 0.0.0.9000\nAuthors@R: \n person(given = \"Andrew\",\n family = \"MacDonald\",\n role = c(\"aut\", \"cre\"),\n email = \"<[email protected]>\")\nDescription: it does networks.\nLicense: MIT + file LICENSE\nEncoding: UTF-8\nLazyData: true\nRoxygen: list(markdown = TRUE)\nRoxygenNote: 7.1.1\nSuggests: \n testthat (>= 3.0.0)\nConfig/testthat/edition: 3\n```\n\nHere are some things to edit *manually* in `DESCRIPTION`:\n\n- package name \\[tk naming of R packages\\] -- make it short and convenient if you can!\n- Title: write this part In Title Case. Don't end the title with a period.\n- Description: Describe the package in a short block of text. This *should* end with a period.\n- Authors: Add your name here and the name of anyone building the package with you. `usethis` will have done the first step for you, and filled in the structure. Only \"aut\" (author) and \"cre\" (creator) are essential. [but many others are possible](https://www.loc.gov/marc/relators/relaterm.html)\n\nAdd your name here.\n\nAdd a license\n\n``` r\nusethis::use_mit_license(copyright_holder = \"\")\n```\n\nnote about the different roles taht R package authors can have. Funny ones. but creator and maintainer are the key ones.\n\nNote the R folder. We'll get much more into that later\n\n- Rbuildignore\n\n## Keeping notes\n\ncreate an R file\n\n``` r\nusethis::use_build_ignore(\"dev.R\")\n```\n\nthe docs folder\n\nhere we have a very minimal version of an R packages we're going to be adding to it as the course progresses.\n\nOne thing we can do right away is build and check the R package\n\nWhat exactly is happining here? slide from R package tutorial.\n\nLots of checkpoints and progress confrimations along the way.\n\nOK so what is that all about? we have compiled the R package and it has gone to where the R packages on our computer go.\n\nThere is a natural cycle to how the different steps in an R package workflow proceed -- see the documentation for this lesson -- we will be following this process (TK another pictures?\n\nOk so now that we ahve the basic structure, let's talk about some content for the R package. I received the donation of a little R function already that we can use to create this workflow in a nice way\n\nThis R function (explain what the function does)\n\nOK so let's focus on just one part of this function.\n\nload all -- shortcut\n\n> how do we do this in VScode?\n\n> how to add something to the .Rbuildignore? it would be nice to have a little .dev script as a space to create all the ohter dependencies that are involved in making an R package.\n\n\n::: {.cell}\n::: {.cell-output .cell-output-stderr}\n```\n✔ Setting active project to '/Users/katherine/Documents/GitHub/bios2.github.io-quarto'\n✔ Adding '^development\\\\.R$' to 'posts/2021-05-04-building-r-packages/.Rbuildignore'\n```\n:::\n:::\n\n\n## Useful links\n\nThis workshop borrows heavily from some excellent sources:\n\n- the [R packages book](https://r-pkgs.org/index.html) especially the [\"Whole Game\"](https://r-pkgs.org/whole-game.html#whole-game) chapter!\n- [rOpenSci Packages: Development, Maintenance, and Peer Review](https://devguide.ropensci.org/index.html)\n\nhttps://builder.r-hub.io/about.html\n", | ||
"markdown": "---\ntitle: \"Building R packages\"\ndescription: |\n This practical training will cover the basics of modern package development in R with a focus on the following three aspects: (1) how to turn your code into functions, (2) how to write tests and documentation, and (3) how to share your R package on GitHub..\nauthor: Andrew MacDonald\ndate: \"2021-05-04\"\nimage: altumcode-PNbDkQ2DDgM-unsplash.jpeg\ncategories: [Technical, EN]\ntoc: true\nnumber-sections: true\nnumber-depth: 1\n---\n\n\n\n\n<iframe src=\"https://giphy.com/embed/HGe4zsOVo7Jvy\" width=\"480\" height=\"270\" frameBorder=\"0\" class=\"giphy-embed\" allowFullScreen>\n\n</iframe>\n\n<p><a href=\"https://giphy.com/gifs/sesame-street-cookies-cookie-monster-HGe4zsOVo7Jvy\">via GIPHY</a></p>\n\nR packages! they are kind of like cookies:\n\n- Almost everyone enjoys them\n\n- delicious when homemade\n\n- Lots of storebought options available\n\n- Great skill to have\n\n- not necessary to sell them!\n\n <aside>here \"selling\" cookies is a metaphor for taking your package public, i.e. by submitting to CRAN or even simply by releasing it on a public-facing GitHub page.</aside>\n\nBut most of all: cookies are delicious for what they *contain*: chocolate chunks, candy, oats, cocoa. However, all cookies share some fundamental ingredients and nearly identical structure. Flour, saturated with fat and sugar hydrated only with an egg, flavoured with vanilla and salt. The basic formula is invariant and admits only slight deviation -- otherwise, it becomes something other than a cookie.\n\nThis workshop is devoted to the study of cookie dough.\n\n### *Mise en place* : development environment\n\nWe'll explore a few useful packages in this workshop. The first two in particular are very popular tools for modern-day R package development:\n\n``` r\ninstall.packages(\"devtools\")\ninstall.packages(\"usethis\")\ninstall.packages(\"testthat\")\ninstall.packages(\"assertthat\")\n```\n\nBuilding an R package also requires specific tools for compiling the finished package. Run the following line to make sure you have the development environment:\n\n``` r\ndevtools::has_devel()\n```\n\nIf you do not have the software to build R packages, you should see a message which will help you find the correct links to download what you need!\n\nWindows will need RTools. First do the check above to see if you are already set up. If not then [download the software here](https://cran.r-project.org/bin/windows/Rtools/).\n\nand Install. After that, open R and run the following:\n\n``` r\nwriteLines('PATH=\"${RTOOLS40_HOME}\\\\usr\\\\bin;${PATH}\"', con = \"~/.Renviron\")\n```\n\nand restart R. Then run the check above once more to confirm\n\n<aside>**During the training I will be calling on learners with different Operating Systems and/or Text Editors to share their experience!**</aside>\n\n## The structure: flour and sugar\n\n> No cookies without carbs\n\nAn R package is essentially a folder on your computer with specific structure. We will begin by creating an empty R package and taking a tour!\n\nOpen your R code editor, and find out where you are:\n\n``` r\ngetwd()\n```\n\nThis is to prepare for the next step, where we will choose a location for our R package folder. Please be intentional about where you place your R package! Do not place it in the same space as another package, Rstudio project or other project. Create a new and isolated location for it.\n\nI am working from an existing R project in my typical R Projects folder, so I go up one level:\n\n``` r\nusethis::create_package(\"../netwerk\")\n```\n\n<aside>we are sticking with `usethis` because we want to keep this general. All of these steps can be manual, and indeed for many years they were!</aside>\n\n\n\nLet's run R CMD CHECK right away. We will do this MANY TIMES.\n\n``` r\ndevtools::check()\n```\n\nWe should see some warnings! let's keep these in mind as we continue our tour.\n\n### The DESCRIPTION file\n\nThe most important file to notice is the DESCRIPTION. This gives general information about the entire package. It is written in a specific file format\n\n``` dcf\nPackage: netwerk\nTitle: Werks with Networks\nVersion: 0.0.0.9000\nAuthors@R: \n person(given = \"Andrew\",\n family = \"MacDonald\",\n role = c(\"aut\", \"cre\"),\n email = \"<[email protected]>\")\nDescription: it does networks.\nLicense: MIT + file LICENSE\nEncoding: UTF-8\nLazyData: true\nRoxygen: list(markdown = TRUE)\nRoxygenNote: 7.1.1\nSuggests: \n testthat (>= 3.0.0)\nConfig/testthat/edition: 3\n```\n\nHere are some things to edit *manually* in `DESCRIPTION`:\n\n- package name \\[tk naming of R packages\\] -- make it short and convenient if you can!\n- Title: write this part In Title Case. Don't end the title with a period.\n- Description: Describe the package in a short block of text. This *should* end with a period.\n- Authors: Add your name here and the name of anyone building the package with you. `usethis` will have done the first step for you, and filled in the structure. Only \"aut\" (author) and \"cre\" (creator) are essential. [but many others are possible](https://www.loc.gov/marc/relators/relaterm.html)\n\nAdd your name here.\n\nAdd a license\n\n``` r\nusethis::use_mit_license(copyright_holder = \"\")\n```\n\nnote about the different roles that R package authors can have. Funny ones. but creator and maintainer are the key ones.\n\nNote the R folder. We'll get much more into that later\n\n- Rbuildignore\n\n## Keeping notes\n\ncreate an R file\n\n``` r\nusethis::use_build_ignore(\"dev.R\")\n```\n\nthe docs folder\n\nhere we have a very minimal version of an R packages we're going to be adding to it as the course progresses.\n\nOne thing we can do right away is build and check the R package\n\nWhat exactly is happining here? slide from R package tutorial.\n\nLots of checkpoints and progress confrimations along the way.\n\nOK so what is that all about? we have compiled the R package and it has gone to where the R packages on our computer go.\n\nThere is a natural cycle to how the different steps in an R package workflow proceed -- see the documentation for this lesson -- we will be following this process (TK another pictures?\n\nOk so now that we ahve the basic structure, let's talk about some content for the R package. I received the donation of a little R function already that we can use to create this workflow in a nice way\n\nThis R function (explain what the function does)\n\nOK so let's focus on just one part of this function.\n\nload all -- shortcut\n\n> how do we do this in VScode?\n\n> how to add something to the .Rbuildignore? it would be nice to have a little .dev script as a space to create all the ohter dependencies that are involved in making an R package.\n\n\n::: {.cell}\n\n:::\n\n\n## Useful links\n\nThis workshop borrows heavily from some excellent sources:\n\n- the [R packages book](https://r-pkgs.org/index.html) especially the [\"Whole Game\"](https://r-pkgs.org/whole-game.html#whole-game) chapter!\n- [rOpenSci Packages: Development, Maintenance, and Peer Review](https://devguide.ropensci.org/index.html)\n\nhttps://builder.r-hub.io/about.html\n", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
|
Oops, something went wrong.