The R language features a rich set of graphical operations both in its base and in advanced packages such as lattice and ggplot2. Here we go through a very brief introduction to base graphics, in this case for bivariate plots.
Open R and paste in the following code:
library(freqparcoord) data(mlb) head(mlb) # take a look # separate data frames for pitchers and catchers mlbc <- mlb[mlb$PosCategory == 'Catcher',] mlbp <- mlb[mlb$PosCategory == 'Pitcher',] # get mean weights for each height value meanwtc <- tapply(mlbc$Weight,mlbc$Height,mean) meanwtp <- tapply(mlbp$Weight,mlbp$Height,mean) # take a look meanwtc # get the vector of distinct heights htsc <- as.numeric(names(meanwtc)) htsp <- as.numeric(names(meanwtp)) # plot mean wt against ht for pitchers, connected by lines plot(htsp,meanwtp,type='l',col='red') # add in the catchers lines(htsc,meanwtc,col='blue')
Of course, the calls to plot() and lines() are the only graphical operations here.
We see that catchers tend to be "beefier" than "pitchers," heavier at any given height. Also, height range for pitchers is much broader.