This function is useful to check a data set. It gives a random number of rows of the input data set.

sample_df(x, n = 10, previous = FALSE)

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.

Value

A data base (resp vector) with n rows (resp elements).

Author

Laurent Berge

Examples


sample_df(iris)
#>     Sepal.Length Sepal.Width Petal.Length Petal.Width    Species
#> 68           5.8         2.7          4.1         1.0 versicolor
#> 26           5.0         3.0          1.6         0.2     setosa
#> 117          6.5         3.0          5.5         1.8  virginica
#> 82           5.5         2.4          3.7         1.0 versicolor
#> 35           4.9         3.1          1.5         0.2     setosa
#> 129          6.4         2.8          5.6         2.1  virginica
#> 112          6.4         2.7          5.3         1.9  virginica
#> 94           5.0         2.3          3.3         1.0 versicolor
#> 65           5.6         2.9          3.6         1.3 versicolor
#> 55           6.5         2.8          4.6         1.5 versicolor

sample_df(iris, previous = TRUE)
#>     Sepal.Length Sepal.Width Petal.Length Petal.Width    Species
#> 68           5.8         2.7          4.1         1.0 versicolor
#> 26           5.0         3.0          1.6         0.2     setosa
#> 117          6.5         3.0          5.5         1.8  virginica
#> 82           5.5         2.4          3.7         1.0 versicolor
#> 35           4.9         3.1          1.5         0.2     setosa
#> 129          6.4         2.8          5.6         2.1  virginica
#> 112          6.4         2.7          5.3         1.9  virginica
#> 94           5.0         2.3          3.3         1.0 versicolor
#> 65           5.6         2.9          3.6         1.3 versicolor
#> 55           6.5         2.8          4.6         1.5 versicolor