Hello list:) I have lots of values which I would like to get a histogram outline out of. An example of what I am talking about: testdata = runif(100) bbb = seq(0,1, by = 0.01) hist(testdata, breaks = bbb) I would like to get the outline of the resulting histogram. Now, I think that I can do this using the stepfun function. However, I am uncertain of how to get to the data the stepfun function require.>From ?stepfunArguments: x: numeric vector giving the knots or jump locations of the step function for 'stepfun()'. For the other functions, 'x' is as 'object' below. y: numeric vector one longer than 'x', giving the heights of the function values _between_ the x values. X I think is the same as bbb above. I am however uncertain of how I would go about getting the data needed for y, given that the data I have is on the same format as testdata above is. Thanks for your help! Karin -- Karin Lagesen, PhD student karin.lagesen at medisin.uio.no http://folk.uio.no/karinlag
On Sat, Jun 21, 2008 at 3:36 AM, Karin Lagesen <karinlag at studmed.uio.no> wrote:> > Hello list:) > > I have lots of values which I would like to get a histogram outline > out of. > > An example of what I am talking about: > > testdata = runif(100) > bbb = seq(0,1, by = 0.01) > hist(testdata, breaks = bbb) > > I would like to get the outline of the resulting histogram.Do you want to draw the outline, or create a function that represents it? (that's what stepfun will do) Either way looking at: h <- hist(testdata, breaks = bbb) str(h) will probably be helpful. Hadley -- http://had.co.nz/
All; this might be an easy question but I cannot make it work. I would like to set the min and max of the y axis of a plot. I know I have to use par("usr"), but after I do the plot() the axis values get changed. x<-rnorm(20) Y<-x+rnorm(20,0,.1) plot(y,x) par("usr") # let's say I have -2.8 1.15 -2.8 1.16 for par("usr") # let's say I need to change the Y-axis to be -5 to 5 usr<-par("usr") par(usr=c(usr[1:2],-5,5)) plot(y,x) # it does not take the -5 to 5??? Is there any way to set the axis values? Thanks