Home > Blockchain >  Get random sample, calculate divisions, and repeat process 1000 times
Get random sample, calculate divisions, and repeat process 1000 times

Time:09-22

I have a categorical data column (Urban.f) in a dataset (edu2018) and would like to calculate a division and repeat the process 1000 times.

This is the code I have to get a random sample of size 300. It shows me how many cases of "Urban" and "Rural" there is, along with the rest of columns in the dataset. enter image description here


Data used

Obviously, we don't have your actual data, so I recreated your vector edu2018_df, which is simply a vector of "Rural" and "Urban"

set.seed(1)
edu2018_df <- sample(c("Rural", "Urban"), 1000, TRUE)
  • Related