You get this error because one of your variables is actually a factor variable . Execute
str(df)
to check this. Then do this double variable change to keep the year numbers instead of transforming into "1,2,3,4" level numbers:
df$year <- as.numeric(as.character(df$year))
EDIT: it appears that your data.frame has a variable of class "array" which might cause the pb. Try then:
df <- data.frame(apply(df, 2, unclass))
and plot again?