R/ggplot2 - directlabels package generating errors even with given example code

250 Views Asked by At

I've installed the "directlabels" package from http://directlabels.r-forge.r-project.org/, along with its dependency "quadprog". The first example from that page works:

install.packages("directlabels", repo="http://r-forge.r-project.org")
library(lattice)
library(directlabels)
direct.label(xyplot(jitter(Sepal.Length)~jitter(Petal.Length),iris,groups=Species))

But the second example doesn't:

install.packages("ggplot2")
library(ggplot2)
data(BodyWeight,package="nlme")
p <- qplot(Time,weight,data=BodyWeight,colour=Rat,geom="line",facets=.~Diet)
direct.label(p,"first.qp")
direct.label(p,"last.qp")

I've tried running it on two computers: the work computer which is locked down and uses an older version of R (3.5.1), RStudio (1.1.463) and outdated package repository that required "quadprog" to be installed manually, and my home computer which has the latest version of R and RStudio and was able to install quadprog automatically.

Running direct.label(p,"first.qp") at work produces Error:xmust be a string or a R connection and at home produces Error in parse(text = x) : <text>:1:2: unexpected ';' 1: ~;.

If I just run direct.label(p) both work and home produce Error in switch(geom, density = "top.bumptwice", line = { : EXPR must be a length 1 vector. I also get this error with a basic ggplot of my own.

Is it possible to get this package working or is it just too old and poorly maintained these days?

1

There are 1 best solutions below

0
AudioBubble On

The rforge version is deprecated (development stopped in 2015 as mentioned here) and must not be used anymore.

You can either install the developmental version of directlabels from GitHub:

# In order to download and install a package from a GitHub hosted repository, install the 'devtools' library (if not available):
if(!require(devtools)) install.packages("devtools")
# Next, install your package using the install_github("username/repo") command:
devtools::install_github("tdhock/directlabels")

or fetch it directly from a CRAN mirror - this is the solution you've ventured into as per your comment above (i.e. install.packages("directlabels")), as "Installing without specifying the repository" defaults to the CRAN link for repos.

I suppose that the source of your installation method came from what's mentioned in http://directlabels.r-forge.r-project.org/, which was indeed last updated several years ago. For future reference to the package and/or documentation needs, please refer to https://tdhock.github.io/directlabels/ now instead. (the website link in the GitHub repo has been recently updated to that as well)