Hi, I'm trying to recreate my graph with the instructions in last night's video. However, after I index the years the plot is returning an error that my x and y are not the same length. Where am I going wrong?
Code for indexing the year:
ave.so <- Teams$SO / Teams$G
year <- (Teams$yearID )
# min and max values needed to create your plot window
ave.so.min <- min( ave.so, na.rm=T )
ave.so.max <- max( ave.so, na.rm=T )
# the league average for each season
league.ave <- tapply( X=ave.so, INDEX=as.factor(year), FUN="mean", na.rm=T )
league.year <- as.numeric( names( league.ave ) )
# Truncate years to >=1900 & <=2012
index <- which(year >=1900 & year <=2012)
year <- year[index]
ave.so < ave.so[index]
index2 <-which(league.year >=1900 & league.year <=2012)
league.year <- league.year[index2]
league.ave <- league.ave[index2]
Hi, I'm trying to recreate my graph with the instructions in last night's video. However, after I index the years the plot is returning an error that my x and y are not the same length. Where am I going wrong? Code for indexing the year:
Code for plots: plot.new() plot.window(xlim=c(1900, 1980), ylim=c(ave.so.min, ave.so.max)) points( year, ave.so )
error: Error in xy.coords(x, y) : 'x' and 'y' lengths differ