Description Usage Arguments Value Author(s) Examples
Searches for possible equivalents for a desired column in a dataframe and replaces first name match with desired name. Useful when parsing different annotation files which may have standard columns with slightly different names, e.g, Gender=SEX=sex=M/F, or ID=id=ids=samples=subjectID
1 | column.salvage(frame, desired, testfor, ignore.case = TRUE)
|
frame |
a dataframe or matrix with column names |
desired |
the column name wanted |
testfor |
possible alternate forms of the desired column name |
ignore.case |
whether to ignore the upper/lower case of the column names |
returns the original dataframe with the target column renamed
Nicholas Cooper nick.cooper@cimr.cam.ac.uk
1 2 3 4 5 6 7 | df <- data.frame(Sex=c("M","F","F"),time=c(9,12,3),ID=c("ID3121","ID3122","ID2124"))
# standard example
new.df <- column.salvage(df,"sex",c("gender","sex","M/F")); df; new.df
# exact column already present so no change
new.df <- column.salvage(df,"ID",c("ID","id","ids","samples","subjectID")); df; new.df
# ignore case==TRUE potentially results in not finding desired column:
new.df <- column.salvage(df,"sex",c("gender","sex","M/F"),ignore.case=FALSE); df; new.df
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.