R/tidyr_methods.R
extract.Rdextract() has been superseded in favour of separate_wider_regex()
because it has a more polished API and better handling of problems.
Superseded functions will not go away, but will only receive critical bug
fixes.
Given a regular expression with capturing groups, extract() turns
each group into a new column. If the groups don't match, or the input
is NA, the output will be NA.
# S3 method for class 'SummarizedExperiment'
extract(
data,
col,
into,
regex = "([[:alnum:]]+)",
remove = TRUE,
convert = FALSE,
...
)A data frame.
<tidy-select> Column to expand.
Names of new variables to create as character vector.
Use NA to omit the variable in the output.
A string representing a regular expression used to extract the
desired values. There should be one group (defined by ()) for each
element of into.
If TRUE, remove input column from output data frame.
If TRUE, will run type.convert() with
as.is = TRUE on new columns. This is useful if the component
columns are integer, numeric or logical.
NB: this will cause string "NA"s to be converted to NAs.
Additional arguments passed on to methods.
tidySummarizedExperiment
Hutchison, W.J., Keyes, T.J., The tidyomics Consortium. et al. The tidyomics ecosystem: enhancing omic data analyses. Nat Methods 21, 1166–1170 (2024). https://doi.org/10.1038/s41592-024-02299-2
Wickham, H., Vaughan, D. (2023). tidyr: Tidy Messy Data. R package version 2.0.0, https://CRAN.R-project.org/package=tidyr
separate() to split up by a separator.
tidySummarizedExperiment::pasilla |>
extract(type, into="sequencing", regex="([a-z]*)_end", convert=TRUE)
#> class: SummarizedExperiment
#> dim: 14599 7
#> metadata(0):
#> assays(1): counts
#> rownames(14599): FBgn0000003 FBgn0000008 ... FBgn0261574 FBgn0261575
#> rowData names(0):
#> colnames(7): untrt1 untrt2 ... trt2 trt3
#> colData names(2): condition sequencing