'Is there a reason strata in R is not working properly?

set.seed(1234)
n <- 50

df2 <- df2[order(df2$race), ]

freq <- table(df2$race)
freq

st.sizes <- n * freq / sum(freq)
st.sizes

sample_strat <- strata(df2,
                       stratanames = "race",
                       size = st.sizes,
                       method = "srswor",
                       description = TRUE)

Above is my code, I have also tried with stratanames = c("race") and that gives the same error message. Which looks like the following.

Stratum 1 

Population total and number of selected units: 736 0.5469272 
Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 0, 1

can anyone help?

Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source