Learn R Programming

pivot (version 18.4.17)

pivot_query: Create a pivot query representation

Description

Create a pivot table

Usage

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

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab