tidyr-methods: unnest

Description Usage Arguments Value Examples

Description

unnest

nest

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
unnest(
  .data,
  cols,
  ...,
  keep_empty = FALSE,
  ptype = NULL,
  names_sep = NULL,
  names_repair = "check_unique"
)

## Default S3 method:
unnest(
  .data,
  cols,
  ...,
  keep_empty = FALSE,
  ptype = NULL,
  names_sep = NULL,
  names_repair = "check_unique"
)

## S3 method for class 'nested_tidybulk'
unnest(
  .data,
  cols,
  ...,
  keep_empty = FALSE,
  ptype = NULL,
  names_sep = NULL,
  names_repair = "check_unique"
)

nest(.data, ...)

## Default S3 method:
nest(.data, ...)

## S3 method for class 'tidybulk'
nest(.data, ...)

Arguments

.data

A tbl. (See tidyr)

cols

<['tidy-select'][tidyr_tidy_select]> Columns to unnest. If you 'unnest()' multiple columns, parallel entries must be of compatible sizes, i.e. they're either equal or length 1 (following the standard tidyverse recycling rules).

...

Name-variable pairs of the form new_col = c(col1, col2, col3) (See tidyr)

keep_empty

See tidyr::unnest

ptype

See tidyr::unnest

names_sep

If 'NULL', the default, the names will be left as is. In 'nest()', inner names will come from the former outer names; in 'unnest()', the new outer names will come from the inner names.

If a string, the inner and outer names will be used together. In 'nest()', the names of the new outer columns will be formed by pasting together the outer and the inner column names, separated by 'names_sep'. In 'unnest()', the new inner names will have the outer names (+ 'names_sep') automatically stripped. This makes 'names_sep' roughly symmetric between nesting and unnesting.

names_repair

See tidyr::unnest

Value

A tt object

A tt object

Examples

1
2
3
4
5
6
7
library(dplyr)

nest(tidybulk(tidybulk::counts_mini, sample, transcript, count), data = -transcript) %>%
unnest(data)


nest(tidybulk(tidybulk::counts_mini, sample, transcript, count), data = -transcript)

tidybulk documentation built on April 7, 2021, 6 p.m.