tribe v0.1.6

0

Monthly downloads

0th

Percentile

Play with the Tribe of Attributes

Functions to make manipulation of object attributes easier. It also contains a few functions that extend the 'dplyr' package for data manipulation, and it provides new pipe operators, including the pipe '%@>%' similar to the 'magrittr' '%>%', but with the additional functionality to enable attributes propagation.

Readme

tribe

Travis-CI Build Status

Play with the tribe of attributes in R.

Installation

You can install tribe from GitHub with:

# install.packages("devtools")
devtools::install_github("paulponcet/tribe")

Verbs for easy manipulation of attributes

This package provides verbs for easy manipulation of attributes. These verbs are:

  • define to create or modify attributes;
  • keep to select attributes (and NULLify the others);
  • rebrand to rename attributes;
  • take to extract attributes.

The function tribe is a convenient synonym of attributes, with the slight difference that it always returns a named list.

library(magrittr)
library(tribe)

# Use 'define' to create or modify attributes
df <- data.frame(x = 1:2, y = 2:3) %>%
  define(example="yes", package="dplyr")
tribe(df)

# Use 'take' to extract attribute values
take(df, names)

# 'take_' is the standard evaluation version of 'take'
take_(df, "class")
take_(df, ~ package)

# Similarly 'define_' is the standard evaluation version of 'define'
df <- df %>%
  define_(package = ~ NULL,
          example = ~ "no")
tribe(df)

A new pipe that preserves attributes

The tribe package provides you with a new pipe %@>% that enables propagation of attributes.

library(dplyr)
library(tribe)

df <- data.frame(x = 1:2, y = 2:3) %>%
 define(example="yes",
        package="tribe", 
        class = c("my_tbl", "data.frame"))

# Attributes just created are lost when the object 
# passes through dplyr verbs
tribe(df %>% mutate(z=3))

# With the pipe '%@>%', most attributes are kept
tribe(df %@>% mutate(z=3))

# One can create a new pipe to adjust attributes propagation settings
"%newpipe>%" <- make_pipe(propagate="none", keep_also = "example")
tribe(df %newpipe>% mutate(z=3))

Functions in tribe

Name Description
tribe Object attribute list
at Infix attribute accessor
define Manipulate attributes in a dplyr fashion
make_pipe Create a pipe operator.
shield Attributes protection
stick_to Work on a specific attribute within a pipeline
No Results!

Vignettes of tribe

Name
tribe-vignette.Rmd
No Results!

Last month downloads

Details

Type Package
Date 2017-11-14
License MIT + file LICENSE
LazyData TRUE
VignetteBuilder knitr
URL https://github.com/paulponcet/tribe
BugReports https://github.com/paulponcet/tribe/issues
RoxygenNote 6.0.1
NeedsCompilation no
Packaged 2017-11-14 17:12:04 UTC; YL1101
Repository CRAN
Date/Publication 2017-11-14 18:11:46 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/tribe)](http://www.rdocumentation.org/packages/tribe)