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 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.