I updated the latest version of r language today. I find that I cannot draw graph use ggtern package. The wrong message is :":geom_point requires the following missing aesthetics: x and y.'' But I have defined x and y variables , I don't know how to fix it.
> ggtern(data=data.frame(x=2,y=4,z=3))+geom_point()
错误: geom_point requires the following missing aesthetics: x and y
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
geom_point requires the following missing aesthetics: x and y
Backtrace:
1. (function (x, ...) ...
2. ggtern:::print.ggplot(x)
4. ggtern:::ggplot_build.ggplot(x)
5. ggtern:::by_layer(function(l, d) l$compute_geom_1(d))
6. ggtern:::f(l = layers[[i]], d = data[[i]])
7. l$compute_geom_1(d)
8. ggplot2:::f(..., self = self)
9. ggplot2:::check_required_aesthetics(...)
Run `rlang::last_trace()` to see the full context.
>rlang::last_trace()
<error/rlang_error>
geom_point requires the following missing aesthetics: x and y
Backtrace:
x
1. +-(function (x, ...) ...
2. \-ggtern:::print.ggplot(x)
3. +-ggtern::ggplot_build(x)
4. \-ggtern:::ggplot_build.ggplot(x)
5. \-ggtern:::by_layer(function(l, d) l$compute_geom_1(d))
6. \-ggtern:::f(l = layers[[i]], d = data[[i]])
7. \-l$compute_geom_1(d)
8. \-ggplot2:::f(..., self = self)
9. \-ggplot2:::check_required_aesthetics(...)
I installed it once with my roommate’s computer, but it didn’t solve the problem. The problem still occurs on his computer. Maybe you can try to install it on your computer to see if the problem also occurs.
You have defined variables in a data frame but the error message is telling you that you haven't mapped any variable to the x and y aesthetic, in other words, you are missing arguments, see this example.
library(ggtern)
ggtern(data = data.frame(x=2,y=4,z=3), aes(x = x, y = y, z = z)) +
geom_point()
I try this both on my PC and Mac ,It doesn't work on both of my two computer. Before I update ggplot2,everything was fine ,but after I update R and ggplot2 yesterday, the wrong message appeared.
I can't reproduce your issue, I have shared a reproducible example and that is proof that the code I have shared with you actually works.
To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
I have been using this package for a long time. All my codes can work normally before the upgrade, but after the upgrade they all can’t run. I tried to install these packages on my friend’s computer where the R language has never been installed. I also can't run these codes, I think there is a problem with ggtern.