Problems installing/using package "emtrends"

Hello,

I have casually used R in the past but would consider myself definitely a novice. I am working with someone else's code (that I know has successfully worked) and I'm having issues installing and using the package "emtrends." Here is the code I've used:

install.packages("emtrends")
library(emtrends)

Here is the error I've received:

> install.packages("emtrends")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/gina7/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘emtrends’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
> library(emtrends)
Error in library(emtrends) : there is no package called ‘emtrends’
> 

Please note that (1) I have the emmeans package installed and working, which I've read is needed for emtrends; (2) I do have RTools installed, contradicting the error message I've received; (3) even though I received the same error messages yesterday, I was still able to get the emtrends function to work at that time - but not anymore.

I am baffled by the message "there is no package called ‘emtrends’" given that my friends' code has worked, and their are several websites describing the emtrends package. I even used the code "help(emtrends, package="emtrends")" and received the error "Error in find.package(if (is.null(package)) loadedNamespaces() else package, :
there is no package called ‘emtrends’".

I have the latest version of RStudio installed. Can someone help? Thank you.

There is a function named emtrends in the emmeans package, but I can't find any package named emtrends. Are you sure that such a package exists?

(post deleted by author)

When I use the emtrends function after invoking library(emmeans) (which runs successfully), I get the error
Error in emtrends(staying_asleep_ethrace_poisson, ~ethrace, var = "age", : could not find function "emtrends"

So I'm not sure what's going on!

If you run library(emmeans) and then ?emtrends, do you get a help listing for emtrends or an error? I just installed emmeans and can attest that emtrends is definitely there, as the following example shows.

library(emmeans)
#> Welcome to emmeans.
#> Caution: You lose important information if you filter this package's results.
#> See '? untidy'
fiber.lm <- lm(strength ~ diameter*machine, data=fiber)
fiber.emt <- emtrends(fiber.lm, "machine", var = "diameter")
fiber.emt
#>  machine diameter.trend    SE df lower.CL upper.CL
#>  A                1.104 0.194  9    0.666     1.54
#>  B                0.857 0.224  9    0.351     1.36
#>  C                0.864 0.208  9    0.394     1.33
#> 
#> Confidence level used: 0.95

Created on 2025-02-21 with reprex v2.1.1