Could not find function "r.test"

Hi there!

I am new to R and RStudio. I only need it to compare two independent correlations with one another using r.test. However, regardless of which combination I put in the response is always "could not find function "r.test"". How can I solve this?

Thanks for your help in advance!

I'm not familiar with the r.test. What does it supposed to do?

It is for sure not included in base R, but it might be available in some package. Did you try to google around and see if it was implemented somewhere?

You may need to run library(psych) to be able to use r.test.

2 Likes

r.test belongs to the Psych package. Googling around did not help unfortunately, but the solution seems to have been the suggestion below.

You said you are new to R, so at the risk of telling you something you already know, I thought I might offer a bit more explanation. I've seen a lot of new useRs get tripped up in this same spot!

It's often surprising to people that installing R packages doesn't make them immediately available to use. A package also has to be loaded (super :nerd_face: R jargon: "attached") before R knows where to find its functions without extra guidance (packageName::functionName() will call functions from packages you have installed, but not loaded, since the part before the :: tells R where to look).

When you start up a new R session (or launch RStudio, which starts a new R session for you), a handful of packages are loaded by default (referred to as the "base packages", even though only one of them is actually named base!) Any other package that you've installed whose functions you want to use has to be loaded using library() every time you start a new R session.

This often strikes people as unintuitive (and maybe also a hassle), and it's definitely different from how a lot of other modern software works. However, the need to be explicit has significant benefits for reproducibility. R scripts typically start out with a few lines of library() statements that load the necessary packages, which is both convenient and sell-documenting. There are ways to make your favorite packages be autoloaded in every session, but that gets dangerous if reproducibility is important to you.

2 Likes