Skip to contents

This is a small convenience function that simply returns the value passed to it, in order to allow the use of a constant node as root node in the sim_from_dag function.

Usage

rconstant(n, constant)

Arguments

n

The number of times the constant should be repeated.

constant

A single value of any kind which is used as the only value of the resulting variable.

Author

Robin Denz

Value

Returns a vector of length n with the same type as constant.

Examples

library(simDAG)

rconstant(n=10, constant=7)
#>  [1] 7 7 7 7 7 7 7 7 7 7

rconstant(n=4, constant="Male")
#> [1] "Male" "Male" "Male" "Male"