我想在数据框的每一列上成对执行Phi函数。
这就是我的df的样子
with open(join(_script_dir, 'tmp.txt'), 'w') as tmp:
#
# old code
#
completed = subprocess.call(cmd, shell=True, stdout=tmp, stderr=tmp)
要正常执行Phi系数,我应该执行:
AnxietyDisorders ASD AutoimmuneThyroiditis CeliacDisease
no no yes no
yes no no no
no no no no
no no no no
no no no no
no no no no
yes no no no
no no no no
no no no yes
如何将其放在循环中以成对执行变量的Phi系数? 谢谢
答案 0 :(得分:0)
选项为combn
combn(df, 2, FUN = function(x) Phi(x[,1], x[,2]))