plot(tracts,col=colours[findInterval(tr1$unemployed, breaks$brks, all.inside=T)])
Produces this:
To answer your question specifically:
The reason for the error is that findInteerval(...)
takes as its second argument a vector of numeric. But
breaks<- classIntervals(tr1$unemployed, n=5, style='sd')
produces a list with two elements: 'var' and 'brks'. You need to use breaks$brks
in findInterval(...)
.
Your statement
plot(tr1, col=colours[findInterval(tr1$unemployed, breaks, all.inside=T), axes=F])
attempts to plot tr1
, which is not a map, it's a data frame with 402 rows. You need to plot(tracts,...)
Finally, why do you believe it is difficult to add layers in ggplot??