Description Usage Arguments Value Note Author(s) Examples
View source: R/createCategorical.R
This function allows the user to create new variables derived from actual input or output data stored in a NONMEM object or a data.frame. The function "bins" the data in a user-chosen manner. The new "binned" variable will be added to the "additionalVars" data frame of the object, or as a new column if the object is a data.frame. The methods for creating the categorical variables are:
unique:Variable is coerced into a factor with no "binning" at all
explicitcuts:The user supplies "cut points" for partitioning the data
range:The user specifies a number of cut points, and they are the generated by cutting the range of the values of the variable into the given number
logrange:As above, but done by range of the log of the variable
counts:User specifies number of cut points, and the bins are then generated so that the bins have equal amounts of data
1 2 | addDerivedCategorical(obj, varName, newVar=paste(varName, ".CUT", sep = ""),
breaks=5, binType="range", labels, ...)
|
obj |
An object of class NMBasicModel, NMRun, NMSimModel, NMSimDataGen or data.frame |
varName |
The variable to "bin" |
newVar |
The name of the new variable |
breaks |
The number of breaks |
binType |
The type of "binning" |
labels |
The labels for the "bins" |
... |
Additional arguments that apply to different classes. These are dataType which specifies what data to use, i.e input or output, for NMBasicModel, NMRun, NMSimModel and NMSimDataGen, and problemNum which specifies the required run for an NMRun object |
A new object with a user-specified "binned" variable added
If the binType
is counts
and calculation of quantiles generates duplicates, a warning will be eliminated and the duplicates
will be discarded.
Mango Solutions
1 2 | x <- addDerivedCategorical(mtcars, "mpg", breaks = 6, binType = "counts" )
show(x$mpg.CUT)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.