UCLA Academic Technology Services HomeServicesClassesContactJobs

Box plot

The examples here are created using R 2.6.2 for Windows XP. It uses the standard graphics package that R loads automatically when it starts.

The examples use hsb2 data set that can be downloaded as follows.

hsb2 <- read.table('http://www.ats.ucla.edu/stat/r/modules/hsb2.csv', header=T, sep=",")
attach(hsb2)


boxplot(write)

 

boxplot(write, xlab="write", boxwex=.4, 
        col="darkblue")
 
 

 

boxplot(write ~ ses)

 

seslab<-as.vector(c("low","medium", "high"))
sesf<-factor(ses, label=seslab)
boxplot(write ~ sesf, xlab="write by ses")

 

boxplot(write ~ sesf, xlab="write by ses", 
        boxwex=.2, notch = TRUE, 
        col = "darkblue")

		

 

# by two factors
boxplot(write ~ female + ses, 
        xlab="write by female and ses", 
        boxwex=.2)
 

 

   

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.