rename() changes the names of individual variables using
new_name = old_name syntax; rename_with() renames columns using a
function.
# S3 method for class 'SummarizedExperiment'
rename(.data, ...)A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.
For rename(): <tidy-select> Use
new_name = old_name to rename selected variables.
For rename_with(): additional arguments passed onto .fn.
An object of the same type as .data. The output has the following
properties:
Rows are not affected.
Column names are changed; column order is preserved.
Data frame attributes are preserved.
Groups are updated to reflect new names.
This function is a generic, which means that packages can provide implementations (methods) for other classes. See the documentation of individual methods for extra arguments and differences in behaviour.
The following methods are currently available in loaded packages:
(vector, Vector), dplyr (data.frame), plotly (plotly), tidySummarizedExperiment (SummarizedExperiment)
.
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., François, R., Henry, L., Müller, K., Vaughan, D. (2023). dplyr: A Grammar of Data Manipulation. R package version 2.1.4, https://CRAN.R-project.org/package=dplyr
data(pasilla)
pasilla |> rename(cond=condition)
#> # A SummarizedExperiment-tibble abstraction: Features=14599 | Samples=7 |
#> # Assays=counts
#> # |------ COVARIATES ----|
#> .feature .sample | counts | cond type |
#> <chr> <chr> | <chr> | <chr> <chr> |
#> 1 FBgn0000003 untrt1 | 0 | untreated single_end |
#> 2 FBgn0000008 untrt1 | 92 | untreated single_end |
#> 3 FBgn0000014 untrt1 | 5 | untreated single_end |
#> 4 FBgn0000015 untrt1 | 0 | untreated single_end |
#> 5 FBgn0000017 untrt1 | 4664 | untreated single_end |
#> -------- ------- - ------ - ---- ---- -
#> 102189 FBgn0261571 trt3 | 0 | treated paired_end |
#> 102190 FBgn0261572 trt3 | 3 | treated paired_end |
#> 102191 FBgn0261573 trt3 | 1908 | treated paired_end |
#> 102192 FBgn0261574 trt3 | 3047 | treated paired_end |
#> 102193 FBgn0261575 trt3 | 4 | treated paired_end |