R/tidyr_methods.R
separate-methods.Rd
Given either a regular expression or a vector of character positions,
separate()
turns a single character column into multiple columns.
Separator between columns.
If character, sep
is interpreted as a regular expression. The default
value is a regular expression that matches any sequence of
non-alphanumeric values.
If numeric, sep
is interpreted as character positions to split at. Positive
values start at 1 at the far-left of the string; negative value start at -1 at
the far-right of the string. The length of sep
should be one less than
into
.
If sep
is a character vector, this controls what
happens when there are too many pieces. There are three valid options:
"warn" (the default): emit a warning and drop extra values.
"drop": drop any extra values without a warning.
"merge": only splits at most length(into)
times
If sep
is a character vector, this controls what
happens when there are not enough pieces. There are three valid options:
"warn" (the default): emit a warning and fill from the right
"right": fill with missing values on the right
"left": fill with missing values on the left
A tidySingleCellExperiment objector a tibble depending on input
un <- pbmc_small %>%
unite("new_col", c(orig.ident, groups))
un %>% separate(col=new_col, into=c("orig.ident", "groups"))
#> # A SingleCellExperiment-tibble abstraction: 80 × 17
#> # Features=230 | Cells=80 | Assays=counts, logcounts
#> .cell orig.ident groups nCount_RNA nFeature_RNA RNA_snn_res.0.8 letter.idents
#> <chr> <chr> <chr> <dbl> <int> <fct> <fct>
#> 1 ATGC… SeuratPro… g2 70 47 0 A
#> 2 CATG… SeuratPro… g1 85 52 0 A
#> 3 GAAC… SeuratPro… g2 87 50 1 B
#> 4 TGAC… SeuratPro… g2 127 56 0 A
#> 5 AGTC… SeuratPro… g2 173 53 0 A
#> 6 TCTG… SeuratPro… g1 70 48 0 A
#> 7 TGGT… SeuratPro… g1 64 36 0 A
#> 8 GCAG… SeuratPro… g1 72 45 0 A
#> 9 GATA… SeuratPro… g1 52 36 0 A
#> 10 AATG… SeuratPro… g1 100 41 0 A
#> # ℹ 70 more rows
#> # ℹ 10 more variables: RNA_snn_res.1 <fct>, file <chr>, ident <fct>,
#> # PC_1 <dbl>, PC_2 <dbl>, PC_3 <dbl>, PC_4 <dbl>, PC_5 <dbl>, tSNE_1 <dbl>,
#> # tSNE_2 <dbl>