Introduction to roxygen2 Aime Gott Education Practice Lead, Mango - - PowerPoint PPT Presentation

introduction to roxygen2
SMART_READER_LITE
LIVE PREVIEW

Introduction to roxygen2 Aime Gott Education Practice Lead, Mango - - PowerPoint PPT Presentation

DataCamp Developing R Packages DEVELOPING R PACKAGES Introduction to roxygen2 Aime Gott Education Practice Lead, Mango Solutions DataCamp Developing R Packages Help files DataCamp Developing R Packages roxygen headers DataCamp


slide-1
SLIDE 1

DataCamp Developing R Packages

Introduction to roxygen2

DEVELOPING R PACKAGES

Aimée Gott

Education Practice Lead, Mango Solutions

slide-2
SLIDE 2

DataCamp Developing R Packages

Help files

slide-3
SLIDE 3

DataCamp Developing R Packages

roxygen headers

slide-4
SLIDE 4

DataCamp Developing R Packages

Title

slide-5
SLIDE 5

DataCamp Developing R Packages

Description

slide-6
SLIDE 6

DataCamp Developing R Packages

Details

slide-7
SLIDE 7

DataCamp Developing R Packages

Arguments

slide-8
SLIDE 8

DataCamp Developing R Packages

Imports

slide-9
SLIDE 9

DataCamp Developing R Packages

Let's practice!

DEVELOPING R PACKAGES

slide-10
SLIDE 10

DataCamp Developing R Packages

What Does Exporting a Function Mean and Why Do It?

DEVELOPING R PACKAGES

Nic Crane

Data Science Consultant, Mango Solutions

slide-11
SLIDE 11

DataCamp Developing R Packages

Exported Functions

Exported functions: visible to the end user key package functionality Non-exported functions: not visible to end user utility functions

slide-12
SLIDE 12

DataCamp Developing R Packages

Exported and Non Exported Functions

#' Count NAs in a vector #' #' @param x A vector #' #' @return Number of NAs in x #' #' @examples #' sumNa(airquality$Ozone) sum_na <- function(x) { sum(is.na(x)) }

slide-13
SLIDE 13

DataCamp Developing R Packages

Exported and Non Exported Functions

slide-14
SLIDE 14

DataCamp Developing R Packages

Exported and Non-Exported Functions

library(simutils) na_counter(airquality) Ozone Solar.R Wind Temp Month Day 37 7 0 0 0 0

slide-15
SLIDE 15

DataCamp Developing R Packages

Calling Non-Exported Functions

library(simutils) sum_na(airquality$Ozone) Error: could not find function "sum_na"

slide-16
SLIDE 16

DataCamp Developing R Packages

Calling Non-Exported Functions

simutils:::sum_na(airquality$Ozone)

slide-17
SLIDE 17

DataCamp Developing R Packages

Exporting Functions with roxygen Headers

slide-18
SLIDE 18

DataCamp Developing R Packages

Let's practice!

DEVELOPING R PACKAGES

slide-19
SLIDE 19

DataCamp Developing R Packages

What Other Elements Can We Document with roxygen Headers?

DEVELOPING R PACKAGES

Aimée Gott

Education Practice Lead, Mango Solutions

slide-20
SLIDE 20

DataCamp Developing R Packages

Documenting Examples

slide-21
SLIDE 21

DataCamp Developing R Packages

Non-Running Examples

slide-22
SLIDE 22

DataCamp Developing R Packages

Documenting Function Return Values

slide-23
SLIDE 23

DataCamp Developing R Packages

Additional Documentation

slide-24
SLIDE 24

DataCamp Developing R Packages

Let's practice!

DEVELOPING R PACKAGES

slide-25
SLIDE 25

DataCamp Developing R Packages

Documenting a Package

DEVELOPING R PACKAGES

Nic Crane

Data Science Consultant, Mango Solutions

slide-26
SLIDE 26

DataCamp Developing R Packages

Package Level Documentation

slide-27
SLIDE 27

DataCamp Developing R Packages

Minimum Level of Documentation

For each function, document: Title Description Arguments Exported (for exported functions only)

slide-28
SLIDE 28

DataCamp Developing R Packages

Documenting Data Objects

use_data(sim_dat, pkg = "simutils")

slide-29
SLIDE 29

DataCamp Developing R Packages

Documenting Data Objects

slide-30
SLIDE 30

DataCamp Developing R Packages

Creating man Files

document("simutils")

slide-31
SLIDE 31

DataCamp Developing R Packages

Let's practice!

DEVELOPING R PACKAGES