gen_random_expr {lazy.symbolic} | R Documentation |
Generate Random Expression
gen_random_expr(
natom = 2,
nparen = 0,
nparen2 = 0,
random = 0,
maxlena = 1,
maxlennum = 0,
oper = c("+", "-", "*"),
alpha = c(letters, LETTERS),
num = formatC(0:9, digits = 0, format = "d"),
print = 0,
debug = 0
)
natom |
# of atmic elements in an expression |
nparen |
# of parentheses in an expression |
nparen2 |
# of higher level parentheses in an expression |
random |
= 1 to randomize the roots of the atomic elements |
maxlena |
# of alphabets in the root |
maxlennum |
# of numerics in the root |
oper |
a vector consisting of the binary operators to be used |
alpha |
a vector of characters to be used as the root |
num |
a vector of the numbers to be used as the root |
print |
= 1 to print the result |
This function generates a valid expression according to the specification given by the input parameters
an expression as a character vector of length one
set.seed(1701)
gen_random_expr( )
gen_random_expr( natom=9, random=1, nparen=3 )
set.seed(1701)
gen_random_expr( natom=9, random=1, nparen=3, nparen2=3 )
expr <- gen_random_expr( natom=9, random=0, nparen=3, nparen2=1
, oper=c("%*%","+","-"), alpha=LETTERS[-9] )
expr <- sub( "D", "diag(D)", expr, fixed=1 )