[R] How to use Subpopulation data?
David Winsemius
dwinsemius at comcast.net
Fri Oct 2 16:38:29 CEST 2009
On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:
> Dear Helpers
>
> I have a sample frame and i have sampled from it using three methods
> and now i want to calculate the statistics but i only get the
> population parameters.
>
> H <- matrix(rnorm(100, mean=50000, sd=5000))
> sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
> sampleframe
>
> str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
> sample.strat<-getdata(sampleframe,str)
> sample.strat
If you want the number of rows in sample.strat then length(H) is the
wrong approach since that is the original (unsampled) object.
> length(H)
> i get:
>
> length(H)
> [1] 100
>
> Desire to get:
> length(H)
> [1] 20
I cannot tell what packages you have loaded and strata is not in the
sampling package which I guessed (wrongly) was where you were getting
"getdata". When you post code you should precede that code with calls
that load any non-base packages.
In later posting you ask for ways to calculate "the sum" but you do
not say what it is that you want the sum of.... . Our abilities to
read minds is extremely limited.
--
David Winsemius
More information about the R-help
mailing list