MattCowgill / ggannotate

Interactively annotate ggplots
Other
309 stars 20 forks source link

error when using a new source window #9

Closed wfmackey closed 4 years ago

wfmackey commented 4 years ago

Hello Matthew

Love the package! Great job!!

The ggannotate function works as expected:

image

But it errors when I use a source window in R Studio (ie I 'pop out' a window):

image

When running the ggannotate add-in with code highlighted from a source window, I will get the error:

 ggannotate:::ggannotate()
Error in UseMethod("primary_selection") : 
  no applicable method for 'primary_selection' applied to an object of class "NULL"

Many thanks

MattCowgill commented 4 years ago

I'm unsure whether this can be fixed - it might be a limitation in the RStudio API that I use to detect the user's current selection. I'll try.

MattCowgill commented 4 years ago

Hiii this doesn't seem to be possible. But you can invoke ggannotate like this:

library(ggplot2)
p <- ggplot(mtcars, 
            aes(x = wt, y = mpg)) + 
  geom_point() 

ggannotate::ggannotate(p)