Displaying 1 result from an estimated 1 matches for "cor_withn".
2013 Feb 22
2
How to merge two functions into one?
...return(NA)
}
}
However I got this error(as some pairs of my data are less then 3):
Error in cor.test.default(x, y) : not enough finite
observations
in order to avoid this error and return NA when there are less than 3
pairs,this function does the job:
cor_withN <- function(...) {
res <- try(cor.test(...)$estimate, silent=TRUE)
ifelse(class(res)=="try-error", NA, res)
}
Both functions worked perfectly.How can we merge both functions into one
function so we calculate correlation when P value is (certain value,...