spread_many: spread_many

Description Usage Arguments Value Examples

View source: R/spread_many.R

Description

Spread more than one column out at once

Usage

1
2
3
4
5
6
7
8
9
spread_many(
  data,
  key_col,
  ...,
  fill = NA,
  convert = TRUE,
  drop = TRUE,
  sep = "_"
)

Arguments

data

data

key_col

key_col

...

List of column, unquoted to spread out

fill

fill

convert

convert

drop

drop

sep

sep

Value

data frame with new columns

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(dplyr)
library(tidyr)

fruits <- data.frame(
  case = c(1, 1, 2, 2),
  fruit = rep(c("Apple", "Orange"), 2),
  height = rnorm(4, 0, 1),
  width = rnorm(4, 0, 2)
)

spread_many(fruits, fruit, width, height)

eringrand/RUncommon documentation built on Sept. 22, 2020, 10:49 p.m.