I am using the solution in this question to try to plot a bar plot with specified intervals:
Create categorical variable in R based on range
I created my intervals and tried to use them in the barplot
function but I am obviously missing a step somewhere and I'm not sure how to get it to work. Here is my code and the error I am getting:
> library(lattice)
> a = c(0,10)
> b = c(11,20)
> c = c(21,30)
> d = c(31,40)
> e = c(41,50)
> f = c(51,60)
> g = c(61,70)
> h = c(71,80)
> i = c(81,90)
> j = c(91,100)
> k = c(101,120)
> l = c(121,150)
> m = c(151,200)
> n = c(201,500)
> o = c(501,3600)
> mybins = matrix(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o), ncol=2)
> shx <- shingle(data5$q3totalScleralLensesFit, intervals=mybins)
> shx
Intervals:
min max count
1 0 10 140
2 11 20 117
3 21 30 78
4 31 40 31
5 41 50 72
6 51 60 5
7 61 70 6
8 71 80 28
9 81 90 3
10 91 100 49
11 101 120 7
12 121 150 28
13 151 200 25
14 201 500 61
15 501 3600 28
> bp <- barplot(shx, main="", xlab="", ylim=c(0,160), ylab="", las=2, cex.names=0.75)
Error in barplot.default(shx, main = "", xlab = "", ylim = c(0, 160), :
'height' must be a vector or a matrix
I don't know how to fix the error. Is there an easier way to make bins like this for a barplot or does someone have any suggestions on how to make the intervals work with barplot?
Thank you!