Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,8 @@
if2 <- function(condition1, condition2, both_true, first_true, second_true, both_false)
{
expr <- if(condition1)
{
if(condition2) both_true else first_true
} else if(condition2) second_true else both_false
eval(expr)
}

View file

@ -0,0 +1,12 @@
for(x in 1:2) for(y in letters[1:2])
{
print(if2(x == 1, y == "a",
"both conditions are true",
x + 99,
{
yy <- rep.int(y, 10)
paste(letters[1:10], yy)
},
NULL
))
}

View file

@ -0,0 +1,10 @@
if2 <- function(condition1, condition2, expr_list = NULL)
{
cl <- as.call(expr_list)
cl_name <- if(condition1)
{
if(condition2) "" else "else1"
} else if(condition2) "else2" else "else"
if(!nzchar(cl_name)) cl_name <- which(!nzchar(names(cl)))
eval(cl[[cl_name]])
}

View file

@ -0,0 +1,13 @@
for(x in 1:2) for(y in letters[1:2])
{
print(if2(x == 1, y == "a", list(
"both conditions are true",
else1 = x + 99,
else2 =
{
yy <- rep.int(y, 10)
paste(letters[1:10], yy)
},
"else" = NULL
)))
}