I have this function:
xa <- 9
xb <- 6
za <- 20
a1 <- xa / za
b1 <- xb / za
Validation <- function (a1, b1)
if (a1 / b1 >= .85 && a1 / b1 <= 1.15) {print(TRUE)}
result <- Validation (a1, b1)
result
The value of xa, xb, and za change ten times and there are also three other trios of data that change ten times:
c1 <- xc / zc
d1 <- xd / zc
e1 <- xe / ze
f1 <- xf / ze
g1 <- xg / zg
h1 <- xh / zg
as you can see in the dataframe below:
mat <- data.frame(xa = sample(0:10, 10, replace = TRUE),
xb = sample(0:10, 10, replace = TRUE),
za = sample(10:20, 10, replace = TRUE),
xc = sample(0:10, 10, replace = TRUE),
xd = sample(0:10, 10, replace = TRUE),
zc = sample(10:20, 10, replace = TRUE),
xe = sample(0:10, 10, replace = TRUE),
xf = sample(0:10, 10, replace = TRUE),
ze = sample(10:20, 10, replace = TRUE),
xg = sample(0:10, 10, replace = TRUE),
xh = sample(0:10, 10, replace = TRUE),
zg = sample(10:20, 10, replace = TRUE))
mat
So, my question is: How can I create a function that also considers these three other trios of data and run the 'if' function for the ten lines of the dataframe?
I ultimately want to have an output of ten lines and four columns (za, zc, ze, zg) with the information: TRUE or NULL.
Thanks,
0 Answer(s)