pivot_query: Create a pivot query representation

Description Usage Arguments Examples

Description

Create a pivot table

Usage

1
2
pivot_query(from, key, value, levels, select = ident(), order_by = NULL,
  fill = NULL)

Arguments

from

the from clause

key

Variable columns originate from

value

The expression to evaluate to create the values

levels

the levels of key to turn into columns.

select

variables to select in addition to levels.

order_by

optional order by clause

fill

optional value to fill in structural missing values. It is the responsibility of the user to ensure type compatibility.

Examples

1
2
3
4
5
6
7
8
9
library(dplyr)
library(dbplyr)
con <- simulate_mssql()

query <- pivot_query( ident('##iris'), key = ident('Species')
                    , levels = ident(c('setosa', 'virginica', 'versicolor'))
                    , value  = rlang::quo(mean(Petal.Length, na.rm=TRUE))
                    )
sql_render(query, con=con)

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