View source: R/addVarFromVar.R
addVarFromVar | R Documentation |
Adds a categorical variable to the data slot of a protdata
object based on an exisiting variable.
addVarFromVar(protdata, basecol, name, vector)
protdata |
A |
basecol |
The name of the column in the existing data on which you base your new column. |
name |
The name of the new variable. |
vector |
A vector that contains the values of the new variable with names corresponding to all possible values of the |
A protdata
object with an added column in its data slot containing the new variable.
#Here we show how the columns conc, rep and instrlab were added to the object proteinsCPTAC data(proteinsCPTAC, package="MSqRob") #Add a grouping factor for the spike-in condition (i.e. 6A, 6B, 6C, 6D and 6E) conc <- factor(substr(levels(getData(proteinsCPTAC[1])$run), 11,12)) names(conc) <- levels(getData(proteinsCPTAC[1])$run) proteinsCPTAC <- addVarFromVar(proteinsCPTAC,"run","conc",conc) #Add a grouping factor for each of the 9 technical repeats (i.e. instrument x run) rep <- factor(substr(levels(getData(proteinsCPTAC[1])$run), 14,14)) proteinsCPTAC <- addVarFromVar(proteinsCPTAC,"run","rep",rep) #Add a grouping factor for the instrument effect (i.e. LTQ-Orbitrap at site 86, LTQ-Orbitrap O at site 65 and LTQ-Orbitrap W at site 56) instrlab <- factor((as.numeric(rep)-1)%/%3+1) proteinsCPTAC <- addVarFromVar(proteinsCPTAC,"run","instrlab",instrlab)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.