uribo / jpmesh
1
#' @title Generate random sample meshcode
2
#' @description Generate random sample meshcode
3
#' @param n Number of samples
4
#' @inheritParams meshcode_set
5
#' @examples
6
#' rmesh(3, mesh_size = 1)
7
#' @export
8
rmesh <- function(n, mesh_size = 1) {
9 6
  if (mesh_size %in% c(80, 10, 5, 1)) {
10 6
    sample(meshcode_set(mesh_size = mesh_size), n) # nolint
11
  } else {
12 6
    rlang::abort(paste0(
13 6
      "`mesh_size` should be one of: ",
14 6
      paste(
15 6
        units::drop_units(mesh_units)[c(1, 2, 3)],
16 6
        collapse = ", "
17
      ),
18 6
      " or ",
19 6
      paste(units::drop_units(mesh_units)[4])
20
    ))
21
  }
22
}

Read our documentation on viewing source code .

Loading