[R] Trouble defining breaks for weighted histogram

David Carlson dcarlson at tamu.edu
Tue Jul 9 21:02:06 CEST 2013

Hard to say without a reproducible example, perhaps by using dput()
to include a subset of the data. You should indicate where
wtd.hist() comes from since it is not in base R. Perhaps the weights
package? It is not clear what weight=weight is unless you have
created a variable called weight. If you are referring to a variable
in NHANES it should be NHANES$weight.

David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of juliannecpayne
Sent: Tuesday, July 9, 2013 12:38 PM
To: r-help at r-project.org
Subject: [R] Trouble defining breaks for weighted histogram

Hello R users,

I am in the process of creating weighted histograms using NHANES
data. I
developed the following language to output my results:

Histogram (Weighted)',xlab='Blood Mercury',col=200,na.rm=TRUE)

Each time I submit the language, I get an error back stating:

Error in wtd.hist(NHANES$LBXTHG, breaks = "Sturges", weight =
weight,  : 
some 'x' not counted; maybe 'breaks' do not span range of 'x'

I'm a bit unclear on why this might be, given that the documentation
Sturges led me to believe that the breaks would be determined by the
of the data. Can anyone advise?

I suppose it may be worth mentioning that I am a new R user. I
program in SAS.


View this message in context:
Sent from the R help mailing list archive at Nabble.com.

R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list