r - Density plot/histogram using intervals -


i have range of integer intervals, e.g. [1, 5], [1,3], [3,4] create density plot. suppose want plot of number of intervals overlapping each integer in entire range. using data above might looks this:

    3     x     2 x x x x     1 x x x x x       1 2 3 4 5 

the obvious (and terrible) way can think of doing loop through every interval , add integers single vector, use hist() or similar function create plot. there straightforward way this?

thanks!

you seem proposing this:

x <- list(c(1,5),c(1,3),c(3,4)) hist(unlist(lapply(x,function(z) seq(z[1],z[2]))))          # hist plot(density(unlist(lapply(x,function(z) seq(z[1],z[2]))))) # density 

and yes, - describe - obvious solution.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -