You will be using the "usdata" package's "county" data # for this assignment. # You will need to run:# install.packages("usdata")# once to install this library - do not include the# install.packages command in your submission# as it can cause gradescope to fail ## ## ## ## ## DO NOT MODIFY BELOW ## ## ## ## ## library(usdata)county<-as.data.frame(county)county<-county[,1:14]county<-county[rowSums(is.na(county))==0,]# The set.seed command will ensure your results are consistent# each time you run the "source" commandset.seed(311)## ## ## ## ## DO NOT MODIFY ABOVE ## ## ## ## ## # Treating the "county" dataset as the population of US counties# create the dataframe "my.SRS" that represents a simple# random sample of n=250 individual counties from all counties in the US. my.SRS <- NA # Treating the "county" dataset as the population of US counties# create the dataframe "my.Stratified" that represents a stratified# sample of individual counties from all counties in the US, statified # along the level of education (median_edu). Due to the different sizes of strata,# you should sample: # 1 county from "below_hs", 140 from "hs_diploma", 170 from "some_college"# and 4 from "bachelors" my.Stratified <- NA #The numbers here should match those specified above# Uncomment after your data frame has been defined to check your work# table(my.Stratified$median_edu) # Treating the "county" dataset as the population of US counties# create the dataframe "my.Clustered" that represents a cluster# sample of individual counties from all counties in the US, clustered by state. # You should randomly sample counties from a total of 5 clusters. my.Clustered <- NA #This should only give 5 total states# Uncomment after your data frame has been defined to check your work# unique(my.Clustered$state)
You will be using the "usdata" package's "county" data
# for this assignment.
# You will need to run:
# install.packages("usdata")
# once to install this library - do not include the
# install.packages command in your submission
# as it can cause gradescope to fail
## ## ## ## ## DO NOT MODIFY BELOW ## ## ## ## ##
library(usdata)
county<-as.data.frame(county)
county<-county[,1:14]
county<-county[rowSums(is.na(county))==0,]
# The set.seed command will ensure your results are consistent
# each time you run the "source" command
set.seed(311)
## ## ## ## ## DO NOT MODIFY ABOVE ## ## ## ## ##
# Treating the "county" dataset as the population of US counties
# create the dataframe "my.SRS" that represents a simple
# random sample of n=250 individual counties from all counties in the US.
my.SRS <- NA
# Treating the "county" dataset as the population of US counties
# create the dataframe "my.Stratified" that represents a stratified
# sample of individual counties from all counties in the US, statified
# along the level of education (median_edu). Due to the different sizes of strata,
# you should sample:
# 1 county from "below_hs", 140 from "hs_diploma", 170 from "some_college"
# and 4 from "bachelors"
my.Stratified <- NA
#The numbers here should match those specified above
# Uncomment after your data frame has been defined to check your work
# table(my.Stratified$median_edu)
# Treating the "county" dataset as the population of US counties
# create the dataframe "my.Clustered" that represents a cluster
# sample of individual counties from all counties in the US, clustered by state.
# You should randomly sample counties from a total of 5 clusters.
my.Clustered <- NA
#This should only give 5 total states
# Uncomment after your data frame has been defined to check your work
# unique(my.Clustered$state)

Step by step
Solved in 2 steps with 8 images






