add_var_random_int: Add a random integer variable to dataset

View source: R/add-var.R

add_var_random_intR Documentation

Add a random integer variable to dataset

Description

Add a random integer variable to dataset

Usage

add_var_random_int(
  data,
  name = "random_int",
  min_val = 1,
  max_val = 10,
  overwrite = TRUE,
  seed
)

Arguments

data

A dataset

name

Name of new variable (as string)

min_val

Minimum random integers

max_val

Maximum random integers

overwrite

Can new random variable overwrite an existing variable in dataset?

seed

Seed for random number generation (integer)

Value

Dataset containing new random variable

Examples

library(magrittr)
iris %>% add_var_random_int() %>% head()
iris %>% add_var_random_int(name = "random_var") %>% head()
iris %>% add_var_random_int(min_val = 1, max_val = 10) %>% head()

explore documentation built on Sept. 11, 2024, 7:40 p.m.