Learn R Programming

Lahman (version 2.0-3)

Label: Extract the Label for a Variable

Description

Extracts the label for a variable from one or more of the *Labels files.

Usage

Label(var, labels = rbind(battingLabels, pitchingLabels, fieldingLabels))

Arguments

var
name of a variable
labels
label table(s) to search, a 2-column dataframe containing variable names and labels.

Value

  • Returns the variable label, or var if no label is found

See Also

battingLabels, pitchingLabels, fieldingLabels

Examples

Run this code
require(plyr)
# find and plot maximum number of homers per year
batHR <- ddply(subset(Batting, !is.na(HR)), .(yearID),
		summarise, max=max(HR))
		
with(batHR, {
  plot(yearID, max, 
       xlab=Label("yearID"), ylab=paste("Maximum", Label("HR")), 
       cex=0.8)
  lines(lowess(yearID, max), col="blue", lwd=2)
  abline(lm(max ~ yearID), col="red", lwd=2)
	})

Run the code above in your browser using DataLab