I’m having a problem with the function p.adjust. I have a list containing 741 p-values and I want to use the p.adjust() function to correct for multiple testing (FDR testing). This is what I have so far:
> x <- as.vector(pvalues1)
> p.adjust(x, method="fdr" n=length(x))
But I get the following error
Error in order (p, decreasing = TRUE) :
unimplemented type 'list' in 'orderVector1'
Can anyone help me with this?
The problem you have is the your list containing the p-values is a vector already. What you wanted was a numeric vector. A list is just a general vector:
One option is to
unlist()the list, to produce a numeric vector:the benefit of that is that it preserves the names. An alternative is plain old
as.numeric(), which looses the names, but is otherwise the same asunlist():For big vectors, you might not want to use the names in
unlist(), so an alternative that will speed that version up is: