unpivot: Un-pivot a table

Description Usage Arguments Examples

View source: R/unpivot.R

Description

Un-pivot a table

Usage

1
unpivot(data, key, value, ...)

Arguments

data

A data frame.

key

Names of new key and value columns, as strings or symbols.

This argument is passed by expression and supports quasiquotation (you can unquote strings and symbols). The name is captured from the expression with rlang::ensym() (note that this kind of interface where symbols do not represent actual objects is now discouraged in the tidyverse; we support it here for backward compatibility).

value

Names of new key and value columns, as strings or symbols.

This argument is passed by expression and supports quasiquotation (you can unquote strings and symbols). The name is captured from the expression with rlang::ensym() (note that this kind of interface where symbols do not represent actual objects is now discouraged in the tidyverse; we support it here for backward compatibility).

...

Selection criteria for columns to unpivot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# establish `db` as a database connection

library(dplyr)
library(dbplyr)

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

## End(Not run)
long.iris <- unpivot(db_iris, Variable, Value, Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)
sql_render(long.iris)

halpo/pivot documentation built on Aug. 25, 2019, 12:41 a.m.