This function is useful to check a data set. It gives a random number of rows of the input data set.
Arguments
- x
A data set: either a vector, a matrix or a data frame.
- n
The number of random rows/elements to sample randomly.
- previous
Logical scalar. Whether the results of the previous draw should be returned.
Examples
sample_df(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 117 6.5 3.0 5.5 1.8 virginica
#> 139 6.0 3.0 4.8 1.8 virginica
#> 79 6.0 2.9 4.5 1.5 versicolor
#> 95 5.6 2.7 4.2 1.3 versicolor
#> 130 7.2 3.0 5.8 1.6 virginica
#> 127 6.2 2.8 4.8 1.8 virginica
#> 144 6.8 3.2 5.9 2.3 virginica
#> 110 7.2 3.6 6.1 2.5 virginica
#> 82 5.5 2.4 3.7 1.0 versicolor
#> 51 7.0 3.2 4.7 1.4 versicolor
sample_df(iris, previous = TRUE)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 117 6.5 3.0 5.5 1.8 virginica
#> 139 6.0 3.0 4.8 1.8 virginica
#> 79 6.0 2.9 4.5 1.5 versicolor
#> 95 5.6 2.7 4.2 1.3 versicolor
#> 130 7.2 3.0 5.8 1.6 virginica
#> 127 6.2 2.8 4.8 1.8 virginica
#> 144 6.8 3.2 5.9 2.3 virginica
#> 110 7.2 3.6 6.1 2.5 virginica
#> 82 5.5 2.4 3.7 1.0 versicolor
#> 51 7.0 3.2 4.7 1.4 versicolor