From my variable in column 1 from the pval data, I want to sum all the pval that are less than 0.05 and find the proportion by dividing that sum by 10000 because my sample size is 10000.
I keep getting the error that the condition has length >1.
I have tried this:
if (pval[,1]<0.05)
{
p1prop<-sum(pval[,1])/10000
}
and this:
if (pval[,1]<0.05)
{sum(pval[,1])/10000
}
How can I correct this?
If you literally just want the proportion this will work:
What that is doing is first creating a logical vector (TRUE if the condition is true, FALSE if it is not). Then, since TRUE will be treated as 1 and false will be treated as 0, add them up.