Sample a Few Elements of an Object
some.RdRandomly select a few elements of an object, typically a data frame, matrix, vector, or list. If the object is a data frame or a matrix, then rows are sampled.
Usage
some(x, ...)
# S3 method for class 'data.frame'
some(x, n=10, cols=NULL, ...)
# S3 method for class 'matrix'
some(x, n=10, cols=NULL, ...)
# Default S3 method
some(x, n=10, ...)Author
John Fox jfox@mcmaster.ca
References
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
Examples
some(Duncan)
#> type income education prestige
#> accountant prof 62 86 82
#> professor prof 64 93 93
#> factory.owner prof 60 56 81
#> bookkeeper wc 29 72 39
#> insurance.agent wc 55 71 41
#> machinist bc 36 32 57
#> plumber bc 44 25 29
#> taxi.driver bc 9 19 10
#> machine.operator bc 21 20 24
#> waiter bc 8 32 10
some(Duncan, cols=names(Duncan)[1:3])
#> type income education
#> professor prof 64 93
#> dentist prof 80 100
#> carpenter bc 21 23
#> electrician bc 47 39
#> RR.engineer bc 81 28
#> auto.repairman bc 22 22
#> taxi.driver bc 9 19
#> truck.driver bc 21 15
#> bartender bc 16 28
#> watchman bc 17 25