renameColumn | R Documentation |
Rename columns in a data.frame, matrix, tibble, or GRanges object
renameColumn(x, from, to, verbose = FALSE, ...)
x |
|
from |
|
to |
|
This function is intended to rename one or more columns in a
data.frame
, matrix
, tibble, or GRanges
related object.
It will gracefully ignore columns which do not match,
in order to make it possible to call the
function again without problem.
This function will also recognize input objects GRanges
,
ucscData
, and IRanges
, which store annotation in DataFrame
accessible via IRanges::values()
. Note the IRanges
package
is required, for its generic function values()
.
The values supplied in to
and from
are converted from factor
to character
to avoid coersion by R to integer
, which was
noted in output prior to jamba version 0.0.72.900
.
data.frame
or object equivalent to the input x
,
with columns from
renamed to values in to
. For genomic
ranges objects such as GRanges
and IRanges
, the colnames
are updated in IRanges::values(x)
.
Other jam practical functions:
breakDensity()
,
checkLightMode()
,
check_pkg_installed()
,
colNum2excelName()
,
color_dither()
,
diff_functions()
,
exp2signed()
,
fileInfo()
,
fixYellow()
,
getAxisLabel()
,
handleArgsText()
,
heads()
,
isFALSEV()
,
isTRUEV()
,
jamba
,
jargs()
,
kable_coloring()
,
lldf()
,
log2signed()
,
make_html_styles()
,
make_styles()
,
match_unique()
,
mergeAllXY()
,
middle()
,
minorLogTicks()
,
newestFile()
,
printDebug()
,
rmInfinite()
,
rmNAs()
,
rmNA()
,
rmNULL()
,
sclass()
,
sdim()
,
setPrompt()
df <- data.frame(A=1:5, B=6:10, C=11:15);
df;
df2 <- renameColumn(df,
from=c("A","C"),
to=c("a_new", "c_new"));
df2;
df3 <- renameColumn(df2,
from=c("A","C","B"),
to=c("a_new", "c_new","b_new"));
df3;
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.