2

I'm trying to highlight 2 specific points with the following code:

p1 <- ggplot(HiBAP1517, aes(FE, DWSpk)) + 
  gghighlight_point(HiBAP1517, aes(FE, DWSpk), value == 51.875) + 
  geom_point(shape=16) + 
  geom_smooth(method=lm, se = F) + 
  theme(axis.title.x = element_text(color="black", size=14, face="bold"), 
        axis.title.y = element_text(color="black", size=14, face="bold"))

pfinal <- p1 + labs(y = expression("DM spk"^{-1}*"g"),
                    x = expression("FE"*(grainsg^{-1})))
pfinal

Getting the following error:

Error in mutate_impl(.data, dots) : Evaluation error: object 'value'not found.

pfinal <- p1 + labs(y = expression("DM spk"^{-1}*"g"), +
                    x = expression("FE"*(grainsg^{-1})))

Error: object 'p1' not found

pfinal 

Error: object 'pfinal' not found

Any ideas what I might be doing wrong? Thanks!

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Ale
  • 43
  • 6
  • 1
    Can you share the output of `dput(HiBAP1517)` so that others can [reproduce your problem](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Z.Lin Dec 10 '18 at 12:52
  • Entry,DWSpk,FE 1,1.335703125,36.075 2,1.0821875,45.79413708 3,1.28984375,36.925 5,0.910625,49.125 6,0.8728125,55.9 7,0.84125,56.925 8,0.93875,46.775 9,1.159453125,41.575 10,1.11375,40.45 Rialto,0.89140625,51.875 Savannah,1.33609375,35.275 – Ale Dec 10 '18 at 13:44

1 Answers1

1

You do not need to specify data and aes in gghighlight, it inherits from ggplot. And my guess is you do not have a variable named value in you dataframe HiBAP151. The condition in highlight needs to refer to your variables. So you probably want gghighlight(FE==51.875) or gghighlight(DWSpk==51.875). Additionally, gghighlight_point is deprecated, you should use gghighlight.

Erich Neuwirth
  • 943
  • 7
  • 13
  • Try with: gghighlight(FE==51.875), got back Error in ggplot_add.gg_highlighter(object, p, objectname) : there is no layer to highlight! – Ale Dec 09 '18 at 18:10