## Read in Asia City Temperature Data (.csv format with headers) asia <- read.csv("http://users.stat.ufl.edu/~winner/sta6329/asia_temp_city.csv") attach(asia); names(asia) head(asia) tail(asia) ## Note that the data are sorted by month first, then by cityID ## We want the rows to be Months, so use byrow=TRUE option temp.mat <- matrix(tempF, byrow=TRUE, 12,12) ## QR decomposition qr.temp <- qr(temp.mat) qr.temp.R <- qr.R(qr.temp) qr.temp.Q <- qr.Q(qr.temp) detach(asia) ## Read in New York Yankees 1927 game data (table format without headers) nyy <- read.table("http://users.stat.ufl.edu/~winner/data/yankees1927team1.dat", header=F, col.names=c("oppTeam", "nyyPitcher", "oppPitcher", "home", "gameNum", "nyyRuns", "oppRuns", "gameDayNum", "offDays", "gameDate")) attach(nyy) head(nyy) tail(nyy) gameDates <- as.Date(gameDate, "%m/%d/%Y") summary(nyyRuns) plot((nyyRuns-oppRuns), type="l") ## line plot (aka time-series plot) abline(h=0, col="red", lwd=2) max(gameDates) - min(gameDates) # Length of season detach(nyy) ## Read in 2104 NFL Combine Data in fixed with format (.fwf, without headers) ## Player Name - Columns 1-25 (25 columns) ## College - 26-47 (22 columns) ## Position - 48-55 (8 cols) ## ... ## 20 Yard Shuttle 136-143 (8 cols) ## There are 12 variables that are in 8 column format combine <- read.fwf("http://users.stat.ufl.edu/~winner/data/nfl_combine_2014.dat", header=F, widths=c(25,22,rep(8,12)), col.names = c("player", "college","position","grade","height", "armLen","weight","handLen","time40","bench", "vertJmp","brdJmp","cone","shuttle")) attach(combine) head(combine) tail(combine) BMI <- 703*weight/height^2 plot(BMI ~ position) mean(time40) mean(time40, na.rm=T) length(player) ## Create a data frame with only players with full data comb.full <- na.omit(combine) detach(combine) attach(comb.full) length(player) plot(bench, time40)