Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Assume your dataset is named 'county _ dataset' # Replace 'median _ edu' with the actual column name representing the level of education #

# Assume your dataset is named 'county_dataset'
# Replace 'median_edu' with the actual column name representing the level of education
# Generate a sample dataset for demonstration
set.seed(123)
county_dataset <- data.frame(
county_id =1:100,
median_edu = sample(c("below_hs","hs_diploma", "some_college", "bachelors"),100, replace = TRUE)
)
# Create a stratified sample
my.Stratified <- county_dataset %>%
group_by(median_edu)%>%
slice_sample(n = ifelse(median_edu == "below_hs",1,
ifelse(median_edu =="hs_diploma", 14,
ifelse(median_edu == "some_college", 17,
ifelse(median_edu == "bachelors", 4,0)
)
)
))%>%
ungroup()
# Print the resulting dataframe
print(my.Stratified)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane X z 2/3 90% a/3

Answered: 1 week ago