

{"id":12609,"date":"2020-01-03T11:22:02","date_gmt":"2020-01-03T16:22:02","guid":{"rendered":"https:\/\/rud.is\/b\/?p=12609"},"modified":"2020-01-02T16:49:11","modified_gmt":"2020-01-02T21:49:11","slug":"writing-frictionless-r-package-wrappers-building-a-basic-r-package","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/","title":{"rendered":"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package"},"content":{"rendered":"<p>Before we start wrapping foreign language code we need to make sure that basic R packages can be created. If you&#8217;ve <a href=\"https:\/\/rud.is\/b\/2020\/01\/01\/writing-frictionless-r-package-wrappers-introduction\/\">followed along from the previous post<\/a> you have everything you need to get started here. <em>Just to make sure<\/em>, you should be able to fire up a new RStudio session and execute the following R code and see similar output. If not, you&#8217;ll need to go through the steps and resources outlined there before continuing.<\/p>\n<pre><code class=\"language-r\">pkgbuild::check_build_tools()\n### Your system is ready to build packages!\n<\/code><\/pre>\n<p>Also: the {bookdown} version should now always match the blog post (apart from some verbiage changes to denote it&#8217;s in a book vs a series of blog posts). You can refer to it at any time via \u2014 <a href=\"https:\/\/rud.is\/books\/writing-frictionless-r-package-wrappers\/\">https:\/\/rud.is\/books\/writing-frictionless-r-package-wrappers\/<\/a>.<\/p>\n<h3>Configuring {devtools}<\/h3>\n<p>We&#8217;re going to rely on the {devtools} package for many operations and the first thing you should do now is execute <code>help(\"create\", \"devtools\")<\/code> in an RStudio R console to see the package documentation page where you&#8217;ll see guidance pointing you to <code>devtools::use_description()<\/code> that lists some R session <code>options()<\/code> that you can set to make your package development life much easier and quicker. Specifically, it lets you know that you can setup your <code>~\/.Rprofile<\/code> to include the certain options settings which will automatically fill in fields each time you create a new package vs you either specifying these fields manually in the package creation GUI or as parameters to <code>devtools::create()<\/code>.<\/p>\n<p>A good, minimal setup would be something like:<\/p>\n<pre><code class=\"language-r\">options(\n  usethis.description = list(\n    `Authors@R` = 'person(\"Some\", \"One\", email = \"someone@example.com\", role = c(\"aut\", \"cre\"),\n                          comment = c(ORCID = \"YOUR-ORCID-ID\"))',\n    License = \"MIT + file LICENSE\"\n  )\n)\n<\/code><\/pre>\n<p>NOTE: If you do not have an &#8220;ORCID&#8221; you really should get one (they&#8217;re free!) by heading over to<br \/>\n&#8212; <a href=\"https:\/\/orcid.org\/\">https:\/\/orcid.org\/<\/a> &#8212; and filling in some basic information.<\/p>\n<p>Take a moment to edit your <code>~\/.Rprofile<\/code>. If you&#8217;re not sure about how to do that there is an excellent chapter in Efficient R Programming<sup id=\"fnref-12609-1\"><a href=\"#fn-12609-1\" class=\"jetpack-footnote\">1<\/a><\/sup> which walks you through the process.<\/p>\n<p>Once you&#8217;ve added or verified these new <code>options()<\/code> settings, restart your R session.<\/p>\n<h3>Creating A Package<\/h3>\n<p>We&#8217;re <em>almost<\/em> ready to create and build a basic R package. All R packages live in a package directory and I highly suggest creating a <code>packages<\/code> directory right off your home directory (e.g. &#8220;<code>~\/packages<\/code>&#8220;) or someplace where you&#8217;ll be able to keep them all organized and accessible. The rest of these posts will assume you&#8217;re using &#8220;<code>~\/packages<\/code>&#8221; as the<\/p>\n<p>With {devtools} now pre-configured, use the RStudio R Console pane to execute the following code which should produce similar output and open up a new RStudio session with the new package directory:<\/p>\n<pre><code class=\"language-r\">devtools::create(\"~\/packages\/myfirstpackage\") \n## \u2714 Creating '\/Users\/someuser\/packages\/myfirstpackage\/'\n## \u2714 Setting active project to '\/Users\/someuser\/packages\/myfirstpackage'\n## \u2714 Creating 'R\/'\n## \u2714 Writing 'DESCRIPTION'\n## Package: myfirstpackage\n## Title: What the Package Does (One Line, Title Case)\n## Version: 0.0.0.9000\n## Authors@R (parsed):\n##     * Bob Rudis &lt;bob@rud.is&gt; [aut, cre] (&lt;https:\/\/orcid.org\/0000-0001-5670-2640&gt;)\n## Description: What the package does (one paragraph).\n## License: MIT + file LICENSE\n## Encoding: UTF-8\n## LazyData: true\n## \u2714 Writing 'NAMESPACE'\n## \u2714 Writing 'myfirstpackage.Rproj'\n## \u2714 Adding '.Rproj.user' to '.gitignore'\n## \u2714 Adding '^myfirstpackage\\\\.Rproj$', '^\\\\.Rproj\\\\.user$' to '.Rbuildignore'\n## \u2714 Opening '\/Users\/someuser\/packages\/myfirstpackage\/' in new RStudio session\n## \u2714 Setting active project to '&lt;no active project&gt;'\n<\/code><\/pre>\n<p>The directory structure will look like this:<\/p>\n<pre><code class=\"language-shell\">.\n\u251c\u2500\u2500 DESCRIPTION\n\u251c\u2500\u2500 NAMESPACE\n\u251c\u2500\u2500 R\/\n\u2514\u2500\u2500 myfirstpackage.Rproj\n<\/code><\/pre>\n<p>At this point we still do not have a &#8220;perfect&#8221; R package. To prove this, use the R console to run <code>devtools::check()<\/code> and &#8212; after some rather verbose output &#8212; you&#8217;ll see the following lines at the end:<\/p>\n<pre><code class=\"language-shell\">&gt; checking DESCRIPTION meta-information ... WARNING\n  Invalid license file pointers: LICENSE\n\n0 errors \u2713 | 1 warning x | 0 notes \u2713\n<\/code><\/pre>\n<p>Since we&#8217;re saying that our package will be using the MIT license, we need to ensure there&#8217;s an associated <code>LICENSE<\/code> file which we can do by executing <code>usethis::use_mit_license()<\/code> which will create the necessary files and ensure the <code>License<\/code> field in the <code>DESCRIPTION<\/code> file is formatted properly.<\/p>\n<p>If you run <code>devtools::check()<\/code> again, now, your final line should report:<\/p>\n<pre><code class=\"language-r\">## 0 errors \u2713 | 0 warnings \u2713 | 0 notes \u2713\n<\/code><\/pre>\n<p>and the package directory tree should look like this:<\/p>\n<pre><code class=\"language-shell\">\u251c\u2500\u2500 DESCRIPTION\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 LICENSE.md\n\u251c\u2500\u2500 NAMESPACE\n\u251c\u2500\u2500 R\/\n\u2514\u2500\u2500 myfirstpackage.Rproj\n<\/code><\/pre>\n<h3>Rounding Out The Corners<\/h3>\n<p>While we have a minimum viable package there are a few other steps we should take during this setup phase. First we&#8217;ll setup our package to use <code>{roxygen2}<\/code><sup id=\"fnref-12609-2\"><a href=\"#fn-12609-2\" class=\"jetpack-footnote\">2<\/a><\/sup> for documenting functions, declaring <code>NAMESPACE<\/code> imports, and other helper-features that will be introduced in later posts. We can do this via <code>usethis::use_roxygen_md()<\/code>:<\/p>\n<pre><code class=\"language-r\">usethis::use_roxygen_md()\n## \u2714 Setting Roxygen field in DESCRIPTION to 'list(markdown = TRUE)'\n## \u2714 Setting RoxygenNote field in DESCRIPTION to '7.0.2'\n## \u25cf Run `devtools::document()`\n<\/code><\/pre>\n<p>We won&#8217;t run <code>devtools::document()<\/code> <em>just yet<\/em>, though. Before we do that we&#8217;ll also create an R file where we can store top-level package introduction\/meta-information:<\/p>\n<pre><code class=\"language-r\">usethis::use_package_doc()\n## \u2714 Writing 'R\/myfirstpackage-package.R'\n<\/code><\/pre>\n<p>Now, our directory tree should look like:<\/p>\n<pre><code class=\"language-shell\">.\n\u251c\u2500\u2500 DESCRIPTION\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 LICENSE.md\n\u251c\u2500\u2500 NAMESPACE\n\u251c\u2500\u2500 R\n\u2502   \u2514\u2500\u2500 myfirstpackage-package.R\n\u2514\u2500\u2500 myfirstpackage.Rproj\n<\/code><\/pre>\n<p>Now, run <code>devtools::document()<\/code> which will translate the {roxygen2} comments into a properly-formatted R documentation file and regenerate the <code>NAMESPACE<\/code> file (as we&#8217;ll be managing package imports and exports via {roxygen2} comments). The directory tree will now look like:<\/p>\n<pre><code class=\"language-shell\">.\n\u251c\u2500\u2500 DESCRIPTION\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 LICENSE.md\n\u251c\u2500\u2500 NAMESPACE\n\u251c\u2500\u2500 R\n\u2502   \u2514\u2500\u2500 myfirstpackage-package.R\n\u251c\u2500\u2500 man\n\u2502   \u2514\u2500\u2500 myfirstpackage-package.Rd\n\u2514\u2500\u2500 myfirstpackage.Rproj\n<\/code><\/pre>\n<p>and, we can now re-run <code>devtools::check()<\/code> to make sure we have the three &#8220;0&#8217;s&#8221; we&#8217;re aiming for each time we check our package for errors.<\/p>\n<h3>Passing The Test<\/h3>\n<p>We&#8217;re going to want to write and use tests to ensure our package works properly. There are many R package testing frameworks available. To ease the introduction into this process, we&#8217;ll use one of the frameworks that came along for the ride when you installed the various packages outlined in the previous post: {testthat}<sup id=\"fnref-12609-3\"><a href=\"#fn-12609-3\" class=\"jetpack-footnote\">3<\/a><\/sup>. Setting up {testthat} is also pretty painless thanks to the {usethis} package we&#8217;ve been taking advantage of quite a bit so far. We&#8217;ll create the {testthat} overall infrastructure then add a placeholder test script since <code>devtools::check()<\/code> will complain about no tests being available if we do not have at least a single script it can execute during the test phase of the package checking process.<\/p>\n<pre><code class=\"language-r\">usethis::use_testthat()\n## \u2714 Adding 'testthat' to Suggests field in DESCRIPTION\n## \u2714 Creating 'tests\/testthat\/'\n## \u2714 Writing 'tests\/testthat.R'\n## \u25cf Call `use_test()` to initialize a basic test file and open it for editing.\n\nusethis::use_test(\"placeholder\")\n## \u2714 Increasing 'testthat' version to '&gt;= 2.1.0' in DESCRIPTION\n## \u2714 Writing 'tests\/testthat\/test-placeholder.R'\n## \u25cf Modify 'tests\/testthat\/test-placeholder.R'\n<\/code><\/pre>\n<p>The directory tree will now look like this:<\/p>\n<pre><code class=\"language-shell\">.\n\u251c\u2500\u2500 DESCRIPTION\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 LICENSE.md\n\u251c\u2500\u2500 NAMESPACE\n\u251c\u2500\u2500 R\n\u2502   \u2514\u2500\u2500 myfirstpackage-package.R\n\u251c\u2500\u2500 man\n\u2502   \u2514\u2500\u2500 myfirstpackage-package.Rd\n\u251c\u2500\u2500 myfirstpackage.Rproj\n\u2514\u2500\u2500 tests\n    \u251c\u2500\u2500 testthat\n    \u2502   \u2514\u2500\u2500 test-placeholder.R\n    \u2514\u2500\u2500 testthat.R\n<\/code><\/pre>\n<p>Run <code>devtools::check()<\/code> one more time to make sure we&#8217;ve got those precious 3 &#8220;0&#8217;s&#8221; one last time.<\/p>\n<h3>Getting Things Under Control<\/h3>\n<p>We&#8217;re <em>almost<\/em> done! One final step is to turn this directory into a git-managed directory so we can work a bit more safely and eventually share our development work with a broader audience. Provided you followed the outline in the previous post, setting up git is as straightforward as one {usethis} function call:<\/p>\n<pre><code class=\"language-r\">usethis::use_git()\n## \u2714 Setting active project to '\/Users\/someuser\/packages\/myfirstpackage'\n## \u2714 Initialising Git repo\n## \u2714 Adding '.Rhistory', '.RData' to '.gitignore'\n## There are 10 uncommitted files:\n## * '.gitignore'\n## * '.Rbuildignore'\n## * 'DESCRIPTION'\n## * 'LICENSE'\n## * 'LICENSE.md'\n## * 'man\/'\n## * 'myfirstpackage.Rproj'\n## * 'NAMESPACE'\n## * 'R\/'\n## * 'tests\/'\n## Is it ok to commit them?\n## \n## 1: For sure\n## 2: Negative\n## 3: Not now\n## \n## Selection: 1\n## \u2714 Adding files\n## \u2714 Commit with message 'Initial commit'\n## \u25cf A restart of RStudio is required to activate the Git pane\n## Restart now?\n## \n## 1: Negative\n## 2: Not now\n## 3: Yup\n## \n## Selection: 3\n<\/code><\/pre>\n<p>RStudio should have been restarted (so it can add a &#8220;Git&#8221; pane in case you want to use the GUI to manage git) and the directory tree will now have a <code>.git\/<\/code> subdirectory that you should (almost) never touch by hand.<\/p>\n<p>The last thing to do is to &#8220;vaccinate&#8221; your git setup so you don&#8217;t leak sensitive or unnecessary files when you (eventually) share your creation with the world:<\/p>\n<pre><code class=\"language-r\">usethis::git_vaccinate()\n## \u2714 Adding '.Rproj.user', '.Rhistory', '.Rdata' to '\/Users\/someuser\/.gitignore'\n<\/code><\/pre>\n<p>We now have a basic, working R package that is devoid of any real functionality other than that of getting us familiar with the package setup and validation processes. We&#8217;ll be building upon this experience in most of the coming posts.<\/p>\n<h3>Quick Reference<\/h3>\n<p>After ensuring you&#8217;ve got the recommended <code>options()<\/code> in place, here are the steps to setup a new package:<\/p>\n<pre><code class=\"language-r\"># in any RStudio R Console session\ndevtools::create(\"~\/packages\/THE-PACKAGE-NAME\")\n\n# in the newly created package RStudio R Console session:\nusethis::use_mit_license()       # need a LICENSE file\nusethis::use_roxygen_md()        # use {roxygen2} for documentation and configuration\nusethis::use_package_doc()       # setup a package-level manual page\nusethis::use_testthat()          # setup testing infrastructure\nusethis::use_test(\"placeholder\") # setup a placeholder test file\ndevtools::document()             # Let {roxygen2} create NAMESPACE entries, build manual pages (and, more later on)\ndevtools::check()                # looking for the three \"0's\" that tell us we're ready to roll!\nusethis::use_git()               # put the directory under git version control\nusethis::git_vaccinate()         # Prevent leaking credentials and other unnecessary filesystem cruft\n<\/code><\/pre>\n<p>Rather than re-type <code>devtools::document()<\/code> (et al) whenever you need to run {roxygen2} or build\/check a package you can use RStudio keyboard shortcuts that are designed to seamlessly integrate with the {devtools} ecosystem:<\/p>\n<table>\n<thead>\n<tr>\n<th>Operation<\/th>\n<th>Windows &amp; Linux<\/th>\n<th>Mac<\/th>\n<th>{devtools} equivalent<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Install and Restart<\/td>\n<td>Ctrl+Shift+B<\/td>\n<td>Cmd+Shift+B<\/td>\n<td>devtools::install()<\/td>\n<\/tr>\n<tr>\n<td>Load All (devtools)<\/td>\n<td>Ctrl+Shift+L<\/td>\n<td>Cmd+Shift+L<\/td>\n<td>devtools::load_all()<\/td>\n<\/tr>\n<tr>\n<td>Test Package (Desktop)<\/td>\n<td>Ctrl+Shift+T<\/td>\n<td>Cmd+Shift+T<\/td>\n<td>devtools::test()<\/td>\n<\/tr>\n<tr>\n<td>Test Package (Web)<\/td>\n<td>Ctrl+Alt+F7<\/td>\n<td>Cmd+Alt+F7<\/td>\n<td>devtools::test()<\/td>\n<\/tr>\n<tr>\n<td>Check Package<\/td>\n<td>Ctrl+Shift+E<\/td>\n<td>Cmd+Shift+E<\/td>\n<td>devtools::check()<\/td>\n<\/tr>\n<tr>\n<td>Document Package<\/td>\n<td>Ctrl+Shift+D<\/td>\n<td>Cmd+Shift+D<\/td>\n<td>devtools::document()<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We&#8217;ll refer to these operations as &#8220;install&#8221; (or &#8220;build&#8221;), &#8220;load all&#8221;, &#8220;test&#8221;, &#8220;check&#8221;, and &#8220;document&#8221; from now on so you can choose to use the console or the shortcuts as you prefer.<\/p>\n<h3>Exercises<\/h3>\n<p>Our package may be kinda, well, <em>useless<\/em> for the moment but that doesn&#8217;t mean you can&#8217;t show it some love and get some practice in at the same time while things are still relatively straightforward.<\/p>\n<ul>\n<li>Modify the <code>Title<\/code>, <code>Version<\/code>, and <code>Description<\/code> fields of the <code>DESCRIPTION<\/code> file and refine them as needed until package checks pass.<\/li>\n<li>Deliberately mangle parts of the <code>DESCRIPTION<\/code> file to see what errors or warnings you receive during the package check process.<\/li>\n<li>Read up on {roxygen2} and add some <code>Section<\/code>s to it formatted with markdown and\/or LaTeX. Re-&#8220;document&#8221; the package and see how your changes look.<\/li>\n<li>Edit the <code>test-placeholder.R<\/code> file and change the placeholder test it created so it fails and then re-check the package to see what warnings or errors show up.<\/li>\n<li>After you&#8217;ve made (valid, working) modifications to any\/all of the above <em>and package checks pass<\/em>, use either the git command line tools or the RStudio Git pane to add your updates to the git tree. Use the resources linked to in the previous post if you need a refresher on how to do that.<\/li>\n<li>Re-run through all the steps with a brand new package name just to make sure you&#8217;re comfortable with the package creation process.<\/li>\n<\/ul>\n<h3>Up Next<\/h3>\n<p>In the next installment in the series we will start wrapping by creating a basic wrapper that just calls out to the operating system shell to run commands.<\/p>\n<div class=\"footnotes\">\n<hr \/>\n<ol>\n<li id=\"fn-12609-1\">\nEfficient R Programming, &#8220;3.3 R Startup&#8221;; (<a href=\"https:\/\/csgillespie.github.io\/efficientR\/3-3-r-startup.html#r-startup\">https:\/\/csgillespie.github.io\/efficientR\/3-3-r-startup.html#r-startup<\/a>)&#160;<a href=\"#fnref-12609-1\">&#8617;<\/a>\n<\/li>\n<li id=\"fn-12609-2\">\n{roxygen2} Home; (<a href=\"https:\/\/roxygen2.r-lib.org\/\">https:\/\/roxygen2.r-lib.org\/<\/a>)&#160;<a href=\"#fnref-12609-2\">&#8617;<\/a>\n<\/li>\n<li id=\"fn-12609-3\">\n{testthat} Home; (<a href=\"https:\/\/testthat.r-lib.org\/\">https:\/\/testthat.r-lib.org\/<\/a>)&#160;<a href=\"#fnref-12609-3\">&#8617;<\/a>\n<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Before we start wrapping foreign language code we need to make sure that basic R packages can be created. If you&#8217;ve followed along from the previous post you have everything you need to get started here. Just to make sure, you should be able to fire up a new RStudio session and execute the following [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[91],"tags":[],"class_list":["post-12609","post","type-post","status-publish","format-standard","hentry","category-r"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package - rud.is\" \/>\n<meta property=\"og:description\" content=\"Before we start wrapping foreign language code we need to make sure that basic R packages can be created. If you&#8217;ve followed along from the previous post you have everything you need to get started here. Just to make sure, you should be able to fire up a new RStudio session and execute the following [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-03T16:22:02+00:00\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package\",\"datePublished\":\"2020-01-03T16:22:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/\"},\"wordCount\":1406,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"articleSection\":[\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/\",\"name\":\"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"datePublished\":\"2020-01-03T16:22:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2020\\\/01\\\/03\\\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/","og_locale":"en_US","og_type":"article","og_title":"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package - rud.is","og_description":"Before we start wrapping foreign language code we need to make sure that basic R packages can be created. If you&#8217;ve followed along from the previous post you have everything you need to get started here. Just to make sure, you should be able to fire up a new RStudio session and execute the following [&hellip;]","og_url":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/","og_site_name":"rud.is","article_published_time":"2020-01-03T16:22:02+00:00","author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package","datePublished":"2020-01-03T16:22:02+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/"},"wordCount":1406,"commentCount":2,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"articleSection":["R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/","url":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/","name":"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"datePublished":"2020-01-03T16:22:02+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2020\/01\/03\/writing-frictionless-r-package-wrappers-building-a-basic-r-package\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Writing Frictionless R Package Wrappers \u2014 Building A Basic R Package"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p23idr-3hn","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":12586,"url":"https:\/\/rud.is\/b\/2020\/01\/01\/writing-frictionless-r-package-wrappers-introduction\/","url_meta":{"origin":12609,"position":0},"title":"Writing Frictionless R Package Wrappers \u2014 Introduction","author":"hrbrmstr","date":"2020-01-01","format":false,"excerpt":"The R language and RStudio IDE are a powerful combination for \"getting stuff done\", and one aspect of R itself that makes it especially useful is the ability to use it with other programming languages via a robust foreign language interface capability1. The term \"foreign language\" refers to another programming\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3622,"url":"https:\/\/rud.is\/b\/2015\/08\/21\/doh-i-could-have-had-just-used-v8\/","url_meta":{"origin":12609,"position":1},"title":"Doh! I Could Have Had Just Used V8!","author":"hrbrmstr","date":"2015-08-21","format":false,"excerpt":"An R user recently had the need to split a \"full, human name\" into component parts to retrieve first & last names. The full names could be anything from something simple like _\"David Regan\"_ to more complex & diverse such as _\"John Smith Jr.\"_, _\"Izaque Iuzuru Nagata\"_ or _\"Christian Schmit\u2026","rel":"","context":"In &quot;Javascript&quot;","block_context":{"text":"Javascript","link":"https:\/\/rud.is\/b\/category\/javascript\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3642,"url":"https:\/\/rud.is\/b\/2015\/08\/24\/new-pacakge-docxtractr-easily-extract-tables-from-microsoft-word-docs\/","url_meta":{"origin":12609,"position":2},"title":"New Pacakge &#8220;docxtractr&#8221; &#8211; Easily Extract Tables From Microsoft Word Docs","author":"hrbrmstr","date":"2015-08-24","format":false,"excerpt":"UPDATE: `docxtractr` is now [on CRAN](https:\/\/cran.rstudio.com\/web\/packages\/docxtractr\/index.html) --------------------- This is more of a follow-up from [yesterday's post](http:\/\/rud.is\/b\/2015\/08\/23\/using-r-to-get-data-out-of-word-docs\/). The hack and function in said post was fine, but it was limited to uniform tables and made you do more work than you had to. So, there's now a `devtools`-installable package [on github](https:\/\/github.com\/hrbrmstr\/docxtractr)\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3898,"url":"https:\/\/rud.is\/b\/2016\/01\/13\/cobble-xpath-interactively-with-the-xmlview-package\/","url_meta":{"origin":12609,"position":3},"title":"Cobble XPath Interactively with the xmlview Package","author":"hrbrmstr","date":"2016-01-13","format":false,"excerpt":"(If you don't know what XML is, you should probably [read a primer](https:\/\/en.wikipedia.org\/wiki\/XML) before reading this post,) When working with data, one inevitably comes across things encoded in XML. I'm in the \"anti-XML\" camp, but deal with my fair share of XML in \"cyber\" and help out enough people who\u2026","rel":"","context":"In &quot;data wrangling&quot;","block_context":{"text":"data wrangling","link":"https:\/\/rud.is\/b\/category\/data-wrangling\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/01\/RStudioScreenSnapz003.png?fit=865%2C523&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/01\/RStudioScreenSnapz003.png?fit=865%2C523&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/01\/RStudioScreenSnapz003.png?fit=865%2C523&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/01\/RStudioScreenSnapz003.png?fit=865%2C523&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":4217,"url":"https:\/\/rud.is\/b\/2016\/03\/29\/easier-composite-u-s-choropleths-with-albersusa\/","url_meta":{"origin":12609,"position":4},"title":"Easier Composite U.S. Choropleths with albersusa","author":"hrbrmstr","date":"2016-03-29","format":false,"excerpt":"Folks who've been tracking this blog on R-bloggers probably remember [this post](https:\/\/rud.is\/b\/2014\/11\/16\/moving-the-earth-well-alaska-hawaii-with-r\/) where I showed how to create a composite U.S. map with an Albers projection (which is commonly referred to as AlbersUSA these days thanks to D3). I'm not sure why I didn't think of this earlier, but you\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3460,"url":"https:\/\/rud.is\/b\/2015\/06\/15\/metricsgraphics-0-8-5-is-now-on-cran\/","url_meta":{"origin":12609,"position":5},"title":"metricsgraphics 0.8.5 is now on CRAN!","author":"hrbrmstr","date":"2015-06-15","format":false,"excerpt":"I'm super-pleased to announce that the Benevolent CRAN Overlords [accepted the metricsgraphics package](http:\/\/cran.r-project.org\/web\/packages\/metricsgraphics\/index.html) into CRAN over the weekend. Now, you no longer need to rely on github\/devtools to use [MetricsGraphics.js](http:\/\/metricsgraphicsjs.org\/) charts from your R scripts. If you're not familiar with `htmlwidgets`, take a look at [the official site for them](http:\/\/www.htmlwidgets.org\/).\u2026","rel":"","context":"In &quot;d3&quot;","block_context":{"text":"d3","link":"https:\/\/rud.is\/b\/category\/d3\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=12609"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12609\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=12609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=12609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=12609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}