Q:

How can I store the output of summary in a variable?

Consider that the following code:
baseball <- read.csv("c:\\Users\\Jim\\Downloads\\MLB2008.csv", header = T)
summary(baseball$SALARY)

Produces the following output:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  400000   600000  2200000  4349000  6250000 28000000

My Question:

How can I store the contents of 'Median' (i.e. 2200000) in a variable that I can use later?

For instance, instead of:
baseball$Salary_GTE_THAN_MEDIAN <- as.numeric(2200000<=baseball$SALARY)

I'd like to write:
baseball$Salary_GTE_THAN_MEDIAN <- as.numeric(median_salary<=baseball$SALARY)

A:

we can subset the summary output by the names of the output.
median_salary <- summary(baseball$SALARY)['Median']
baseball$Salary_GTE_THAN_MEDIAN <- as.numeric(median_salary<=baseball$SALARY)

Using a reproducible example
data(iris)
Med <- summary(iris$Sepal.Length)['Median']
Med <= iris$Sepal.Length

