Skip to content
Prev 179766 / 398503 Next

Plotting counts vs. intervals for a shingle

Took a bit of inspecting, looking at hidden functions, but this seems  
to do it:

library(lattice)
  a <- c(1:10, 5:10)
  b <- cbind(c(0,2.5,4.5,6.5), c(5.5,7.5,9.5,11))
  c <- shingle(a, b)
  summary(c, showValues=FALSE)

apply(as.matrix(levels(c)), 1, function(x) length(c[ c>= x[[1]][1] & c  
<= x[[1]][2] ]) )

#[1]  6  8 10  8

"apply" passes a list to the function which requires the "[["  
operation before the index. Since you did not create an example that  
represents the exceptions, i did not test for any such conditions.  
(Why do people not construct proper examples?)