dplyr like sample_frac for a matrix

sample_frac_matrix(mat, frac, replace = FALSE, weight = NULL)

Arguments

mat

A matrix

frac

fraction of rows to sample

replace

See arguments for 'base::sample'

weight

See arguments for 'base::sample'

Value

A matrix

Examples

library("magrittr") mat <- matrix(1:1e4, ncol = 10) mat %>% sample_frac_matrix(0.1) %>% dim()
#> [1] 100 10