Learn R Programming

pivot (version 18.4.17)

unpivot: Un-pivot a table

Description

Un-pivot a table

Usage

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::quo_name() (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::quo_name() (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

Run this code
# NOT RUN {
# establish `db` as a database connection

library(dplyr)
library(dbplyr)
# }
# NOT RUN {
    db_iris <- copy_to(db, iris)
# }
# NOT RUN {
long.iris <- unpivot(db_iris, Variable, Value, Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)
sql_render(long.iris)


# }

Run the code above in your browser using DataLab