blob: 61f0c11d3cc0937ce572422d411391feacd2ff50 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en" data-content_root="" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>R tutorials &#8212; Apache Arrow v17.0.0.dev59</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
<!-- Loaded before other Sphinx assets -->
<link href="../../../_static/styles/theme.css?digest=8d27b9dea8ad943066ae" rel="stylesheet" />
<link href="../../../_static/styles/bootstrap.css?digest=8d27b9dea8ad943066ae" rel="stylesheet" />
<link href="../../../_static/styles/pydata-sphinx-theme.css?digest=8d27b9dea8ad943066ae" rel="stylesheet" />
<link href="../../../_static/vendor/fontawesome/6.5.1/css/all.min.css?digest=8d27b9dea8ad943066ae" rel="stylesheet" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../_static/vendor/fontawesome/6.5.1/webfonts/fa-solid-900.woff2" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../_static/vendor/fontawesome/6.5.1/webfonts/fa-brands-400.woff2" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../_static/vendor/fontawesome/6.5.1/webfonts/fa-regular-400.woff2" />
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/design-style.1e8bd061cd6da7fc9cf755528e8ffc24.min.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/theme_overrides.css" />
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../../../_static/scripts/bootstrap.js?digest=8d27b9dea8ad943066ae" />
<link rel="preload" as="script" href="../../../_static/scripts/pydata-sphinx-theme.js?digest=8d27b9dea8ad943066ae" />
<script src="../../../_static/vendor/fontawesome/6.5.1/js/all.min.js?digest=8d27b9dea8ad943066ae"></script>
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/sphinx_highlight.js"></script>
<script src="../../../_static/clipboard.min.js"></script>
<script src="../../../_static/copybutton.js"></script>
<script src="../../../_static/design-tabs.js"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'developers/guide/tutorials/r_tutorial';</script>
<script>
DOCUMENTATION_OPTIONS.theme_version = '0.15.2';
DOCUMENTATION_OPTIONS.theme_switcher_json_url = '/docs/_static/versions.json';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = 'dev/';
DOCUMENTATION_OPTIONS.show_version_warning_banner = true;
</script>
<link rel="canonical" href="https://arrow.apache.org/docs/developers/guide/tutorials/r_tutorial.html" />
<link rel="icon" href="../../../_static/favicon.ico"/>
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
<link rel="next" title="Additional information and resources" href="../resources.html" />
<link rel="prev" title="Python tutorial" href="python_tutorial.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
/* We explicitly disable cookie tracking to avoid privacy issues */
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '20']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">
<a id="pst-skip-link" class="skip-link" href="#main-content">Skip to main content</a>
<div id="pst-scroll-pixel-helper"></div>
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
<i class="fa-solid fa-arrow-up"></i>
Back to top
</button>
<input type="checkbox"
class="sidebar-toggle"
name="__primary"
id="__primary"/>
<label class="overlay overlay-primary" for="__primary"></label>
<input type="checkbox"
class="sidebar-toggle"
name="__secondary"
id="__secondary"/>
<label class="overlay overlay-secondary" for="__secondary"></label>
<div class="search-button__wrapper">
<div class="search-button__overlay"></div>
<div class="search-button__search-container">
<form class="bd-search d-flex align-items-center"
action="../../../search.html"
method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search"
class="form-control"
name="q"
id="search-input"
placeholder="Search the docs ..."
aria-label="Search the docs ..."
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form></div>
</div>
<header class="bd-header navbar navbar-expand-lg bd-navbar">
<div class="bd-header__inner bd-page-width">
<label class="sidebar-toggle primary-toggle" for="__primary">
<span class="fa-solid fa-bars"></span>
</label>
<div class="col-lg-3 navbar-header-items__start">
<div class="navbar-item">
<a class="navbar-brand logo" href="../../../index.html">
<img src="../../../_static/arrow.png" class="logo__image only-light" alt="Apache Arrow v17.0.0.dev59 - Home"/>
<script>document.write(`<img src="../../../_static/arrow-dark.png" class="logo__image only-dark" alt="Apache Arrow v17.0.0.dev59 - Home"/>`);</script>
</a></div>
</div>
<div class="col-lg-9 navbar-header-items">
<div class="me-auto navbar-header-items__center">
<div class="navbar-item">
<nav class="navbar-nav">
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item">
<a class="nav-link nav-internal" href="../../../format/index.html">
Specifications
</a>
</li>
<li class="nav-item current active">
<a class="nav-link nav-internal" href="../../index.html">
Development
</a>
</li>
<li class="nav-item dropdown">
<button class="btn dropdown-toggle nav-item" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-controls="pst-nav-more-links">
Implementations
</button>
<ul id="pst-nav-more-links" class="dropdown-menu">
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../c_glib/index.html">
C/GLib
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../cpp/index.html">
C++
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://github.com/apache/arrow/blob/main/csharp/README.md">
C#
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://pkg.go.dev/github.com/apache/arrow/go/v17">
Go
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../java/index.html">
Java
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../js/index.html">
JavaScript
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/julia/">
Julia
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://github.com/apache/arrow/blob/main/matlab/README.md">
MATLAB
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/nanoarrow/">
nanoarrow
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../python/index.html">
Python
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../r/index.html">
R
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://github.com/apache/arrow/blob/main/ruby/README.md">
Ruby
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://docs.rs/crate/arrow/">
Rust
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../status.html">
Implementation Status
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/cpp/">
C++ cookbook
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/java/">
Java cookbook
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/py/">
Python cookbook
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/r/">
R cookbook
</a>
</li>
</ul>
</li>
</ul>
</nav></div>
</div>
<div class="navbar-header-items__end">
<div class="navbar-item navbar-persistent--container">
<script>
document.write(`
<button class="btn navbar-btn search-button-field search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
<span class="search-button__default-text">Search</span>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
`);
</script>
</div>
<div class="navbar-item">
<script>
document.write(`
<div class="version-switcher__container dropdown">
<button id="pst-version-switcher-button-2"
type="button"
class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="pst-version-switcher-list-2"
aria-label="Version switcher list"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div id="pst-version-switcher-list-2"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="pst-version-switcher-button-2">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
`);
</script></div>
<div class="navbar-item">
<script>
document.write(`
<button class="btn btn-sm navbar-btn theme-switch-button" title="light/dark" aria-label="light/dark" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="theme-switch nav-link" data-mode="light"><i class="fa-solid fa-sun fa-lg"></i></span>
<span class="theme-switch nav-link" data-mode="dark"><i class="fa-solid fa-moon fa-lg"></i></span>
<span class="theme-switch nav-link" data-mode="auto"><i class="fa-solid fa-circle-half-stroke fa-lg"></i></span>
</button>
`);
</script></div>
<div class="navbar-item"><ul class="navbar-icon-links navbar-nav"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/apache/arrow" title="GitHub" class="nav-link" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><span><i class="fa-brands fa-square-github fa-lg" aria-hidden="true"></i></span>
<span class="sr-only">GitHub</span></a>
</li>
<li class="nav-item">
<a href="https://twitter.com/ApacheArrow" title="X" class="nav-link" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><span><i class="fa-brands fa-square-x-twitter fa-lg" aria-hidden="true"></i></span>
<span class="sr-only">X</span></a>
</li>
</ul></div>
</div>
</div>
<div class="navbar-persistent--mobile">
<script>
document.write(`
<button class="btn navbar-btn search-button-field search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
<span class="search-button__default-text">Search</span>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
`);
</script>
</div>
<label class="sidebar-toggle secondary-toggle" for="__secondary" tabindex="0">
<span class="fa-solid fa-outdent"></span>
</label>
</div>
</header>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<div class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
<div class="sidebar-header-items__center">
<div class="navbar-item">
<nav class="navbar-nav">
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item">
<a class="nav-link nav-internal" href="../../../format/index.html">
Specifications
</a>
</li>
<li class="nav-item current active">
<a class="nav-link nav-internal" href="../../index.html">
Development
</a>
</li>
<li class="nav-item dropdown">
<button class="btn dropdown-toggle nav-item" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-controls="pst-nav-more-links-2">
Implementations
</button>
<ul id="pst-nav-more-links-2" class="dropdown-menu">
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../c_glib/index.html">
C/GLib
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../cpp/index.html">
C++
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://github.com/apache/arrow/blob/main/csharp/README.md">
C#
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://pkg.go.dev/github.com/apache/arrow/go/v17">
Go
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../java/index.html">
Java
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../js/index.html">
JavaScript
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/julia/">
Julia
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://github.com/apache/arrow/blob/main/matlab/README.md">
MATLAB
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/nanoarrow/">
nanoarrow
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../python/index.html">
Python
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../r/index.html">
R
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://github.com/apache/arrow/blob/main/ruby/README.md">
Ruby
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://docs.rs/crate/arrow/">
Rust
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="../../../status.html">
Implementation Status
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/cpp/">
C++ cookbook
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/java/">
Java cookbook
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/py/">
Python cookbook
</a>
</li>
<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://arrow.apache.org/cookbook/r/">
R cookbook
</a>
</li>
</ul>
</li>
</ul>
</nav></div>
</div>
<div class="sidebar-header-items__end">
<div class="navbar-item">
<script>
document.write(`
<div class="version-switcher__container dropdown">
<button id="pst-version-switcher-button-3"
type="button"
class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="pst-version-switcher-list-3"
aria-label="Version switcher list"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div id="pst-version-switcher-list-3"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="pst-version-switcher-button-3">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
`);
</script></div>
<div class="navbar-item">
<script>
document.write(`
<button class="btn btn-sm navbar-btn theme-switch-button" title="light/dark" aria-label="light/dark" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="theme-switch nav-link" data-mode="light"><i class="fa-solid fa-sun fa-lg"></i></span>
<span class="theme-switch nav-link" data-mode="dark"><i class="fa-solid fa-moon fa-lg"></i></span>
<span class="theme-switch nav-link" data-mode="auto"><i class="fa-solid fa-circle-half-stroke fa-lg"></i></span>
</button>
`);
</script></div>
<div class="navbar-item"><ul class="navbar-icon-links navbar-nav"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/apache/arrow" title="GitHub" class="nav-link" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><span><i class="fa-brands fa-square-github fa-lg" aria-hidden="true"></i></span>
<span class="sr-only">GitHub</span></a>
</li>
<li class="nav-item">
<a href="https://twitter.com/ApacheArrow" title="X" class="nav-link" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><span><i class="fa-brands fa-square-x-twitter fa-lg" aria-hidden="true"></i></span>
<span class="sr-only">X</span></a>
</li>
</ul></div>
</div>
</div>
<div class="sidebar-primary-items__start sidebar-primary__section">
<div class="sidebar-primary-item">
<nav class="bd-docs-nav bd-links"
aria-label="Section Navigation">
<p class="bd-links__title" role="heading" aria-level="1">Section Navigation</p>
<div class="bd-toc-item navbar-nav"><ul class="current nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="../../bug_reports.html">Bug reports and feature requests</a></li>
<li class="toctree-l1 current active has-children"><a class="reference internal" href="../index.html">New Contributor’s Guide</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-1"><i class="fa-solid fa-chevron-down"></i></label><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../architectural_overview.html">Architectural Overview</a></li>
<li class="toctree-l2"><a class="reference internal" href="../communication.html">Communication</a></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="../step_by_step/index.html">Steps in making your first PR</a><input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-2"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../step_by_step/set_up.html">Set up</a></li>
<li class="toctree-l3"><a class="reference internal" href="../step_by_step/building.html">Building the Arrow libraries 🏋🏿‍♀️</a></li>
<li class="toctree-l3"><a class="reference internal" href="../step_by_step/finding_issues.html">Finding good first issues 🔎</a></li>
<li class="toctree-l3"><a class="reference internal" href="../step_by_step/arrow_codebase.html">Working on the Arrow codebase 🧐</a></li>
<li class="toctree-l3"><a class="reference internal" href="../step_by_step/testing.html">Testing 🧪</a></li>
<li class="toctree-l3"><a class="reference internal" href="../step_by_step/styling.html">Styling 😎</a></li>
<li class="toctree-l3"><a class="reference internal" href="../step_by_step/pr_lifecycle.html">Lifecycle of a pull request</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../documentation.html">Helping with documentation</a></li>
<li class="toctree-l2 current active has-children"><a class="reference internal" href="index.html">Tutorials</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-3" name="toctree-checkbox-3" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-3"><i class="fa-solid fa-chevron-down"></i></label><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="python_tutorial.html">Python tutorial</a></li>
<li class="toctree-l3 current active"><a class="current reference internal" href="#">R tutorials</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../resources.html">Additional information and resources</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../overview.html">Contributing Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../reviewing.html">Reviewing contributions</a></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../cpp/index.html">C++ Development</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../cpp/building.html">Building Arrow C++</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cpp/development.html">Development Guidelines</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cpp/windows.html">Developing on Windows</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cpp/emscripten.html">Cross compiling for WebAssembly with Emscripten</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cpp/conventions.html">Conventions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../cpp/fuzzing.html">Fuzzing Arrow C++</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../java/index.html">Java Development</a><input class="toctree-checkbox" id="toctree-checkbox-5" name="toctree-checkbox-5" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-5"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../java/building.html">Building Arrow Java</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../java/development.html">Development Guidelines</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../python.html">Python Development</a></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../continuous_integration/index.html">Continuous Integration</a><input class="toctree-checkbox" id="toctree-checkbox-6" name="toctree-checkbox-6" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-6"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../continuous_integration/overview.html">Continuous Integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../continuous_integration/docker.html">Running Docker Builds</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../continuous_integration/archery.html">Daily Development using Archery</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../continuous_integration/crossbow.html">Packaging and Testing with Crossbow</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../benchmarks.html">Benchmarks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../documentation.html">Building the Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../release.html">Release Management Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../release_verification.html">Release Verification Process</a></li>
</ul>
</div>
</nav></div>
</div>
<div class="sidebar-primary-items__end sidebar-primary__section">
</div>
<div id="rtd-footer-container"></div>
</div>
<main id="main-content" class="bd-main">
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article">
<div class="header-article-items header-article__inner">
<div class="header-article-items__start">
<div class="header-article-item">
<nav aria-label="Breadcrumb">
<ul class="bd-breadcrumbs">
<li class="breadcrumb-item breadcrumb-home">
<a href="../../../index.html" class="nav-link" aria-label="Home">
<i class="fa-solid fa-home"></i>
</a>
</li>
<li class="breadcrumb-item"><a href="../../index.html" class="nav-link">Development</a></li>
<li class="breadcrumb-item"><i class="fa-solid fa-ellipsis"></i></li>
<li class="breadcrumb-item"><a href="index.html" class="nav-link">Tutorials</a></li>
<li class="breadcrumb-item active" aria-current="page">R tutorials</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="searchbox"></div>
<article class="bd-article">
<section id="r-tutorials">
<span id="r-tutorial"></span><h1>R tutorials<a class="headerlink" href="#r-tutorials" title="Permalink to this heading">#</a></h1>
<section id="writing-bindings-walkthrough">
<h2>Writing Bindings Walkthrough<a class="headerlink" href="#writing-bindings-walkthrough" title="Permalink to this heading">#</a></h2>
<p>The first R package tutorial to be included in the New Contributor’s
guide is a <strong>Walkthrough</strong> added in the <strong>Writing Bindings</strong>
vignette. With time we will try to include additional tutorials
directly into this guide.</p>
<p>This tutorial will show how to do a binding of a C++ function
<a class="reference external" href="https://arrow.apache.org/docs/cpp/compute.html#containment-tests">starts_with()</a>
to the (base) R function <code class="docutils literal notranslate"><span class="pre">startsWith()</span></code>.</p>
<p>To view the tutorial follow the
<a class="reference external" href="https://arrow.apache.org/docs/r/articles/developers/bindings.html#walkthrough">Walkthrough section of the Writing Bindings article</a>.</p>
</section>
<section id="r-tutorial-on-adding-a-lubridate-binding">
<h2>R tutorial on adding a lubridate binding<a class="headerlink" href="#r-tutorial-on-adding-a-lubridate-binding" title="Permalink to this heading">#</a></h2>
<p>In this tutorial, we will document the contribution of a binding
to Arrow R package following the steps specified by the
<a class="reference internal" href="../index.html#quick-ref-guide"><span class="std std-ref">Quick Reference</span></a> section of the guide and a more detailed
<a class="reference internal" href="../step_by_step/index.html#step-by-step"><span class="std std-ref">Steps in making your first PR</span></a> section. Navigate there whenever there is
some information you may find is missing here.</p>
<p>The binding will be added to the <code class="docutils literal notranslate"><span class="pre">expression.R</span></code> file in the
R package. But you can also follow these steps in case you are
adding a binding that will live somewhere else.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>To read more about the philosophy behind R bindings, refer to the
<a class="reference external" href="https://arrow.apache.org/docs/r/articles/developers/bindings.html">Writing Bindings article</a>.</p>
</div>
<p>This tutorial is different from the <a class="reference internal" href="../step_by_step/index.html#step-by-step"><span class="std std-ref">Steps in making your first PR</span></a> as we
will be working on a specific case. This tutorial is not meant
as a step-by-step guide.</p>
<p><strong>Let’s start!</strong></p>
<section id="set-up">
<h3>Set up<a class="headerlink" href="#set-up" title="Permalink to this heading">#</a></h3>
<p>Let’s set up the Arrow repository. We presume here that Git is
already installed. Otherwise please see the <a class="reference internal" href="../step_by_step/set_up.html#set-up"><span class="std std-ref">Set up</span></a> section.</p>
<p>Once the <a class="reference external" href="https://github.com/apache/arrow">Apache Arrow repository</a>
is forked (see <a class="reference internal" href="../step_by_step/set_up.html#fork-repo-guide"><span class="std std-ref">Fork the repository</span></a>) we will clone it and add the
link of the main repository to our upstream.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>clone<span class="w"> </span>https://github.com/&lt;your<span class="w"> </span>username&gt;/arrow.git
<span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span>arrow
<span class="gp">$ </span>git<span class="w"> </span>remote<span class="w"> </span>add<span class="w"> </span>upstream<span class="w"> </span>https://github.com/apache/arrow
</pre></div>
</div>
</section>
<section id="building-r-package">
<h3>Building R package<a class="headerlink" href="#building-r-package" title="Permalink to this heading">#</a></h3>
<p>The steps to follow for building the R package differs depending on the operating
system you are using. For this reason we will only refer to
the instructions for the building process in this tutorial.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>For the <strong>introduction</strong> to the building process refer to the
<a class="reference internal" href="../step_by_step/building.html#build-arrow-guide"><span class="std std-ref">Building the Arrow libraries 🏋🏿‍♀️</span></a> section.</p>
<p>For the <strong>instructions</strong> on how to build the R package refer to the
<a class="reference external" href="https://arrow.apache.org/docs/r/articles/developing.html">R developer docs</a>.</p>
</div>
</section>
<section id="the-issue">
<h3>The issue<a class="headerlink" href="#the-issue" title="Permalink to this heading">#</a></h3>
<p>In this tutorial we will be tackling an issue for implementing
a simple binding for <code class="docutils literal notranslate"><span class="pre">mday()</span></code> function that will match that of the
existing R function from <code class="docutils literal notranslate"><span class="pre">lubridate</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you do not have an issue and you need help finding one please refer
to the <a class="reference internal" href="../step_by_step/finding_issues.html#finding-issues"><span class="std std-ref">Finding good first issues 🔎</span></a> part of the guide.</p>
</div>
<p>Once you have an issue picked out and assigned to yourself, you can
proceed to the next step.</p>
</section>
<section id="start-the-work-on-a-new-branch">
<h3>Start the work on a new branch<a class="headerlink" href="#start-the-work-on-a-new-branch" title="Permalink to this heading">#</a></h3>
<p>Before we start working on adding the binding we should
create a new branch from the updated main.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>checkout<span class="w"> </span>main
<span class="gp">$ </span>git<span class="w"> </span>fetch<span class="w"> </span>upstream
<span class="gp">$ </span>git<span class="w"> </span>pull<span class="w"> </span>--ff-only<span class="w"> </span>upstream<span class="w"> </span>main
<span class="gp">$ </span>git<span class="w"> </span>checkout<span class="w"> </span>-b<span class="w"> </span>ARROW-14816
</pre></div>
</div>
<p>Now we can start with researching the R function and the C++ Arrow
compute function we want to expose or connect to.</p>
<p><strong>Examine the lubridate mday() function</strong></p>
<p>Going through the <a class="reference external" href="https://lubridate.tidyverse.org/reference/day.html">lubridate documentation</a>
we can see that <code class="docutils literal notranslate"><span class="pre">mday()</span></code> takes a date object
and returns the day of the month as a numeric object.</p>
<p>We can run some examples in the R console to help us understand
the function better:</p>
<div class="highlight-R notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span><span class="w"> </span><span class="nf">library</span><span class="p">(</span><span class="n">lubridate</span><span class="p">)</span>
<span class="o">&gt;</span><span class="w"> </span><span class="nf">mday</span><span class="p">(</span><span class="nf">as.Date</span><span class="p">(</span><span class="s">&quot;2000-12-31&quot;</span><span class="p">))</span>
<span class="p">[</span><span class="m">1</span><span class="p">]</span><span class="w"> </span><span class="m">31</span>
<span class="o">&gt;</span><span class="w"> </span><span class="nf">mday</span><span class="p">(</span><span class="nf">ymd</span><span class="p">(</span><span class="m">080306</span><span class="p">))</span>
<span class="p">[</span><span class="m">1</span><span class="p">]</span><span class="w"> </span><span class="m">6</span>
</pre></div>
</div>
<p><strong>Examine the Arrow C++ day() function</strong></p>
<p>From the <a class="reference external" href="https://arrow.apache.org/docs/cpp/compute.html#containment-tests">compute function documentation</a>
we can see that <code class="docutils literal notranslate"><span class="pre">day</span></code> is a unary function, which means that it takes
a single data input. The data input must be a <code class="docutils literal notranslate"><span class="pre">Temporal</span> <span class="pre">class</span></code> and
the returned value is an <code class="docutils literal notranslate"><span class="pre">Integer/numeric</span></code> type.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">Temporal</span> <span class="pre">class</span></code> is specified as: Date types (Date32, Date64),
Time types (Time32, Time64), Timestamp, Duration, Interval.</p>
<p>We can call an Arrow C++ function from an R console using <code class="docutils literal notranslate"><span class="pre">call_function</span></code>
to see how it works:</p>
<div class="highlight-R notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span><span class="w"> </span><span class="nf">call_function</span><span class="p">(</span><span class="s">&quot;day&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">Scalar</span><span class="o">$</span><span class="nf">create</span><span class="p">(</span><span class="n">lubridate</span><span class="o">::</span><span class="nf">ymd</span><span class="p">(</span><span class="s">&quot;2000-12-31&quot;</span><span class="p">)))</span>
<span class="n">Scalar</span>
<span class="m">31</span>
</pre></div>
</div>
<p>We can see that lubridate and Arrow functions operate on and return
equivalent data types. lubridate’s <code class="docutils literal notranslate"><span class="pre">mday()</span></code> function has no additional
arguments and there are also no option classes associated with Arrow C++
function <code class="docutils literal notranslate"><span class="pre">day()</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>To see what to do if there is an option class associated with the
function you are binding, refer to
<a class="reference external" href="https://arrow.apache.org/docs/r/articles/developers/bindings.html#examining-the-c-function">Examining the C++ function</a> from the Writing Bindings
article.</p>
</div>
<p>Looking at the code in <code class="docutils literal notranslate"><span class="pre">expressions.R</span></code> we can see the day function
is already specified/mapped on the R package side:
<a class="github reference external" href="https://github.com/apache/arrow/blob/658bec37aa5cbdd53b5e4cdc81b8ba3962e67f11/r/R/expression.R#L63-L64">apache/arrow</a></p>
<p>We only need to add <code class="docutils literal notranslate"><span class="pre">mday()</span></code> to the list of expressions connecting
it to the C++ <code class="docutils literal notranslate"><span class="pre">day</span></code> function.</p>
<div class="highlight-R notranslate"><div class="highlight"><pre><span></span><span class="c1"># second is defined in dplyr-functions.R</span>
<span class="c1"># wday is defined in dplyr-functions.R</span>
<span class="s">&quot;mday&quot;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;day&quot;</span><span class="p">,</span>
<span class="s">&quot;yday&quot;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;day_of_year&quot;</span><span class="p">,</span>
<span class="s">&quot;year&quot;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;year&quot;</span><span class="p">,</span>
</pre></div>
</div>
</section>
<section id="adding-a-test">
<h3>Adding a test<a class="headerlink" href="#adding-a-test" title="Permalink to this heading">#</a></h3>
<p>Now we need to add a test that checks if everything works well.
If there are additional options or edge cases, we would have to
add more. Looking at tests for similar functions (for example
<code class="docutils literal notranslate"><span class="pre">yday()</span></code> or <code class="docutils literal notranslate"><span class="pre">day())</span></code> we can see that a good place to add two
tests we have is in <code class="docutils literal notranslate"><span class="pre">test-dplyr-funcs-datetime.R</span></code>:</p>
<div class="highlight-R notranslate"><div class="highlight"><pre><span></span><span class="nf">test_that</span><span class="p">(</span><span class="s">&quot;extract mday from timestamp&quot;</span><span class="p">,</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nf">compare_dplyr_binding</span><span class="p">(</span>
<span class="w"> </span><span class="n">.input</span><span class="w"> </span><span class="o">%&gt;%</span>
<span class="w"> </span><span class="nf">mutate</span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">mday</span><span class="p">(</span><span class="n">datetime</span><span class="p">))</span><span class="w"> </span><span class="o">%&gt;%</span>
<span class="w"> </span><span class="nf">collect</span><span class="p">(),</span>
<span class="w"> </span><span class="n">test_df</span>
<span class="w"> </span><span class="p">)</span>
<span class="p">})</span>
</pre></div>
</div>
<p>And</p>
<div class="highlight-R notranslate"><div class="highlight"><pre><span></span><span class="nf">test_that</span><span class="p">(</span><span class="s">&quot;extract mday from date&quot;</span><span class="p">,</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nf">compare_dplyr_binding</span><span class="p">(</span>
<span class="w"> </span><span class="n">.input</span><span class="w"> </span><span class="o">%&gt;%</span>
<span class="w"> </span><span class="nf">mutate</span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">mday</span><span class="p">(</span><span class="n">date</span><span class="p">))</span><span class="w"> </span><span class="o">%&gt;%</span>
<span class="w"> </span><span class="nf">collect</span><span class="p">(),</span>
<span class="w"> </span><span class="n">test_df</span>
<span class="w"> </span><span class="p">)</span>
<span class="p">})</span>
</pre></div>
</div>
<p>Now we need to see if the tests are passing or we need to do some
more research and code corrections.</p>
<div class="highlight-R notranslate"><div class="highlight"><pre><span></span><span class="n">devtools</span><span class="o">::</span><span class="nf">test</span><span class="p">(</span><span class="n">filter</span><span class="o">=</span><span class="s">&quot;datetime&quot;</span><span class="p">)</span>
<span class="o">&gt;</span><span class="w"> </span><span class="n">devtools</span><span class="o">::</span><span class="nf">test</span><span class="p">(</span><span class="n">filter</span><span class="o">=</span><span class="s">&quot;datetime&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="n">Loading</span><span class="w"> </span><span class="n">arrow</span>
<span class="n">See</span><span class="w"> </span><span class="nf">arrow_info</span><span class="p">()</span><span class="w"> </span><span class="n">for</span><span class="w"> </span><span class="n">available</span><span class="w"> </span><span class="n">features</span>
<span class="w"> </span><span class="n">Testing</span><span class="w"> </span><span class="n">arrow</span>
<span class="n">See</span><span class="w"> </span><span class="nf">arrow_info</span><span class="p">()</span><span class="w"> </span><span class="n">for</span><span class="w"> </span><span class="n">available</span><span class="w"> </span><span class="n">features</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="bp">F</span><span class="w"> </span><span class="n">W</span><span class="w"> </span><span class="n">S</span><span class="w"> </span><span class="n">OK</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">Context</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="m">230</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">dplyr</span><span class="o">-</span><span class="n">funcs</span><span class="o">-</span><span class="n">datetime</span><span class="w"> </span><span class="p">[</span><span class="m">1.4</span><span class="n">s</span><span class="p">]</span>
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
<span class="nf">Failure </span><span class="p">(</span><span class="n">test</span><span class="o">-</span><span class="n">dplyr</span><span class="o">-</span><span class="n">funcs</span><span class="o">-</span><span class="n">datetime.R</span><span class="o">:</span><span class="m">187</span><span class="o">:</span><span class="m">3</span><span class="p">)</span><span class="o">:</span><span class="w"> </span><span class="n">strftime</span>
<span class="n">``</span><span class="o">%&gt;%</span><span class="n">`(...)`</span><span class="w"> </span><span class="n">did</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">throw</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">expected</span><span class="w"> </span><span class="n">error.</span>
<span class="n">Backtrace</span><span class="o">:</span>
<span class="w"> </span><span class="m">1</span><span class="n">.</span><span class="w"> </span><span class="n">testthat</span><span class="o">::</span><span class="nf">expect_error</span><span class="p">(</span><span class="kc">...</span><span class="p">)</span><span class="w"> </span><span class="n">test</span><span class="o">-</span><span class="n">dplyr</span><span class="o">-</span><span class="n">funcs</span><span class="o">-</span><span class="n">datetime.R</span><span class="o">:</span><span class="m">187</span><span class="o">:</span><span class="m">2</span>
<span class="w"> </span><span class="m">2</span><span class="n">.</span><span class="w"> </span><span class="n">testthat</span><span class="o">:::</span><span class="nf">expect_condition_matching</span><span class="p">(</span><span class="kc">...</span><span class="p">)</span>
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
══<span class="w"> </span><span class="n">Results</span><span class="w"> </span>═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
<span class="n">Duration</span><span class="o">:</span><span class="w"> </span><span class="m">1.4</span><span class="w"> </span><span class="n">s</span>
<span class="p">[</span><span class="w"> </span><span class="n">FAIL</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">WARN</span><span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">SKIP</span><span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">PASS</span><span class="w"> </span><span class="m">230</span><span class="w"> </span><span class="p">]</span>
</pre></div>
</div>
<p>There is a failure we get for the <code class="docutils literal notranslate"><span class="pre">strftime</span></code> function but looking
at the code we see is not connected to our work. We can move on and
maybe ask others if they are getting similar fail when running the tests.
It could be we only need to rebuild the library.</p>
</section>
<section id="check-styling">
<h3>Check styling<a class="headerlink" href="#check-styling" title="Permalink to this heading">#</a></h3>
<p>We should also run linters to check that the styling of the code
follows the <a class="reference external" href="https://style.tidyverse.org/">tidyverse style</a>. To
do that we run the following command in the shell:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>make<span class="w"> </span>style
<span class="go">R -s -e &#39;setwd(&quot;..&quot;); if (requireNamespace(&quot;styler&quot;)) styler::style_file(setdiff(system(&quot;git diff --name-only | grep r/.*R$&quot;, intern = TRUE), file.path(&quot;r&quot;, source(&quot;r/.styler_excludes.R&quot;)$value)))&#39;</span>
<span class="go">Loading required namespace: styler</span>
<span class="go">Styling 2 files:</span>
<span class="go"> r/R/expression.R ✔</span>
<span class="go"> r/tests/testthat/test-dplyr-funcs-datetime.R ℹ</span>
<span class="go">────────────────────────────────────────────</span>
<span class="go">Status Count Legend</span>
<span class="go">✔ 1 File unchanged.</span>
<span class="go">ℹ 1 File changed.</span>
<span class="go">✖ 0 Styling threw an error.</span>
<span class="go">────────────────────────────────────────────</span>
<span class="go">Please review the changes carefully!</span>
</pre></div>
</div>
</section>
<section id="creating-a-pull-request">
<h3>Creating a Pull Request<a class="headerlink" href="#creating-a-pull-request" title="Permalink to this heading">#</a></h3>
<p>First let’s review our changes in the shell using <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">status</span></code> to see
which files have been changed and to commit only the ones we are working on.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>status
<span class="go">On branch ARROW-14816</span>
<span class="go">Changes not staged for commit:</span>
<span class="go"> (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)</span>
<span class="go"> (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)</span>
<span class="go"> modified: R/expression.R</span>
<span class="go"> modified: tests/testthat/test-dplyr-funcs-datetime.R</span>
</pre></div>
</div>
<p>And <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">diff</span></code> to see the changes in the files in order to spot any error we might have made.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>diff
<span class="go">diff --git a/r/R/expression.R b/r/R/expression.R</span>
<span class="go">index 37fc21c25..0e71803ec 100644</span>
<span class="go">--- a/r/R/expression.R</span>
<span class="go">+++ b/r/R/expression.R</span>
<span class="go">@@ -70,6 +70,7 @@</span>
<span class="go"> &quot;quarter&quot; = &quot;quarter&quot;,</span>
<span class="gp"> # </span>second<span class="w"> </span>is<span class="w"> </span>defined<span class="w"> </span><span class="k">in</span><span class="w"> </span>dplyr-functions.R
<span class="gp"> # </span>wday<span class="w"> </span>is<span class="w"> </span>defined<span class="w"> </span><span class="k">in</span><span class="w"> </span>dplyr-functions.R
<span class="go">+ &quot;mday&quot; = &quot;day&quot;,</span>
<span class="go"> &quot;yday&quot; = &quot;day_of_year&quot;,</span>
<span class="go"> &quot;year&quot; = &quot;year&quot;,</span>
<span class="go">diff --git a/r/tests/testthat/test-dplyr-funcs-datetime.R b/r/tests/testthat/test-dplyr-funcs-datetime.R</span>
<span class="go">index 359a5403a..228eca56a 100644</span>
<span class="go">--- a/r/tests/testthat/test-dplyr-funcs-datetime.R</span>
<span class="go">+++ b/r/tests/testthat/test-dplyr-funcs-datetime.R</span>
<span class="go">@@ -444,6 +444,15 @@ test_that(&quot;extract wday from timestamp&quot;, {</span>
<span class="go"> )</span>
<span class="go"> })</span>
<span class="go">+test_that(&quot;extract mday from timestamp&quot;, {</span>
<span class="go">+ compare_dplyr_binding(</span>
<span class="go">+ .input %&gt;%</span>
<span class="go">+ mutate(x = mday(datetime)) %&gt;%</span>
<span class="go">+ collect(),</span>
<span class="go">+ test_df</span>
<span class="go">+ )</span>
<span class="go">+})</span>
<span class="go">+</span>
<span class="go"> test_that(&quot;extract yday from timestamp&quot;, {</span>
<span class="go"> compare_dplyr_binding(</span>
<span class="go"> .input %&gt;%</span>
<span class="go">@@ -626,6 +635,15 @@ test_that(&quot;extract wday from date&quot;, {</span>
<span class="go"> )</span>
<span class="go"> })</span>
<span class="go">+test_that(&quot;extract mday from date&quot;, {</span>
<span class="go">+ compare_dplyr_binding(</span>
<span class="go">+ .input %&gt;%</span>
<span class="go">+ mutate(x = mday(date)) %&gt;%</span>
<span class="go">+ collect(),</span>
<span class="go">+ test_df</span>
<span class="go">+ )</span>
<span class="go">+})</span>
<span class="go">+</span>
<span class="go"> test_that(&quot;extract yday from date&quot;, {</span>
<span class="go"> compare_dplyr_binding(</span>
<span class="go"> .input %&gt;%</span>
</pre></div>
</div>
<p>Everything looks OK. Now we can make the commit
(save our changes to the branch history):</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>commit<span class="w"> </span>-am<span class="w"> </span><span class="s2">&quot;Adding a binding and a test for mday() lubridate&quot;</span>
<span class="go">[ARROW-14816 ed37d3a3b] Adding a binding and a test for mday() lubridate</span>
<span class="go"> 2 files changed, 19 insertions(+)</span>
</pre></div>
</div>
<p>We can use <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">log</span></code> to check the history of commits:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>log
<span class="go">commit ed37d3a3b3eef76b696532f10562fea85f809fab (HEAD -&gt; ARROW-14816)</span>
<span class="go">Author: Alenka Frim &lt;frim.alenka@gmail.com&gt;</span>
<span class="go">Date: Fri Jan 21 09:15:31 2022 +0100</span>
<span class="go"> Adding a binding and a test for mday() lubridate</span>
<span class="go">commit c5358787ee8f7b80f067292f49e5f032854041b9 (upstream/main, upstream/HEAD, main, ARROW-15346, ARROW-10643)</span>
<span class="go">Author: Krisztián Szűcs &lt;szucs.krisztian@gmail.com&gt;</span>
<span class="go">Date: Thu Jan 20 09:45:59 2022 +0900</span>
<span class="go"> ARROW-15372: [C++][Gandiva] Gandiva now depends on boost/crc.hpp which is missing from the trimmed boost archive</span>
<span class="go"> See build error https://github.com/ursacomputing/crossbow/runs/4871392838?check_suite_focus=true#step:5:11762</span>
<span class="go"> Closes #12190 from kszucs/ARROW-15372</span>
<span class="go"> Authored-by: Krisztián Szűcs &lt;szucs.krisztian@gmail.com&gt;</span>
<span class="go"> Signed-off-by: Sutou Kouhei &lt;kou@clear-code.com&gt;</span>
</pre></div>
</div>
<p>If we started the branch some time ago, we may need to rebase
to upstream main to make sure there are no merge conflicts:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>pull<span class="w"> </span>upstream<span class="w"> </span>main<span class="w"> </span>--rebase
</pre></div>
</div>
<p>And now we can push our work to the forked Arrow repository
on GitHub called origin.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>push<span class="w"> </span>origin<span class="w"> </span>ARROW-14816
<span class="go">Enumerating objects: 233, done.</span>
<span class="go">Counting objects: 100% (233/233), done.</span>
<span class="go">Delta compression using up to 8 threads</span>
<span class="go">Compressing objects: 100% (130/130), done.</span>
<span class="go">Writing objects: 100% (151/151), 35.78 KiB | 8.95 MiB/s, done.</span>
<span class="go">Total 151 (delta 129), reused 33 (delta 20), pack-reused 0</span>
<span class="go">remote: Resolving deltas: 100% (129/129), completed with 80 local objects.</span>
<span class="go">remote:</span>
<span class="go">remote: Create a pull request for &#39;ARROW-14816&#39; on GitHub by visiting:</span>
<span class="go">remote: https://github.com/AlenkaF/arrow/pull/new/ARROW-14816</span>
<span class="go">remote:</span>
<span class="go">To https://github.com/AlenkaF/arrow.git</span>
<span class="go"> * [new branch] ARROW-14816 -&gt; ARROW-14816</span>
</pre></div>
</div>
<p>Now we have to go to the <a class="reference external" href="https://github.com/apache/arrow">Arrow repository on GitHub</a>
to create a Pull Request. On the GitHub Arrow
page (main or forked) we will see a yellow notice
bar with a note that we made recent pushes to the branch
ARROW-14816. That’s great, now we can make the Pull Request
by clicking on <strong>Compare &amp; pull request</strong>.</p>
<figure class="align-default" id="id1">
<a class="reference internal image-reference" href="../../../_images/R_tutorial_create_pr_notice.jpeg"><img alt="GitHub page of the Apache Arrow repository showing a notice bar indicating change has been made in our branch and a Pull Request can be created." src="../../../_images/R_tutorial_create_pr_notice.jpeg" style="width: 835.1999999999999px; height: 510.0px;" /></a>
<figcaption>
<p><span class="caption-text">Notice bar on the Apache Arrow repository.</span><a class="headerlink" href="#id1" title="Permalink to this image">#</a></p>
</figcaption>
</figure>
<p>First we need to change the Title to <strong>ARROW-14816: [R] Implement
bindings for lubridate::mday()</strong> in order to match it with the
issue. Note a punctuation mark was added!</p>
<p><em>Extra note: when this tutorial was created, we had been using the Jira issue
tracker. As we are currently using GitHub issues, the title would be prefixed
with GH-14816: [R] Implement bindings for lubridate::mday()</em>.</p>
<p>We will also add a description to make it clear to others what we are trying to do.</p>
<figure class="align-default" id="id2">
<a class="reference internal image-reference" href="../../../_images/R_tutorial_pr_descr.jpeg"><img alt="GitHub page of the Pull Request showing the editor for the title and a description." src="../../../_images/R_tutorial_pr_descr.jpeg" style="width: 785.5px; height: 852.0px;" /></a>
<figcaption>
<p><span class="caption-text">Editing the title and the description of our Pull Request.</span><a class="headerlink" href="#id2" title="Permalink to this image">#</a></p>
</figcaption>
</figure>
<p>Once we click <strong>Create pull request</strong> our code can be reviewed as
a Pull Request in the Apache Arrow repository.</p>
<figure class="align-default" id="id3">
<a class="reference internal image-reference" href="../../../_images/R_tutorial_pr.jpeg"><img alt="GitHub page of the Pull Request showing the title and a description." src="../../../_images/R_tutorial_pr.jpeg" style="width: 785.5px; height: 852.0px;" /></a>
<figcaption>
<p><span class="caption-text">Here it is, our Pull Request!</span><a class="headerlink" href="#id3" title="Permalink to this image">#</a></p>
</figcaption>
</figure>
<p>The pull request gets connected to the issue and the CI is running.
After some time passes and we get a review we can correct the code,
comment, resolve conversations and so on.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>For more information about Pull Request workflow see <a class="reference internal" href="../step_by_step/pr_lifecycle.html#pr-lifecycle"><span class="std std-ref">Lifecycle of a pull request</span></a>.</p>
</div>
<p>The Pull Request we made can be viewed <a class="reference external" href="https://github.com/apache/arrow/pull/12218">here</a>.</p>
</section>
</section>
</section>
</article>
<footer class="prev-next-footer">
<div class="prev-next-area">
<a class="left-prev"
href="python_tutorial.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">Python tutorial</p>
</div>
</a>
<a class="right-next"
href="../resources.html"
title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Additional information and resources</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>
</div>
</footer>
</div>
<div class="bd-sidebar-secondary bd-toc"><div class="sidebar-secondary-items sidebar-secondary__inner">
<div class="sidebar-secondary-item">
<div
id="pst-page-navigation-heading-2"
class="page-toc tocsection onthispage">
<i class="fa-solid fa-list"></i> On this page
</div>
<nav class="bd-toc-nav page-toc" aria-labelledby="pst-page-navigation-heading-2">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#writing-bindings-walkthrough">Writing Bindings Walkthrough</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#r-tutorial-on-adding-a-lubridate-binding">R tutorial on adding a lubridate binding</a><ul class="visible nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#set-up">Set up</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#building-r-package">Building R package</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#the-issue">The issue</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#start-the-work-on-a-new-branch">Start the work on a new branch</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#adding-a-test">Adding a test</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#check-styling">Check styling</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#creating-a-pull-request">Creating a Pull Request</a></li>
</ul>
</li>
</ul>
</nav></div>
<div class="sidebar-secondary-item">
<div class="tocsection editthispage">
<a href="https://github.com/apache/arrow/edit/main/docs/source/developers/guide/tutorials/r_tutorial.rst">
<i class="fa-solid fa-pencil"></i>
Edit on GitHub
</a>
</div>
</div>
</div></div>
</div>
<footer class="bd-footer-content">
</footer>
</main>
</div>
</div>
<!-- Scripts loaded after <body> so the DOM is not blocked -->
<script src="../../../_static/scripts/bootstrap.js?digest=8d27b9dea8ad943066ae"></script>
<script src="../../../_static/scripts/pydata-sphinx-theme.js?digest=8d27b9dea8ad943066ae"></script>
<footer class="bd-footer">
<div class="bd-footer__inner bd-page-width">
<div class="footer-items__start">
<div class="footer-item">
<p class="copyright">
© Copyright 2016-2024 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache feather logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
<br/>
</p>
</div>
<div class="footer-item">
<p class="sphinx-version">
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 6.2.0.
<br/>
</p>
</div>
</div>
<div class="footer-items__end">
<div class="footer-item">
<p class="theme-version">
Built with the <a href="https://pydata-sphinx-theme.readthedocs.io/en/stable/index.html">PyData Sphinx Theme</a> 0.15.2.
</p></div>
</div>
</div>
</footer>
</body>
</html>