'dplyr' Verbs for Lists and Other Verbs for Data Frames

Provides 'dplyr' verbs for lists and other useful verbs for manipulation of data frames. In particular, it includes a mutate_which() function that mutates columns for a specific subset of rows defined by a condition, and fuse() which is a more flexible version of 'tidyr' unite() function.


Travis-CI Build Status CRAN_Status_Badge

Installation

You can install 'lplyr' from GitHub with:

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

Verbs for lists and pairlists

The package 'lplyr' extends some dplyr verbs to lists and pairlists:

library(lplyr)
 
xs <- list(x1 = 1:3, 
           x2 = 2:5, 
           x3 = list("alpha", c("beta", "gamma")))
           
mutate(xs, x4 = 4)
rename(xs, x0 = x1)

Usual verbs made for standard evaluation work as well:

mutate_(xs, x4 = ~ 4)
rename_(xs, x0 = ~ x1)

New verbs for data frames

The mutate_which and transmute_which functions are made for adding new variables or modifying existing ones on a subset of the data.

df <- mtcars[1:10,]
mutate_which(df, gear==4, carb = 100)
transmute_which(df, gear==4, carb = 100)

There is also a standard evaluation version of these functions, called mutate_which_ and transmute_which_:

mutate_which_(df, ~ gear==4, carb = ~ 100)
transmute_which_(df, ~ gear==4, carb = ~ 100)

The function pull selects a column in a data frame and transforms it into a vector. This is useful to use it in combination with magrittr's pipe operator and dplyr's verbs.

mtcars[["mpg"]]
mtcars %>% pull(mpg)
 
# more convenient than (mtcars %>% filter(mpg > 20))[[3L]]
mtcars %>%
 filter(mpg > 20) %>%
 pull(3)

News

lplyr 0.1.12

  • 'chunk()' is removed since 'multidplyr' package is no longer on CRAN for R 3.4.X.

lplyr 0.1.11

  • 'select()' functions are removed due to conflicts with the existing 'select.list()' function in package 'utils'.

lplyr 0.1.10

  • drop_narows() function added (not exported for now)

lplyr 0.1.9

  • take() function added

lplyr 0.1.8

  • take() function added

lplyr 0.1.7

  • Issue #2: chunck() now renamed chunk()
  • mutate_if_which() removed for now (not ready yet, and adequate name to be found)

lplyr 0.1.6

  • subset() function removed for now (not ready yet)

lplyr 0.1.5

  • subset() function added

lplyr 0.1.4

  • Test for miniCRAN
  • Changed R file names to clarify what is reexported.
  • Removed chunck() function provisionally.

lplyr 0.1.3

  • Changed 'base2' for 'bazar'

lplyr 0.1.2

  • fuse() function added

lplyr 0.1.1

  • 'dplyr' verbs added for pairlists
  • Updated README.md file
  • Vignette created

lplyr 0.1.0

  • Creation of the package 'lplyr'

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("lplyr")

0.1.12 by Paul Poncet, 7 months ago


https://github.com/paulponcet/lplyr


Report a bug at https://github.com/paulponcet/lplyr/issues


Browse source code at https://github.com/cran/lplyr


Authors: Paul Poncet [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports bazar, dplyr, lazyeval, magrittr

Suggests knitr, rmarkdown, testthat, tidyr


Suggested by tribe.


See at CRAN