Displaying 20 results from an estimated 3000 matches similar to: "hist() basic question"
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
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)
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
2013 Jan 14
1
Wrong bin count number with hist() ?
Hi there,
# Consider the following example:
A = 19
B = 20
A< B
A==B
hist(c(1:15,B,50),breaks=c(0,15,A,50),plot=F)$count
hist(c(1:15,A,50),breaks=c(0,15,B,50),plot=F)$count
# I was expecting the same results with the following values of A and B:
A = 19.6019203953960
B = 19.6019204365543
A< B
A==B
hist(c(1:15,B,50),breaks=c(0,15,A,50),plot=F)$count# wrong
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
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
2000 Nov 17
2
hist() and density
There were some questions about hist() a couple of days ago which
triggered this post. My question/suggestion is about the y-axis in hist.
There are reasons to prefer making the y-axis density=relative
frequency/bin width. One reason is that the height of the plot does not
depend on the bin width; another is that if your histogram is in density
then you can easily superimpose a smooth theoretical
2001 Aug 28
1
Axis labels
Hi,
I am trying to label the x-axis of some histograms with the units of
measurement.
However, when I use, for example:
> truehist(Ca, prob=FALSE, col="gray", xlab=expression(paste("Calcium
(", mu, eq^-1, ")")))
I get the following message:
Error in eval(expr, envir, enclos) : Object "mu" not found
Could someone let me know what I'm doing wrong?
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
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 =
2001 Dec 18
4
chi-squared test
I don't quite understand the difference between the two methods for
performing a chi-squared test on contingency tables:  summary(table())
and   chisq.test()
They may different results. E.g.:
aa <- gl(2, 10)
bb <- as.factor(c(1,2,2,2,1,2,1,2,2,2,1,2,2,2,1,1,1,2,1,1))
aa <- c(aa, aa)
bb <- c(bb, bb)
table(aa, bb)
summary(table(aa, bb))
chisq.test(aa, bb)
Could somebody give me
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
2007 Feb 02
5
reading very large files
Hi all,
I have a large file (1.8 GB) with 900,000 lines that I would like to read.
Each line is a string characters. Specifically I would like to randomly
select 3000 lines. For smaller files, what I'm doing is:
trs <- scan("myfile", what= character(), sep = "\n")
trs<- trs[sample(length(trs), 3000)]
And this works OK; however my computer seems not able to handle
2001 Sep 25
2
glm.nb, anova.negbin
Dear R-collegues,
I'm getting an error message (Error in round) when summarising a glm.nb
model, and when using anova.negbin (in R 1.3.1 for windows):
> m.nb <- glm.nb(tax ~ areal)
> m.bn
Call:  glm.nb(formula = tax ~ areal, init.theta = 5.08829537115498,
link = log)
Coefficients:
(Intercept)        areal
    3.03146      0.03182
Degrees of Freedom: 283 Total (i.e. Null);  282
2008 Feb 10
2
reshape
Dear colleagues,
I'd like to reshape a datafame in a long format to a wide format, but
I do not quite get what I want. Here is an example of the data I've
have (dat):
sp <- c("a", "a", "a", "a", "b", "b", "b", "c", "d", "d", "d", "d")
tr <- c("A",
2005 Oct 04
1
repeated measures with random effects
Dear all,
I'm interested in analysing a reapeated measure desing where plant
height (H) was measured 3 times (Time). The experimental design
include 2 fixed factor (say A and B) in which A is nested in B, and a
random factor (C, the plot), using the aov().
So my first idea would be something like:
aov(H ~ B * A %in% B * Time + Error(id) )
where id is the factor coded for the repeated
2003 Apr 24
1
matrix to coordinates
Dear R-users,
I'm sure it must be a specific function or a better way to convert 
matrix to x,y,z coordinates (and viceversa), than my function below (it 
works). Any help?
m2coord <- function(m)
{
k <- nrow(m)*ncol(m)
aa <- data.frame(r=1:k, c=1:k, v=1:k)
k <- 0
  for (i in 1:nrow(m))
  for (j in 1:ncol(m))
  {
  k <- k+1
  aa$f[k]=i; aa$c[k]=j; aa$v[k]=m[i,j]
  }
aa
}
Juli
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"
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