Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: ggtern does not work, broken with new ggplot2

Tags:

r

ggplot2

ggtern

I'm trying to use the ggtern package to plot some plots. It used to run on ggplot2, but now it doesn't work and breaks ggplot2.

When I run the following:

library(ggplot2)
qplot(1,2)
library(ggtern)
qplot(3,4)

df = data.frame(x = runif(50),
                y = runif(50),
                z = runif(50),
                Value = runif(50,1,10),
                Group = as.factor(round(runif(50,1,2))))
ggtern(data=df,aes(x,y,z,color=Group)) +
  theme_rgbw() +
  geom_point() + geom_path() +
  labs(x="X",y="Y",z="Z",title="Title")

qplot(1,2) works just fine, library(ggtern) gives me this (which may or may not be related to the problem):

Attaching package: ‘ggtern’

The following objects are masked from ‘package:ggplot2’:

    %+%, %+replace%, aes, calc_element, Geom, geom_segment, ggplot_build,
    ggplot_gtable, ggsave, theme, theme_bw, theme_classic, theme_get, theme_gray,
    theme_grey, theme_minimal, theme_set, theme_update

qplot(3,4) fails with this:

Error in FUN(X[[i]], ...) : attempt to apply non-function

And if I comment it out and it reaches the ggtern(... I get this:

Error in coord_tern() : could not find function "coord"

Obviously, something is wrong. Where do I start looking for what's wrong? What's this function coord and why is it gone?

like image 348
Gimelist Avatar asked Dec 31 '25 02:12

Gimelist


2 Answers

Yep, ggtern 2.0.1 is now available, published on CRAN a couple of days ago after completely re-writing the package to be compatible withggplot2 2.0.0. A summary of the new functionality in ggtern 2.0.X can be found here:

Here is what your code produces under the new package:

solution

like image 154
Nicholas Hamilton Avatar answered Jan 02 '26 15:01

Nicholas Hamilton


I ran into the same problem with ggtern faulting. My work around was downloading and installing the 1.0.1 version of ggplot2. Archived versions can be found at "cran.r-project.org" website at https://cran.r-project.org/src/contrib/Archive

like image 21
D Tuohey Avatar answered Jan 02 '26 15:01

D Tuohey