Displaying 20 results from an estimated 10000 matches similar to: "Wrong bin count number with hist() ?"
2004 Nov 26
2
hist and truehist
Hello!
Up to now I have been using hist() to display the distributions.
Howevere, I noteiced strange numbers on y (vertical) axis, if I used
probability = T or freq = F option. I thought it is a bug and launched
the R-bug system and found some posts on that matter. Brian Ripley
responded to one, that one should look at truehist() for that. Ok I can
use truehist() if I want to see the ratios
2004 Sep 09
1
man page of hist points to truehist, which can't be viewed without loading a library?
rdevel from yesterday, also in 1.9.1 (Debian, -3).
The man page of 'hist' (from the graphics package, obtained by
"?hist") suggests 'truehist' under "see also", but 'truehist' isn't
loaded by default (a sensible "of course"), so that "?truehist" fails.
One can do help.search(), of course, which points what to do, but
leads to my
2003 Mar 08
2
hist() basic question
Hi,
This is a very basic question, but I would like to undestand hist(). I
thought that the hist( , freq=FALSE) should provide the relative
frequencies (probabilities), and so they should sum 1, however:
set.seed(2)
ah <- hist(rnorm(100), freq=F)
sum(ah$intensities)
[1] 2
set.seed(2)
bh <- hist(rlnorm(100), freq=F)
sum(bh$intensities)
[1] 0.4999996
I'm getting similar figures with
2004 Aug 21
1
relative frequencies for hist()
I have problems getting a histogram with relative frequencies on the y-axis.
Here is an example data set:
> a <- c(4.626, 4.627, 4.627, 4.628, 4.629, 4.629, 4.630, 4.631, 4.632,
4.632)
> d = hist(a,freq=F)
> d$density
[1] 299.9999 100.0000 200.0000 100.0000 100.0000 200.0000
The obtained densities are given by counts/(total n * bin width), with
bin width being
2002 Mar 23
1
Normal behavior or bug?
>selectiris<-sample(1:5, 150, replace=T)
> hist(selectiris, plot=TRUE) #freq=TRUE, breaks=5, etc all do the same thing
>truehist(selectiris)
Is the behavior of "hist" in this sample of code correct. On my system
(Windows 2K, SP2) the first and second bars are pushed together, while the
3rd, 4th, and 5th bars are correctly positioned.
The function "truehist"
2011 Apr 22
1
histogram of dates
I can't seem to get a histogram of dates:
tmt910% R --vanilla
R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
...
> temp <- as.Date(1:200, origin="1970/01/01")
> range(temp)
[1] "1970-01-02" "1970-07-20"
> hist(temp)
Error in .Internal(inherits(x, what, which)) : 'x' is missing
2006 Nov 07
1
histogram bin width
hi all : i have the data below and then below that, i call the hist
function three times using the Scott method for the widths of the bins.
the bin width is different for the three histograms but I would like it
to always be 0.05 regfardless of the data
set being histogrammed.
I'm sure there must be a manual way to do this which is fine with me. i
tried breaks=0.05 but it wasn't happy
2007 Mar 20
1
truehist bug?
Hi,
Is this a bug in truehist()?
> library(MASS)
> x <- rep(1, 10)
> truehist(x)
Error in pretty(data, nbins) : invalid 'n' value
Thanks,
Gad
> R.version
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 4.1
year 2006
month 12
day 18
svn
2007 Mar 20
1
truehist bug?
Hi,
Is this a bug in truehist()?
> library(MASS)
> x <- rep(1, 10)
> truehist(x)
Error in pretty(data, nbins) : invalid 'n' value
Thanks,
Gad
> R.version
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 4.1
year 2006
month 12
day 18
svn
2003 Apr 18
3
superimposing graphs
Dear People,
I have a data set of data x from a probability distribution, and I have a
function, mydensity, of the pdf of that distribution.
I'm asking for help in superimposing the histogram of x and the plot of
mydensity.
In the function below, I call truehist and curve, but these are plotted in
different figures.
I'd like them to be plotted on the same figure, and to use common
2003 Jan 31
3
hist (PR#2512)
The command hist(c(2,2,2,4,5,6)) returns a histogram that looks incorrect -- 3 in the bin labeled 2 on the left, but 1 each in the bins labeled 3,4,5 on the left.
Thanks!
Pam Surko
--------------------
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 1
minor
2003 May 03
1
can't plot ylab in graph
Dear People,
I am sure I am missing something obvious as usual, but in the following
graph I can't plot ylab.
Ignoring unimportant details, I am plotting one instance of truehist() and
one instance of curve() on the same graph. Truehist() won't let me pass
the ylab argument. It gives me the error
Error in plot.default(xlim, c(0, ymax), type = "n", xlab = xlab, ylab =
2007 Apr 25
1
omit y=zero line in histogram
Dear all,
hist ( ) plots a horizontal line at y=0 when the respective bin is empty. I
can deal with this by modifying the hist object before plotting it
(x$density[x$density == 0] <- NA), but I'm sure I've seen a more elegant
way. Perhaps this was in truehist (MASS). I have looked but can't find it.
Does anyone know?
Best wishes
Paul
--
View this message in context:
2002 Sep 11
1
axis with negative values
How can I extend the axis of truehist with negative values. I need to plot
residuals from a stepwise regression.
Ulrich
--
__________________________________________________
Ulrich Leopold MSc.
Department of Physical Geography
Institute for Biodiversity and Ecosystem Dynamics
Faculty of Science
University of Amsterdam
Nieuwe Achtergracht 166
NL-1018WV Amsterdam
Phone: +31-(0)20-525-7456
2004 Mar 01
6
How to plot Histogram with frequence overlaid by distribution curve
Hi,
I am facing the problem that I want to plot a histogram chart set
freq to true and overlay with normal or weibull or exponential distribution
curve.
The sample code is shown as below:
>samp<-c(-8.2262,-8.2262,-8.2262,-8.20209,-8.09294,-8.07321,-8.07321,
-8.07321,-8.07175,-8.04948,-8.04948,-8.04948,-8.03848,-8.03848,
2007 Nov 28
1
Histograms and Sturges rule
Dear All,
According to the Sturges rule, the number of classes of a histogram is
the closest integer to
1 + logb(n,base=2)
where n is the number of observations. The function hist(), by
default, uses the Sturges rule. However, the code
x <- 1:200
hist(x)
produces a histogram with 10 classes and not 9 classes as determined
by the Sturges rule. What am I missing?
Thanks in advance,
Paul
2012 Mar 14
2
sum(hist$density) == 2 ?!
> x <- rnorm(1000)
> h <- hist(x,plot=FALSE)
> sum(h$density)
[1] 2 ----------------------------- shouldn't it be 1?!
> h <- hist(x,plot=FALSE, breaks=(-4:4))
> sum(h$density)
[1] 1 ----------------------------- now it's 1. why?!
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://www.memritv.org
2010 Apr 16
2
how to change the position of xlab in truehist?
Hi,
I'm wondering how can I change the position of xlab in truehist. For example, the following code creats a histogram with 4 bins for my discrete data. I want each bin to be labelled as 0, 1, 2, or 3 in the middle, so that it's clear each bin corresponds to each of the discrete case.
I was thinking of first delete xlab and then add marks myself, but it doesn't look like it's
2006 Sep 29
2
X-axis labels in histograms drawn by the "truehist" function
Hi,
I have a simple problem that I would appreciate getting some tips. I am
using the "truehist" function within an "apply" call to plot multiple
histograms. I can't figure out how to get truehist to use the column names
of the matrix as the labels for the x-axis of the histograms.
Here is a simple example:
X <- matrix(runif(4000),ncol=4)
colnames(X)
2009 Apr 28
3
truehist and density plots
Hi,
I wanted to plot the histogram of a vector and then, plot the density function of subsets of the vector on the histogram. So I use truehist in MASS package and lines(density) as follows:
length(b) = 1000
truehist(b)
lines(density(b[1:100]))
however the density plot of the first 100 points exceeds the max of y axis (see attached). how is it possible to make a graphics so that the density plot