SyntaxFix
Write A Post
Hire A Developer
Questions
Take a look at ?legend and try this:
?legend
legend('topright', names(a)[-1] , lty=1, col=c('red', 'blue', 'green',' brown'), bty='n', cex=.75)