下面是我的数据集的微缩版。我想在不使用“for”函数的情况下循环三个变量。
主题数据集的可重现版本
cat1 <- rep(c("A","S"),each=40)# First variable
cat2 <- rep(c("C","M","Y","K"), each=10, times=2) # Second variable
num1 <- rep(c(0,10,20,30,40,45,65,80,90,100),8) # Third variable
rspns <-structure(list(dataSet = c(0.2484375, 0.3959375, 0.4875, 0.57875, 0.6696875, 0.694375,
0.816875, 0.879375, 0.9121875, 0.93125, 0.25125, 0.3796875, 0.4609375, 0.5396875, 0.6159375,
0.6515625, 0.7696875, 0.8384375, 0.864375, 0.8865625, 0.271875, 0.39875, 0.4821875,
0.5628125, 0.6284375, 0.650625, 0.7553125, 0.8003125, 0.8103125, 0.8125, 0.251875, 0.3775,
0.4703125, 0.5725, 0.6996875, 0.7378125, 0.945, 1.055625, 1.1021875, 1.1140625, 0.25125,
0.4203125, 0.5215625, 0.615625, 0.71, 0.74, 0.865625, 0.9246875, 0.9603125, 0.9734375,
0.256875, 0.3953125, 0.4775, 0.5528125, 0.62875, 0.65875, 0.78375, 0.8384375, 0.8653125,
0.8740625, 0.2790625, 0.4215625, 0.515, 0.6009375, 0.6665625, 0.693125, 0.7959375, 0.83875,
0.8490625, 0.8575, 0.2571875, 0.3759375, 0.4665625, 0.56375, 0.68875, 0.725, 0.9259375,
1.0328125, 1.085625, 1.1096875)), .Names = "rspns",
class = "data.frame", row.names = c(NA, -80L))
gain <- data.frame(cat1,cat2,num1, rspns=rspns)
tint <- function(x,y,z) gain[cat1 == x & cat2 == y & num1 == z, 4]
dgain <- function(x,y,z){(100* (1-10^-(tint(x,y,z) - tint(x,y,0))) / (1-10^-(tint(x,y,100)- tint(x,y,0)))) - z}
如何在不使用循环的情况下获取需要三个参数的函数dgain
来循环cat1
和变量?cat2
num1
for
非常感谢您的帮助和技术专长。