'In R, how can I use all methods of p.adjust on a dataframe in one go?

At the moment I have a data frame of p values.

l<- data.frame(p1 = c(0.01,0.5,0.6), p2= c(0.04,0.9,0.02))

and I would like to apply p.adjust using all methods on each column independently of the others.

Below is the only way that seems to work... but only for one column at a time.

library(multcomp)
set.seed(2020)

l<- data.frame(p1 = c(0.01,0.5,0.6), p2= c(0.04,0.9,0.02))
p.adjust.M<- p.adjust.methods
sapply(p.adjust.M, function(meth) p.adjust( l[,1], meth))
`p.adjust.M<- p.adjust.methods`

The output below is for the first column. I would ideally like to apply all the methods below to all columns in one go and have n dataframes corresponding to n columns of adjustments.

     holm hochberg hommel bonferroni   BH    BY  fdr none
[1,] 0.03     0.03   0.03       0.03 0.03 0.055 0.03 0.01
[2,] 1.00     0.60   0.60       1.00 0.60 1.000 0.60 0.50
[3,] 1.00     0.60   0.60       1.00 0.60 1.000 0.60 0.60

Unfortunately I am going to have a lot of columns so this isn't a feasible approach.

Thanks in advance!



Solution 1:[1]

I have the problem. when i pass body instead of fixture in the interceptor , cypress forces the header to application/json. no way to change it. to solve the problem i passed my json file as a fixture and set my custom header according to that.

Cypress.Commands.overwrite('intercept', (originalFn, { method, url }, options) => {
  method = 'POST'
  url = `${Cypress.env('EXTERNAL_API')}/${url}`
  const isJsonHeader = options?.fixture?.toLowerCase()?.includes('.json') ? true : false
  options = {
    ...options,
    headers: isJsonHeader ? Cypress.env('JSON_HEADER') : Cypress.env('DEFAULT_HEADER'),
  }
  return originalFn(method, url, options)
})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ehsan