export
export copied to clipboard
doc_parse_raw
Hi, When I use graph2ppt on ubuntu system platform. It report the error:
Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html, :
StartTag: invalid element name [68]
And below is the details: R version 3.4.4 (2018-03-15) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.5 LTS
Matrix products: default BLAS: /usr/lib/libblas/libblas.so.3.6.0 LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] export_0.2.2.9000
Could you please provide a full reproducible example, so we can try on our end?
I just use very simple example:
library(export)
p<-plot(1:10)
graph2ppt(x=p,file="test.pptx")
I run this on ubuntu.
Is the problem here not just that you are trying to pass a base R plot as an object, which is not possible? (You can only do that with ggplots) So you would have to do instead
library(export)
plot(1:10)
graph2ppt(file="test.pptx")
Does that work OK for you?
I am sorry I don't have graphic interface on my server.
Ha then you would have to use
library(export)
plot.fun = function(){
print(plot(1:10))
}
graph2ppt(fun=plot.fun, file="test.pptx")
I think... (You have to set your working directory first, or include the path in the filename)
I try it but it doesn't work. Thanks!
And does exporting ggplots work for you? E.g.
library(export)
library(ggplot2)
library(datasets)
x=qplot(Sepal.Length, Petal.Length, data = iris,
color = Species, size = Petal.Width, alpha = I(0.7))
graph2ppt(x=x, file="test.pptx")
One other thing that may be causing problems is that I believe export is expecting the latest version of R, R 3.5.1... When I try on my ubuntu workstation here it all works so I am not quite sure where the problem is coming from... Could be that it has to do something with the fact you don't have a graphics interface on your server (we've always tested the package from within RStudio with a graphics device open).... But I'll look into it...
Could you try if this works on your configuration
library(officer)
doc <- read_pptx()
doc <- add_slide(doc, "Title and Content", "Office Theme")
doc <- ph_with_vg_at(doc, code = barplot(1:5, col = 2:6),
left = 1, top = 2, width = 6, height = 4)
print(doc, target = "vg.pptx")
If that one doesn't work without a graphics interface then I'm afraid export
also won't work, since we rely on officer
and rvg
...
Hi, I try it. it works. Thanks!
So officer
works, but the export
package still doesn't work? Or does exporting ggplots
work also in export
?
Yes. export
seems doesn't work but officer
did. I haven't try ggplots
.
OK I'll look into it then, because that means I should be able to fix export
to make it work for this configuration... Would you know by any chance how to set up an R installation without a screen device?
It automatic setup on the server. Btw, the thing happened since I want build an shiny app("http://hurlab.med.und.edu/VennDetail/") by using your export
package to export ppt and doc. Now it works. I found the reason also comes from UpSetR
when I try to save the upset
figure which always call grid.newpage
function. I modified the upset
code and used the ph_with_vg_at
function.
We just did an update to the github export version to make it work also for R users without a screen device. You can install it with
devtools::install_github("tomwenseleers/export")
See if that works for you!
OK. I will try the new version. Thanks!
And did it work for you in the end?
Hi Tom,
I am having this same issue. graph2ppt works in Rstudio when I export a dendrogram (or anything):
Example:
plot(hc.dend)
graph2ppt(file="dendrograms.pptx", append=F)
But returns the error below when I run it as an Rscript from the bash command line (no screen device):
Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html, :
StartTag: invalid element name [68]
Calls: graph2ppt ... as_xml_document.character -> read_xml.raw -> doc_parse_raw
I re-installed the package using devtools::install_github("tomwenseleers/export") & that didn't fix it.
Thanks
Hi, Sorry for the late reply. it seems the new version still not works. Kai