diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..88eb4ad --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1 @@ +^development\.R$ diff --git a/.quarto/_freeze/posts/2021-05-04-building-r-packages/index/execute-results/html.json b/.quarto/_freeze/posts/2021-05-04-building-r-packages/index/execute-results/html.json index f40d397..5d646d1 100644 --- a/.quarto/_freeze/posts/2021-05-04-building-r-packages/index/execute-results/html.json +++ b/.quarto/_freeze/posts/2021-05-04-building-r-packages/index/execute-results/html.json @@ -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\n\n
\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 \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\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\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 = \"This frog can be found in the tropical rain forests of Costa Rica.
\n{{ .description }}
\n