title: Unable to run strata() in R
body: <p>I am learning about strata sampling in R and was trying to run the strata function. I run into the same error each time i try to run this function - when i run strata() from class notes provided by the professor, when run an example from ?strata - below is the example from help(strata) and the error message i receive when i try to run it. I am puzzled. I get the same error message no matter which strata() i run - any ideas how to overcome this? Any recommendations are appreciated.</p>
  
  <pre><code># Uses the 'swissmunicipalities' data as population for drawing a sample of units
  
  data(swissmunicipalities)
  
  # the variable 'REG' has 7 categories in the population
  # it is used as stratification variable
  # Computes the population stratum sizes
  table(swissmunicipalities$REG)
  1   2   3   4   5   6   7 
  589 913 321 171 471 186 245 
  
  # do not run
  #  1   2   3   4   5   6   7 
  # 589 913 321 171 471 186 245 
  # sort the data to obtain the same order of the regions in the sample
  
  data=swissmunicipalities
  data=data[order(data$REG),]
  
  # the sample stratum sizes are given by size=c(30,20,45,15,20,11,44)
  # 30 units are drawn in the first stratum, 20 in the second one, etc.
  # the method is simple random sampling without replacement 
  # (equal probability, without replacement)  
  
  st=strata(data,stratanames=c("REG"),size=c(30,20,45,15,20,11,44), method="srswor") 
  </code></pre>
  
  <blockquote>
    <p>Error in strata(data, stratanames = c("REG"), size = c(30, 20, 45, 15,
    :    all arguments must be the same length</p>
  </blockquote>
  
  <pre><code># extracts the observed data 
  getdata(data, st) 
  </code></pre>
  
  <blockquote>
    <p>Error in is.vector(m) : object 'st' not found</p>
  </blockquote>
  
  <pre><code># see the result using a contingency table 
  table(st$REG)
  </code></pre>
  
  <blockquote>
    <p>Error in table(st$REG) : object 'st' not found</p>
  </blockquote>