I have a list of p values indicated by
ord = sort(p_values, index = TRUE)
I want to obtain the index of values in this list that are less than 0.05.
I have a list of p values indicated by
ord = sort(p_values, index = TRUE)
I want to obtain the index of values in this list that are less than 0.05.
First I create random p-values:
p_values <- runif(10, 0, 1)
[1] 0.42179212 0.78151769 0.11912855 0.24357883 0.78714226 0.92601108 0.01192523 0.97904421 0.51560005 0.69564248
What you can do is order the p-values based on your certain criteria and select indices which is from the column ix, as @Vincent Guillemot also suggested in the comment. You can use the following code:
ord = sort(p_values, index = TRUE)
$x
[1] 0.01192523 0.11912855 0.24357883 0.42179212 0.51560005 0.69564248 0.78151769 0.78714226 0.92601108 0.97904421
$ix
[1] 7 3 4 1 9 10 2 5 6 8
ord$ix[ord$x <= 0.05]
Output:
[1] 7
Which means that the index 7 has a p-value lower than 0.05.