Simple random sampling

sampling(
  dataset,
  vars,
  sample_size,
  seed = 1234,
  data_filter = "",
  na.rm = FALSE,
  envir = parent.frame()
)

Arguments

dataset

Dataset to sample from

vars

The variables to sample

sample_size

Number of units to select

seed

Random seed to use as the starting point

data_filter

Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000")

na.rm

Remove rows with missing values (FALSE or TRUE)

envir

Environment to extract data from

Value

A list of class 'sampling' with all variables defined in the sampling function

Details

See https://radiant-rstats.github.io/docs/design/sampling.html for an example in Radiant

See also

summary.sampling to summarize results

Examples

sampling(rndnames, "Names", 10)
#> $seldat #> rnd_number Names #> 1 0.9921504 Jarrod Jolly #> 2 0.9264005 Matilda Mcgillivray #> 3 0.9234335 Beau Bannerman #> 4 0.9146582 Tomas Tupper #> 5 0.9004246 Bernardine Bohr #> 6 0.8985805 Nona Nosal #> 7 0.8961858 Janey Jetton #> 8 0.8928364 Amberly Ahumada #> 9 0.8648338 Latisha Lutz #> 10 0.8609154 Jc Julius #> #> $rnd_number #> rnd_number #> 1 0.113703411 #> 2 0.622299405 #> 3 0.609274733 #> 4 0.623379442 #> 5 0.860915384 #> 6 0.640310605 #> 7 0.009495756 #> 8 0.232550506 #> 9 0.666083758 #> 10 0.514251141 #> 11 0.693591292 #> 12 0.544974836 #> 13 0.282733584 #> 14 0.923433484 #> 15 0.292315840 #> 16 0.837295628 #> 17 0.286223285 #> 18 0.266820780 #> 19 0.186722790 #> 20 0.232225911 #> 21 0.316612455 #> 22 0.302693371 #> 23 0.159046003 #> 24 0.039995918 #> 25 0.218799541 #> 26 0.810598552 #> 27 0.525697547 #> 28 0.914658166 #> 29 0.831345047 #> 30 0.045770263 #> 31 0.456091482 #> 32 0.265186672 #> 33 0.304672203 #> 34 0.507306870 #> 35 0.181096208 #> 36 0.759670635 #> 37 0.201248038 #> 38 0.258809819 #> 39 0.992150418 #> 40 0.807352340 #> 41 0.553333591 #> 42 0.646406094 #> 43 0.311824307 #> 44 0.621819198 #> 45 0.329770176 #> 46 0.501997473 #> 47 0.677094527 #> 48 0.484991239 #> 49 0.243928827 #> 50 0.765459788 #> 51 0.073779880 #> 52 0.309686602 #> 53 0.717271743 #> 54 0.504545912 #> 55 0.152998959 #> 56 0.503933488 #> 57 0.493960923 #> 58 0.751200197 #> 59 0.174649824 #> 60 0.848392410 #> 61 0.864833832 #> 62 0.041857275 #> 63 0.317182155 #> 64 0.013749939 #> 65 0.239025727 #> 66 0.706494617 #> 67 0.308094757 #> 68 0.508547566 #> 69 0.051646619 #> 70 0.564569840 #> 71 0.121480187 #> 72 0.892836382 #> 73 0.014627256 #> 74 0.783121104 #> 75 0.089961333 #> 76 0.519189981 #> 77 0.384266688 #> 78 0.070052497 #> 79 0.320644422 #> 80 0.668495397 #> 81 0.926400476 #> 82 0.471909721 #> 83 0.142615343 #> 84 0.544269755 #> 85 0.196174652 #> 86 0.898580489 #> 87 0.389499785 #> 88 0.310870780 #> 89 0.160028663 #> 90 0.896185850 #> 91 0.166393780 #> 92 0.900424596 #> 93 0.134078195 #> 94 0.131614134 #> 95 0.105287503 #> 96 0.511583581 #> 97 0.300199054 #> 98 0.026716895 #> 99 0.309647431 #> 100 0.742119657 #> #> $df_name #> [1] "rndnames" #> #> $dataset #> rnd_number Names #> 1 0.113703411 Ervin Escalona #> 2 0.622299405 Allan Ammerman #> 3 0.609274733 Milton Mothershed #> 4 0.623379442 Deshawn Dawn #> 5 0.860915384 Jc Julius #> 6 0.640310605 Denver Delph #> 7 0.009495756 Jed Jameson #> 8 0.232550506 Zachariah Zeno #> 9 0.666083758 Cyril Class #> 10 0.514251141 Lauren Lukas #> 11 0.693591292 Hershel Hentz #> 12 0.544974836 Darrell Draheim #> 13 0.282733584 Shawn Salmon #> 14 0.923433484 Beau Bannerman #> 15 0.292315840 Stephen Slough #> 16 0.837295628 Cole Cropper #> 17 0.286223285 Stacy Schrecengost #> 18 0.266820780 Kent Keasler #> 19 0.186722790 Omar Ogden #> 20 0.232225911 Perry Pearcy #> 21 0.316612455 Courtney Carmody #> 22 0.302693371 Derek Dorsch #> 23 0.159046003 Napoleon Norman #> 24 0.039995918 Rodney Regis #> 25 0.218799541 Hubert Hyer #> 26 0.810598552 Foster Fugate #> 27 0.525697547 Emery Etchison #> 28 0.914658166 Tomas Tupper #> 29 0.831345047 Robin Ramsay #> 30 0.045770263 Tom Tomita #> 31 0.456091482 Travis Thornley #> 32 0.265186672 Hank Heavner #> 33 0.304672203 Ahmed Avey #> 34 0.507306870 Sanford Steinfeldt #> 35 0.181096208 Douglass Daddario #> 36 0.759670635 Dominic Duhon #> 37 0.201248038 Emanuel Esquer #> 38 0.258809819 Federico Fillion #> 39 0.992150418 Jarrod Jolly #> 40 0.807352340 Lawrence Levasseur #> 41 0.553333591 Kurtis Kieser #> 42 0.646406094 Ty Troyer #> 43 0.311824307 Bryce Billy #> 44 0.621819198 Brooks Buie #> 45 0.329770176 Maximo Manzi #> 46 0.501997473 Lino Luse #> 47 0.677094527 Mark Mccloskey #> 48 0.484991239 Tory Tilman #> 49 0.243928827 Angel Aker #> 50 0.765459788 Jean Joseph #> 51 0.073779880 Susann Sauers #> 52 0.309686602 Deborah Deckard #> 53 0.717271743 Many Mcvey #> 54 0.504545912 Dalene Dubreuil #> 55 0.152998959 Gabriella Gurganus #> 56 0.503933488 Kellie Kealoha #> 57 0.493960923 Amie Asay #> 58 0.751200197 Robbi Randell #> 59 0.174649824 Jacquelin James #> 60 0.848392410 Jennefer Jansson #> 61 0.864833832 Latisha Lutz #> 62 0.041857275 Glenda Garris #> 63 0.317182155 Elana Eslinger #> 64 0.013749939 Margene Martelli #> 65 0.239025727 Breana Ballou #> 66 0.706494617 Christal Chaires #> 67 0.308094757 Carlotta Clack #> 68 0.508547566 Doretha Dever #> 69 0.051646619 Eden Epps #> 70 0.564569840 Essie Elwood #> 71 0.121480187 Antonina Alers #> 72 0.892836382 Amberly Ahumada #> 73 0.014627256 Bernadette Basnight #> 74 0.783121104 Christine Chevalier #> 75 0.089961333 Shemeka Solar #> 76 0.519189981 Antonietta Alfano #> 77 0.384266688 Rozanne Raulerson #> 78 0.070052497 Willa Well #> 79 0.320644422 Jazmin Jeffcoat #> 80 0.668495397 Marcell Meisner #> 81 0.926400476 Matilda Mcgillivray #> 82 0.471909721 Davida Derrickson #> 83 0.142615343 Clarita Calandra #> 84 0.544269755 Angelita Archer #> 85 0.196174652 Dorinda Dehne #> 86 0.898580489 Nona Nosal #> 87 0.389499785 Jesusa Jordon #> 88 0.310870780 Elinore Elmer #> 89 0.160028663 Leanne Lew #> 90 0.896185850 Janey Jetton #> 91 0.166393780 Linette Lavery #> 92 0.900424596 Bernardine Bohr #> 93 0.134078195 Dagny Distefano #> 94 0.131614134 Racheal Ravelo #> 95 0.105287503 Kayla Krajewski #> 96 0.511583581 Marylee Malatesta #> 97 0.300199054 Janna Jacob #> 98 0.026716895 Alita Aikin #> 99 0.309647431 Junko Jungers #> 100 0.742119657 Denese Diem #> #> $vars #> [1] "Names" #> #> $sample_size #> [1] 10 #> #> $seed #> [1] 1234 #> #> $data_filter #> [1] "" #> #> $na.rm #> [1] FALSE #> #> attr(,"class") #> [1] "sampling" "list"