Subsetting made easy

Calculating characteristics such as median, mean,… of a subset of data is quite straightforward in R:

For a data set containing results from several “models”, a subset for the model “base” is created by

base_only <- subset(all, all$model == "base")

Then, the median of the variable “data” can be computed via

median(base_only$data)

Published by

greg

Atmospheric chemistry researcher and university teacher. Data analysis/chemometrics specialist (PCA, PCR, Cluster analysis, SOM)

Leave a Reply

Your email address will not be published. Required fields are marked *