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)

About greg

Atmospheric chemistry researcher and university teacher. Data analysis/chemometrics specialist (PCA, PCR, Cluster analysis, SOM)
This entry was posted in r, research and tagged , , . Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>