0

I tried to install cld function in R and failed many times. I did get the following response, can you suggest better way?

install.packages("cld", lib="C:/Program Files/R/R-4.0.4/library")  

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/
Warning in install.packages :
package ‘cld’ 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

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
Workneh
  • 1
  • 1
  • 1) install Rtools; 2) `cld` is a *function* in *package* `lsmeans`. You do not install the function, you install the package and then at the beginning of your script load it with `library(lsmeans)`. to make the function available. – Rui Barradas Mar 08 '21 at 08:49

1 Answers1

0

Use this as suggested by Russ Lenth

install.packages(c("multcomp", "multcompView", "emmeans"))

install.packages(c("multcomp", "multcompView", "emmeans")) # use this as suggested by Russ Lenth

library(multcomp)
library(multcompView)
library(emmeans)

# example from <https://www.rdocumentation.org/packages/lsmeans/versions/2.27-62/topics/cld>
warp.lm <- lm(breaks ~ wool * tension, data = warpbreaks)
warp.lsm <- lsmeans(warp.lm, ~ tension | wool)
cld(warp.lsm)                  # implicitly uses by = "wool"
cld(warp.lsm, by = "tension")  # overrides implicit 'by'

# Mimic grouping bars and compare all 6 means
cld(warp.lsm, by = NULL, Letters = "||||||||", alpha = .01)
# }
TarJae
  • 72,363
  • 6
  • 19
  • 66
  • Thanks for your answer. But, I could not also install multcomp due to the same reason. – Workneh Mar 08 '21 at 10:49
  • Have you installed `Rtools` as Rui Barradas suggested? If not -> Type `install.Rtools()` in the console and hit enter. – TarJae Mar 08 '21 at 12:50
  • 1
    This is not quite true. `cld()` is a generic function in **multcomp**. There is a method for it to use with `glht` objects in that package, and there is also a method for it to use with `emmGrid` objects in the **emmeans** package (not **lsmeans**). The latter requires the package **multcompView**. The **lsmeans** package is now just a frot end for **emmeans** that supports some of its ancient functionlity. You don't need it; even the `lsmeans()` function is in **emmeans**. – Russ Lenth Mar 08 '21 at 22:51
  • 1
    You do not need Rtools to install any of these. Just use `install.packages(c("multcomp", "multcompView", "emmeans"))` – Russ Lenth Mar 08 '21 at 22:53
  • Thank you Russ Lenth. I have edited my answer with your suggestion. – TarJae Mar 09 '21 at 07:26
  • 1
    You can also remove installing lsmeans and loading lsmeans. You do not need that oackage at all. – Russ Lenth Mar 11 '21 at 04:31