magrittr: magrittr - a Forward-Pipe Operator for R

Description Usage Arguments Details Contact Demonstration See Also Examples

Description

An extended pipe operator %>% from magrittr package version 1.0.1. Enables archiving artifacts with their chaining code - see examples and vignettes.

Usage

1
lhs %a% rhs

Arguments

lhs

An artifact that will be used as an argument of rhs by %a% operator.

rhs

A function call using lhs as an argument by %a% operator.

Details

The extension works as follows, the result of %a% operator is archived together with lhs (as an artifact) and rhs (as a Tag). This allows to present a history of an artifact. This option works only if a default repository is set.

Contact

Bug reports and feature requests can be sent to https://github.com/pbiecek/archivist/issues

Demonstration

This function is well explained on this http://r-bloggers.com/r-hero-saves-backup-city-with-archivist-and-github blog post.

See Also

Other archivist: Repository, Tags, addHooksToPrint, addTagsRepo, aformat, ahistory, alink, aoptions, archivist-package, areadLocal, aread, asearchLocal, asearch, asession, atrace, cache, copyLocalRepo, createLocalRepo, createMDGallery, deleteLocalRepo, getRemoteHook, getTagsLocal, loadFromLocalRepo, md5hash, removeTagsRepo, restoreLibs, rmFromLocalRepo, saveToLocalRepo, searchInLocalRepo, setLocalRepo, shinySearchInLocalRepo, showLocalRepo, splitTagsLocal, summaryLocalRepo, zipLocalRepo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 

library("dplyr")

## Usage of %a% operator without setting default repository
# We will receive sepcial warning
iris %a% summary()

## Archiving artifacts with their chaining code
# Creating empty repository
exampleRepoDir <- tempfile()
createLocalRepo( exampleRepoDir, default = TRUE ) # Remember to set repo to default

# Start using %a% operator
data("hflights", package = "hflights")
hflights %a%
  group_by(Year, Month, DayofMonth) %a%
  select(Year:DayofMonth, ArrDelay, DepDelay) %a%
  summarise(arr = mean(ArrDelay, na.rm = TRUE),
            dep = mean(DepDelay, na.rm = TRUE)) %a%
  filter(arr > 30 | dep > 30)
  
# Let's check how Tags of subsequent artifacts look like
showLocalRepo()
getTagsLocal("a8ce013a8e66df222be278122423dc60", tag = "") #1
getTagsLocal("9d91fe67fd51f3bfdc9db0a596b12b38", tag = "") #2
getTagsLocal("617ded4953ac986524a1c24703363980", tag = "") #3
getTagsLocal("3f1ac0a27485be5d52e1b0a41d165abc", tag = "") #4
getTagsLocal("0cb04315482de73d7f5a1081953236f8", tag = "") #5
getTagsLocal("5629bc43e36d219b613076b17c665eda", tag = "") #6

# Deleting existing repository
deleteLocalRepo(exampleRepoDir, deleteRoot = TRUE)
rm(exampleRepoDir) 

## End(Not run)

archivist documentation built on Aug. 31, 2019, 5:05 p.m.