R环用于Phi系数 [英] R loop for Phi coefficient

查看:52
本文介绍了R环用于Phi系数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据框的每一列上成对执行Phi函数.

I want to perform Phi function pairwise on each column of my dataframe.

这就是我的df的样子

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系数,我应该执行:

To perform Phi coefficient normally I should perform:

Phi(df[,1],df[,2]

如何将其放在循环中以成对执行变量的Phi系数?谢谢

How can I put it in a loop to perform the Phi coefficient for variables pairwise? Thanks

推荐答案

选项为 combn

combn(df, 2, FUN = function(x) Phi(x[,1], x[,2]))

这篇关于R环用于Phi系数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆