[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:

wtd.hist(NHANES$LBXTHG,breaks="Sturges",weight=weight,freq=FALSE,mai
n='Mercury
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
on
Sturges led me to believe that the breaks would be determined by the
range
of the data. Can anyone advise?

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

Best,
Jules




--
View this message in context:
http://r.789695.n4.nabble.com/Trouble-defining-breaks-for-weighted-h
istogram-tp4671176.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list