Please i want to draw pps sample from different zones. Every zone has its sample size. I have 2 data frames in rstudio.
The first one contains the whole individuals, each individual belongs to a zone with a size variable.
The second data frame contains sample size of each zone.
**First data frame (BD) :
Individuals | Zone | size_variable |
---|---|---|
1 | A | 3 |
2 | B | 8 |
3 | A | 2 |
4 | E | 14 |
…… | ……. | ……. |
**Second data frame (SZ) :
Zone | Sample Size |
---|---|
A | 4 |
B | 6 |
C | 7 |
D | 10 |
…… | ……. |
I turned the following code :
library(samplingbook)
library(dplyr)
library(readxl)
for (i in 1:nrow(SZ)) { for (j in 1:nrow(SZ)){ i=BD%>%filter(Zone==SZ$Zone [i]) sample [[i]] <- pps.sampling(i$size_variable,SZ$sample_size[j],id=BD$Individuals,method = 'midzuno', return.PI = FALSE ) Sample_Final [[i]] <- data.frame(sample[[i]]$sample) Write.csv (Sample_Final [[i]], "sample.csv")
But i had only one sample of the first zone. please help me where is the problem?
Naoufal BAHEDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.