t-test in R between individuals columns and the rest of a given dataframe

后端 未结 1 941
庸人自扰
庸人自扰 2021-01-16 21:49

This is in R. I need help taking a dataframe of basic format

       NAC     cOF3     APir       Pu       Tu     V2.3     mOF3     DGpf
1 6.314770 6.181188 6.         


        
1条回答
  •  北恋
    北恋 (楼主)
    2021-01-16 22:45

    sapply(names(dat), function(x) 
             sapply( names(dat), function(y) t.test(dat[[x]],dat[[y]])$statistic ))
    

    Can use any of the values returned in the list from the function t.test. Could also have looped across the results of combn(names(dat), 2), which would be a choose(n,2) matrix. (The square matrix has obvious redundant results) Obviously need a sensible adjustment for multiple testing. Could use p.adjust.

    0 讨论(0)
提交回复
热议问题