pivot: Pivot a table

Description Usage Arguments Examples

Description

Pivot a table

Usage

1
pivot(data, key, value, ..., fill = NULL)

Arguments

data

A data frame.

key

Column names or positions. This is passed to tidyselect::vars_pull().

These arguments are passed by expression and support quasiquotation (you can unquote column names or column positions).

value

Column names or positions. This is passed to tidyselect::vars_pull().

These arguments are passed by expression and support quasiquotation (you can unquote column names or column positions).

...

Selection criteria for levels of key to select.

fill

If set, missing values will be replaced with this value. Note that there are two types of missingness in the input: explicit missing values (i.e. NA), and implicit missings, rows that simply aren't present. Both types of missing value will be replaced by fill.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(dplyr)
library(dbplyr)
# establish db as a database connection

## Not run: 
db_iris <- copy_to(db, iris)

## End(Not run)
result <- pivot( db_iris, Species, mean(Petal.Length, na.rm=TRUE)
               , setosa, versicolor, virginica)
sql_render(result)

pivot documentation built on May 2, 2019, 2:02 p.m.