Skip to content
Prev 311660 / 398503 Next

Barplot with lines

On 11/23/2012 06:33 PM, Ripples wrote:
Hi SK,
Your alignment problem is due to the way barplot spaces the bars. Try this:

mydata<-read.table(textConnection(
  "emp days val1 val2 score
  1 21 1 0 1200
  2 35 1 1 na
  3 42 na na 3000
  4 53 2 1 2100
  5 64 1 0 na
  6 73 na na 1400"),
  header=TRUE,na.strings="na")
barpos<-barplot(as.matrix(mydata[c(1,2,4,5),c("val1","val2")]))

Then use "barpos" as the x locations of your values for the lines.

Jim