export a ggplot with geom_errorbar () into excel in an editable format using the read_xlsx function from the office package

Viewed 15

Does anyone know a way I can fix this clitch I am getting while trying to export my ggplot into excel to further edit it? It works fine when I remove geom_errorbar() part of the plot but I would like to get it to work with that part. Is it just an un editable part of the graph so it wont export? If so, does anyone know of a way I can get an error bar that works?

################ Example for stack
library(tidyverse)
library(officer)
library(rvg)
data <- c(1:50)

data <- as.data.frame(data)

plott<- ggplot(data, aes(data, data)) +
  geom_errorbar(data=data, mapping=aes(ymax = data + 5, ymin = data - 5), color="808080") + theme_bw() + labs(y="", x= "")  +
  theme_classic() + theme(text=element_text(size=20,  family="serif", face = "bold", color = "black")) + geom_line(size = 1) + 
   theme(axis.line = element_line(colour = 'black', size = .5)) 
  
plott

doc <- read_xlsx()
doc <- xl_add_vg(doc, sheet = "Feuil1", code = print(plott),
                 width = 10, height = 6, left = 1, top = 2 )
print(doc, target = "EPA.xlsx")

0 Answers
Related