You can use the split function to split the data frame in groups based for example in the Treatment variable. Head(df) Plant Type Treatment conc uptake Consider the following data frame: set.seed(3) You can split a data set in subsets based on one or more variables that represents groups of the data. Hence, you can split the vector in two vectors where the elements are of the same group, passing the names of the vector with the names function to the argument f. Suppose you have a named vector, where the name of each element corresponds to the group the element belongs.