Code Monkey home page Code Monkey logo

export's Introduction

version downloads

export version 0.3.0

export is an R package to easily export active R graphs and statistical output in publication quality to Microsoft Office (Word, PowerPoint and Excel), HTML and Latex.

Features

  • Save active R graphs or ggplot2, lattice or base R plots in publication quality to Microsoft Word, Powerpoint, or various other bitmap or vector formats using a single command with sensible defaults.
  • Fully editable Powerpoint vector format output, enabling manual tidy-up of plot layout.
  • Save the output of statistical analysis in R as tables in Excel, Word, PowerPoint, Latex or HTML documents.
  • Customize formatting of R outputs.

Installation

  • The export package works cross-platform on Windows, Ubuntu & Mac. Some Mac distributions though do not have the cairo device installed by default, and this is required by the export package. This problem is solved if Mac users first install XQuartz, which is available for free from https://www.xquartz.org/.

  • You can report bugs at http://github.com/tomwenseleers/export/issues. If you report a bug, try to send a reproducible example and don't forget to send the result of

sessionInfo()

Official CRAN release

Get the latest official release from CRAN:

install.packages("export")

Github development version

Get the latest development version:

install.packages("officer")
install.packages("rvg")
install.packages("openxlsx")
install.packages("ggplot2")
install.packages("flextable")
install.packages("xtable")
install.packages("rgl")
install.packages("stargazer")
install.packages("tikzDevice")
install.packages("xml2")
install.packages("broom")
install.packages("devtools")
devtools::install_github("tomwenseleers/export")

Getting Started

library(export)
      
?graph2ppt
?graph2doc
?graph2svg
?graph2png
?table2ppt
?table2tex
?table2excel
?table2doc
?table2html

## export of ggplot2 plot
library(ggplot2)
qplot(Sepal.Length, Petal.Length, data = iris, color = Species, 
      size = Petal.Width, alpha = I(0.7))
# export to Powerpoint      
graph2ppt()      
graph2ppt(file="ggplot2_plot.pptx", aspectr=1.7)
# add 2nd slide with same graph 9 inches wide and A4 aspect ratio
graph2ppt(file="ggplot2_plot.pptx", width=9, aspectr=sqrt(2), append=TRUE) 
# add 3d slide with same graph with fixed width & height
graph2ppt(file="ggplot2_plot.pptx", width=6, height=5, append=TRUE) 
# export to Word
graph2doc()
# export to bitmap or vector formats
graph2svg()
graph2png()
graph2tif()
graph2jpg()

## export of aov Anova output
fit=aov(yield ~ block + N * P + K, npk)
x=summary(fit)
# export to Powerpoint
table2ppt(x=x)
table2ppt(x=x,file="table_aov.pptx")
table2ppt(x=x,file="table_aov.pptx",digits=4,append=TRUE)
table2ppt(x=x,file="table_aov.pptx",digits=4,digitspvals=1,
          font="Times New Roman",pointsize=16,append=TRUE)
# export to Word
table2doc(x=x)
# export to Excel
table2excel(x=x, file = "table_aov.xlsx",digits=4,digitspvals=1,
            sheetName = "Anova_table", add.rownames = TRUE)
# export to Latex
table2tex(x=x)
# export to HTML
table2html(x=x)

License

The export package is licensed under the GPLv2.

export's People

Contributors

cvanderaa avatar davidgohel avatar tomwenseleers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

export's Issues

Error in xpath_search(x$node, x$doc, xpath = xpath, nsMap = ns, num_results = 1) : Memory allocation failed : growing nodeset hit limit

Hi,
I get an error when using graph2ppt():

Error in xpath_search(x$node, x$doc, xpath = xpath, nsMap = ns, num_results = 1) :
Memory allocation failed : growing nodeset hit limit
[2]
Calls: graph2ppt ... xml_find_first -> xml_find_first.xml_node -> xpath_search -> .Call

And I get some information from https://stackoverflow.com/questions/40159864/getting-memory-allocation-failed-growing-nodeset-hit-limit-with-xml2-package. Unfortunately,I don't solve this problem. I will pleasure if you can give advice.

Session crashes when arguments are used in graph2ppt()

Hi,

I installed this package a few days ago and experienced a lot of R crashes trying to use it, both in R only and RStudio, as well as both on Linux Mint 17 x64 and Windows 7 x64.

I initially had trouble pinpointing what was exactly causing the issue, as the crash log first reported an issue with Java and core dump on my Linux machine. But after fixing this issue and many additional attempts, I noticed that the PPT export was working as long as I was using just the commandline graph2ppt(), and not something like graph2office(type="PPT", "Blah blah blah.ppt") or graph2ppt("Blah blah blah.ppt"). Same with pptx as an extension. I experienced the crashes even with simple filenames without special characters or spaces. The only way I could get the command not to crash the session was by setting no argument in the brackets.

I can observe this behaviour with any type of graph on both my Windows and Linux machines, so the following basic code should allow reproducing the crash:

hist(rnorm(1000))
graph2ppt("test.ppt")

I'm using R 3.2.2 and latest version of RStudio.

This package is very useful and I'm very happy that I could finally use it, thanks a lot for your work, and hope you'll find a way to fix this bug.

Update of `export` is recommended (R 3.2.5)

I would like to ask to update the functions of the package export, as warnings arise using R v3.2.5 and official examples from the package:

library(ggplot2)
x=qplot(Sepal.Length, Petal.Length, data = iris, color = Species, 
      size = Petal.Width, alpha = I(0.7))
x
graph2ppt(x=x)

Warning message:

Exported graph as Rplot.pptx
Warning message:
argument fontname is deprecated; please usefontname_serif, fontname_sans, fontname_mono,fontname_symbol instead. 

Error in colformat_int

Whatever I try, I am getting this error

table2ppt(x=x,file=filen, digits = 1, digitspvals = 3)

Error in colformat_int(x = tab, col_keys = col.df) :
unused argument (col_keys = col.df)

Even with the very basic example from the vignette run in an otherwise empty script I get this error. Am I doing something wrong here?

Could not find layout named "Blank" in master named "Office Theme"

While trying to add a plotly plot, I am getting the following error

Error in add_slide(doc, layout = "Blank", master = "Office Theme") : 
  could not find layout named "Blank" in master named "Office Theme"

Code used

p = plot_ly( ldf, x = ~dates, y = ~m, type = 'scatter', mode = 'lines', name = 'm' ) %>%
  
  layout( title = paste0( 'Plot of M values over time', tag ) )

graph2ppt(x = p, file="D:\\projects\\Chetan\\Variation of Values.pptx", width=6, height=5, append=T) 

Error during installation

Hi! I tried installing the github version (sessionInfo() below), but I received the following error:

Error: Failed to install 'export' from GitHub:
  lazy-load database '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/processx/R/processx.rdb' is corrupt
In addition: Warning message:
In get0(oNam, envir = ns) : internal error -3 in R_decompress1

I accepted the update of all packages, including those with source code versions more up-to-date than available binaries.

Below is the result of my sessionInfo(). Thank you very much for any guidance on how to solve this.

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS  10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] gdtools_0.2.2   officer_0.3.15  rvg_0.2.5       pins_0.4.4      DT_0.15        
 [6] stargazer_5.2.2 covidcast_0.2.0 jsonlite_1.7.1  httr_1.4.2      plotly_4.9.2.1 
[11] rdrop2_0.8.2.1  writexl_1.3.1   lubridate_1.7.9 forcats_0.5.0   stringr_1.4.0  
[16] dplyr_1.0.2     purrr_0.3.4     readr_1.3.1     tidyr_1.1.2     tibble_3.0.4   
[21] ggplot2_3.3.2   tidyverse_1.3.0

loaded via a namespace (and not attached):
  [1] assertive.base_0.0-7       colorspace_1.4-1           ellipsis_0.3.1            
  [4] rprojroot_1.3-2            fs_1.5.0                   rstudioapi_0.11           
  [7] farver_2.0.3               remotes_2.2.0              assertive.sets_0.0-3      
 [10] fansi_0.4.1                xml2_1.3.2                 assertive.data.uk_0.0-2   
 [13] codetools_0.2-16           splines_4.0.2              knitr_1.30                
 [16] pkgload_1.1.0              assertive_0.3-6            assertive.data.us_0.0-2   
 [19] broom_0.7.2                dbplyr_1.4.4               compiler_4.0.2            
 [22] backports_1.2.0            assertthat_0.2.1           Matrix_1.2-18             
 [25] lazyeval_0.2.2             cli_2.2.0                  prettyunits_1.1.1         
 [28] htmltools_0.5.0            tools_4.0.2                gtable_0.3.0              
 [31] glue_1.4.2                 rappdirs_0.3.1             tinytex_0.27              
 [34] Rcpp_1.0.5                 cellranger_1.1.0           vctrs_0.3.5               
 [37] nlme_3.1-148               crosstalk_1.1.0.1          assertive.files_0.0-2     
 [40] assertive.datetimes_0.0-3  assertive.models_0.0-2     xfun_0.19                 
 [43] ps_1.4.0                   testthat_2.3.2             rvest_0.3.6               
 [46] lifecycle_0.2.0            devtools_2.3.1             scales_1.1.1              
 [49] hms_0.5.3                  assertive.matrices_0.0-2   assertive.strings_0.0-3   
 [52] yaml_2.2.1                 curl_4.3                   memoise_1.1.0             
 [55] stringi_1.5.3              desc_1.2.0                 filelock_1.0.2            
 [58] pkgbuild_1.1.0             zip_2.1.1                  cpp11_0.2.4               
 [61] rlang_0.4.9                pkgconfig_2.0.3            systemfonts_0.3.2         
 [64] evaluate_0.14              lattice_0.20-41            assertive.data_0.0-3      
 [67] htmlwidgets_1.5.2          labeling_0.4.2             assertive.properties_0.0-4
 [70] processx_3.4.5             tidyselect_1.1.0           assertive.code_0.0-3      
 [73] magrittr_2.0.1             R6_2.5.0                   generics_0.1.0            
 [76] DBI_1.1.0                  pillar_1.4.7               haven_2.3.1               
 [79] withr_2.3.0                mgcv_1.8-31                assertive.numbers_0.0-2   
 [82] modelr_0.1.8               crayon_1.3.4               assertive.types_0.0-3     
 [85] uuid_0.1-4                 utf8_1.1.4                 rmarkdown_2.5             
 [88] usethis_1.6.1              grid_4.0.2                 readxl_1.3.1              
 [91] data.table_1.13.2          blob_1.2.1                 callr_3.5.1               
 [94] reprex_0.3.0               digest_0.6.27              openssl_1.4.2             
 [97] munsell_0.5.0              viridisLite_0.3.0          assertive.reflection_0.0-5
[100] sessioninfo_1.1.1          askpass_1.1   

Trouble intalling the export package

Hi,
I've been using the export package in the past, and found it to be very useful.
I'm now trying to download it to a new computer, with no success. No matter how I try, I keep getting errors, and the process fails.
I would very much appreciate any help on this matter.

Noa

Error in options()$device != FALSE

Hello~

I just tested if I installed it right, and got the following error report.

Error in options()$device != FALSE :
comparison (2) is possible only for atomic and list types

The test code is quite simple, as follows:
AA <- 1:100
BB <- 2*AA
plot(AA,BB)
graph2ppt(file="AA_BB_test.ppt")

Could you please tell me what might be wrong? Thanks very much!

Best regards,

Tricia

sessionInfo()

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936
[2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] export_0.2.2.9000 devtools_2.2.2 usethis_1.5.1

loaded via a namespace (and not attached):
[1] rgl_0.100.50 Rcpp_1.0.3 lattice_0.20-38
[4] tidyr_1.0.2 prettyunits_1.1.1 ps_1.3.2
[7] assertthat_0.2.1 rprojroot_1.3-2 digest_0.6.25
[10] mime_0.9 R6_2.4.1 backports_1.1.5
[13] evaluate_0.14 pillar_1.4.3 gdtools_0.2.1
[16] rlang_0.4.4 curl_4.3 uuid_0.1-4
[19] miniUI_0.1.1.1 data.table_1.12.8 callr_3.4.2
[22] flextable_0.5.8 rmarkdown_2.1 desc_1.2.0
[25] webshot_0.5.2 htmlwidgets_1.5.1 shiny_1.4.0
[28] broom_0.5.5 compiler_3.6.3 httpuv_1.5.2
[31] xfun_0.12 pkgconfig_2.0.3 systemfonts_0.1.1
[34] base64enc_0.1-3 pkgbuild_1.0.6 rvg_0.2.4
[37] htmltools_0.4.0 tidyselect_1.0.0 tibble_2.1.3
[40] fansi_0.4.1 crayon_1.3.4 dplyr_0.8.4
[43] withr_2.1.2 later_1.0.0 grid_3.6.3
[46] jsonlite_1.6.1 xtable_1.8-4 nlme_3.1-144
[49] lifecycle_0.1.0 magrittr_1.5 zip_2.0.4
[52] cli_2.0.2 stringi_1.4.6 fs_1.3.1
[55] promises_1.1.0 remotes_2.1.1 testthat_2.3.2
[58] xml2_1.2.2 ellipsis_0.3.0 generics_0.0.2
[61] vctrs_0.2.3 openxlsx_4.1.4 stargazer_5.2.2
[64] tools_3.6.3 manipulateWidget_0.10.1 glue_1.3.1
[67] officer_0.3.7 purrr_0.3.3 crosstalk_1.0.0
[70] fastmap_1.0.1 processx_3.4.2 pkgload_1.0.2
[73] sessioninfo_1.1.1 memoise_1.1.0 knitr_1.28

Warnings in table2*** functions

Hi,

Several functions of table2*** (i.e. table2doc()) outputs warnings about flextable::colformat_***.

export::table2doc(iris)
#> Warning in colformat_num.flextable(x = tab, col_keys = col.other, digits =
#> digits): argument col_keys is deprecated in favor of argument j
#> Warning in colformat_int.flextable(x = tab, col_keys = col.df): argument
#> col_keys is deprecated in favor of argument j
#> Warning in colformat_num.flextable(x = tab, col_keys = col.pval, digits = ):
#> argument col_keys is deprecated in favor of argument j
#> Exported table as Rtable.docx
#> Error in knit_print.flextable(x, ...): unsupported format for flextable rendering:markdown_strict

This is because the argument col_keys are deprecated (should use j instead).

I found around here in this code.

https://github.com/tomwenseleers/export/blob/master/R/table2office.R#L281
https://github.com/tomwenseleers/export/blob/master/R/table2office.R#L282
https://github.com/tomwenseleers/export/blob/master/R/table2office.R#L283

Error in export of plots containing polygons (R function polygon())

Plots the wrong polygon in export to Powerpoint. Other exports from R (my example contains pdf) work correctly and display the correct polygon. The error only occurs for selected polygons and not all polygons.

Attached example plots a normal distribution and shades a selected area under the curve. For easier bug reporting, a fresh R session was started before sourcing the example.

Attached files:
export-example.txt - Reproducible example to create the examples for Powerpoint and R export. Github does not support .R files so please rename to export-example.R
sessionInfo.txt - R session info created by sessionInfo()
areaUnderCurve.pdf, areaUnderCurve.pptx - examples created by R export

export-example.txt
sessionInfo.txt
areaUnderCurve.pdf
areaUnderCurve.pptx

I can not install the export package.

I tried the following ways to install export, but neither of them worked:
1.
install.packages("export")
library(export)

Error:
image

install.packages("devtools")
library(devtools)
devtools::install_github("tomwenseleers/export", force = TRUE)
library(export)
RGL_USE_NULL = TRUE; options(rgl_useNULL = TRUE)
library(export)

Error:
image

Could you please let me know how to install export package in this case? Thanks a lot!

Problem with exporting maps properly when ggmap is invoked

for example

CenterOfMap <- geocode("Bahrain")
Bahrain <- get_map(c(lon=CenterOfMap$lon, lat=CenterOfMap$lat), zoom = 10, maptype = "satellite", source = "google")
BahrainMap <- ggmap(Bahrain)
BahrainMap
BahrainMap2<-BahrainMap + geom_point(aes(x =50.626444, y = 26.044472), color="red", size = 3)+
  annotate(geom="text", x=50.55, y=26.06,label="Bahrain",color="black", size = 6)+
  labs(x = 'Longitude', y = 'Latitude')+
ggtitle('Type Location')
BahrainMap2
graph2ppt(file="pseudotriloculina.pptx", width=5, height=5)
graph2ppt(file="pseudotriloculina.pptx", width=10, height=10,append=T) # append table to previous slide
graph2ppt(file="pseudotriloculina.pptx", append=T) # append table to previous slide

This was the result i got,
pseudotriloculina.pptx

Thank you in anticipation fo your help.

Trouble when saving ggplot graph with superscripts to pptx

Hi,
I get the following error when trying to save the plot:
Error in grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, :
Metric information not available for this family/device
I can save it with ggsave, and plot it on the screen, but can't export to ppt.

library(ggplot2)
library(export)

P<-c(rep(0,times=18),rep(0.5,times=18),rep(5,times=18),rep(50,times=18))
P<-as.factor(P)
N<-rep(c(rep(10,times=6),rep(30,times=6),rep(50,times=6)), times=4)
N<-as.factor(N)
set.seed(42)
Y<-runif(n=72)*10

dat<-data.frame(P=P,N=N,Y=Y)

test<-ggplot(dat, aes(x=P, y=Y)) + geom_boxplot(position="dodge", aes(fill=N))+
ylab(expression(paste('Measurement (µmol ',g^{-1},' root FW)')))+
xlab(expression(paste('P supply (mg ',kg^{-1},' soil)')))+
labs(fill=expression(paste('N (mg ',kg^{-1},')')))
test

graph2ppt(test, file="test.pptx")

I hope you can help!

Cheers,
Anna

sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_Australia.1252
[2] LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

other attached packages:
[1] gdtools_0.1.4 export_0.2.1 ggplot2_2.2.1 rJava_0.9-8

loaded via a namespace (and not attached):
[1] Rcpp_0.12.10 knitr_1.14 xml2_1.1.1
[4] magrittr_1.5 ReporteRsjars_0.0.2 munsell_0.4.3
[7] xtable_1.8-2 colorspace_1.2-6 R6_2.1.2
[10] plyr_1.8.4 dplyr_0.5.0 tools_3.3.3
[13] grid_3.3.3 gtable_0.2.0 png_0.1-7
[16] rvg_0.1.3.9000 R.oo_1.21.0 DBI_0.4-1
[19] htmltools_0.3.5 rgl_0.97.0 lazyeval_0.2.0
[22] assertthat_0.1 digest_0.6.9 tibble_1.1
[25] shiny_1.0.0 tidyr_0.6.1 officer_0.1.1
[28] purrr_0.2.2 htmlwidgets_0.8 ReporteRs_0.8.8
[31] base64enc_0.1-3 R.utils_2.5.0 rtable_0.1.5
[34] mime_0.5 labeling_0.3 scales_0.4.1
[37] R.methodsS3_1.7.1 jsonlite_1.1 httpuv_1.3.3

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

installation

Hi
I am trying to install export from github to Rstudio based on R 4.0 and this is what I got (below). Any help will be greatly appreciated because export is an extremely useful package.

devtools::install_github("tomwenseleers/export")
WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools custom from https://cran.r-project.org/bin/windows/Rtools/.
Downloading GitHub repo tomwenseleers/export@master
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All
2: CRAN packages only
3: None
4: httpuv (1.5.3.1 -> 1.5.4 ) [CRAN]
5: later (1.0.0 -> 1.1.0.1) [CRAN]
6: vctrs (0.3.0 -> 0.3.1 ) [CRAN]

Enter one or more numbers, or an empty line to skip updates:

WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools custom from https://cran.r-project.org/bin/windows/Rtools/.
√ checking for file 'C:\Users\Owner\AppData\Local\Temp\RtmpWA1TdW\remotes381826937dd\tomwenseleers-export-269abaf/DESCRIPTION' (442ms)

  • preparing 'export':
    √ checking DESCRIPTION meta-information ...
  • excluding invalid files
    Subdirectory 'R' contains invalid file names:
    'export' 'export.rdb' 'export.rdx'
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
  • building 'export_0.2.2.9001.tar.gz'

Installing package into ‘C:/Users/Owner/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)

  • installing source package 'export' ...
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'export'
    finding HTML links ... done
    graph2bitmap html
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/graph2bitmap.Rd:64: file link 'tiff' in package 'grDevices' does not exist and so has been treated as a topic
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/graph2bitmap.Rd:64: file link 'jpeg' in package 'grDevices' does not exist and so has been treated as a topic
    graph2office html
    graph2vector html
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/graph2vector.Rd:68: file link 'svg' in package 'grDevices' does not exist and so has been treated as a topic
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/graph2vector.Rd:68: file link 'cairo_pdf' in package 'grDevices' does not exist and so has been treated as a topic
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/graph2vector.Rd:68: file link 'cairo_ps' in package 'grDevices' does not exist and so has been treated as a topic
    rgl2bitmap html
    table2office html
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/table2office.Rd:69: file link 'tidy' in package 'broom' does not exist and so has been treated as a topic
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/table2office.Rd:71: file link 'tidy' in package 'broom' does not exist and so has been treated as a topic
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/table2office.Rd:105: file link 'tidy' in package 'broom' does not exist and so has been treated as a topic
    table2spreadsheet html
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/table2spreadsheet.Rd:61: file link 'tidy' in package 'broom' does not exist and so has been treated as a topic
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/table2spreadsheet.Rd:63: file link 'tidy' in package 'broom' does not exist and so has been treated as a topic
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/table2spreadsheet.Rd:97: file link 'tidy' in package 'broom' does not exist and so has been treated as a topic
    table2tex html
    Rd warning: C:/Users/Owner/AppData/Local/Temp/RtmpElaXyQ/R.INSTALL8c042841a65/export/man/table2tex.Rd:52: file link 'tidy' in package 'broom' does not exist and so has been treated as a topic
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    *** arch - i386
    *** arch - x64
    ** testing if installed package can be loaded from final location
    *** arch - i386
    *** arch - x64
    ** testing if installed package keeps a record of temporary installation path
  • DONE (export)

The command graph2ppt works though

Export splm object

Hi! I'm trying to export an splm regression, because I saw here that is possible. But I have an error:

Error in table2spreadsheet(..., type = "XLS") : splm is currently not supported by table2office

Is there still a way to export a splm object?

Here is the code:

library(splm)
library(export)

#loading data
data(Insurance)
data(itaww)

# preparing regression
w <- mat2listw(itaww)
reg <- log(ppcd) ~ log(rgdp) + log(bank) + log(den) + rirs +
  log(agen) + school + vaagr + log(fam) + d99 + d00 +
  d01 + d02 

# splm reg

splm_reg <- spml(reg, data = Insurance, listw =w, model="pooling", spatial.error="none",  lag=FALSE)

#exporting splm regression
table2excel(splm_reg, file=filen, sheetName="x", digits = 1, digitspvals = 3)

Error when trying to update

Hi, I get the below error when trying to update the package with devtools::install_github('tomwenseleers/export',local = F).

* installing *source* package ‘export’ ...
** R
** data
** inst
** preparing package for lazy loading
Warning: replacing previous import ‘ReporteRs::renderFlexTable’ by ‘rtable::renderFlexTable’ when loading ‘export’
Error : .onLoad failed in loadNamespace() for 'rgl', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Users/user.name/Library/R/3.3/library/rgl/libs/rgl.so':
  dlopen(/Users/user.name/Library/R/3.3/library/rgl/libs/rgl.so, 6): Library not loaded: /opt/X11/lib/libGLU.1.dylib
  Referenced from: /Users/user.name/Library/R/3.3/library/rgl/libs/rgl.so
  Reason: image not found
ERROR: lazy loading failed for package ‘export’
* removing ‘/Users/user.name/Library/R/3.3/library/export’
* restoring previous ‘/Users/user.name/Library/R/3.3/library/export’
Error: Command failed (1)

issues about graph2ppt

Hi, thank you for you great tool! It is very useful for us. However, I got a question about graph2ppt function. When I use graph2ppt, I found that I can not move all elements in my PPT, which means I can only move the title, axis, and figure legend and can not move the point in my figure. How can I solve it?

Finally solving the export installation issue ... totally the fault of rJava

After wasting a full day reinstalling r, studio, java and so on... I stumbled on this two webpages that totally fixed my problem.... they are easy to follow an will solve your problem in 5 mins

  1. http://www.snaq.net/software/rjava-macos.php, for directing R to your java installation folder
    you can skip all the detailed explanation ( very useful though) and go straight to the "Quick version" I configuration section.
  2. https://stackoverflow.com/questions/47658210/loading-rjava-on-mac-os-high-sierra?rq=1 for installing rJava from source via terminal.

Unavailable for R version

Hi Tom and Christophe,
Your export package is not available for my R version 3.6.1.
Can you make this available, or can you tell me which R version you would recommend instead?
Kind regards!

graph2ppt error in an rshiny

Hi Sir,
I am developing a Rshiny App with your package to export figures in .pptx format.
But the figure generated by graph2ppt function has some error, the gap of world and number of the axis was filled by black color.
01
The function works well on Windows or Ubuntu, but it can not work correctly in an R shiny.
I do not know how to get the solution to the error.
Any reply will be appreciated!
Thanks!

  • [ ]

Greek letters and symbols not supported

Hello,

using graph2ppt() the greek letters and symbols are converted to squares (this issue has already been raised here by scs some years ago).
For instance, the code

par(mar = c(5, 5, 1, 1))
plot(0, ylab = expression(paste("E (mmol m"^-2, " s"^-1, ")", sep = "")), cex.lab = 1.5)
legend("topleft", expression(paste(sigma, " = ", 1, " ")), cex = 2)
graph2ppt(file = "test.pptx")

produces this plot in R:
test_R
but this plot when saved as pptx:
test_PPT

Moreover, the letters of the y-axis are not properly aligned (the 's' should be slightly more on the left to be aligned with the 'm').
The generated pptx is attached: test.pptx

Thanks for your help.

Error in graph2ppt()

Hi,

I enjoy the export package very much. However recently, I started getting the following error:
Exported graph as ggplot_attempt_distribution_beakin.pptx
Warning message:
argument fontname is deprecated; please usefontname_serif, fontname_sans ,fontname_mono,fontname_symbol instead.

Do you have any idea what can be the problem? and how can I fix this?

Thanks in advance,

Noa

graph2ppt error

Thank you for this great package! I am trying to export this image from R studio using graph2ppt but I get this error even though I have the latest version of export installed from gitgub:
Error: 'ph_with_vg_at' is defunct.
Use 'officer::ph_with' instead.

This is the code I have used to generate my plot:
p <- ggboxplot(na.omit(rdf), x = "Group", y = "Value", fill="Group", outlier.shape=NA, alpha=0.7)
p <- p + geom_jitter(position=position_jitter(width=0.1,height=0))
p <- p + theme_bw()
p <- p + theme(axis.text.x = element_text(size=14), legend.position = "none")
p <- p + geom_violin(alpha=0.3, scale = "width", position = position_dodge(width = .3),size=0.5,color = NA,aes(fill=Group))
p <- p + scale_fill_viridis_d(option = "viridis")
p <- p + stat_compare_means(comparisons = my_comparisons, size=5, family= "Arial", fontface= "bold")
#p <- p + stat_compare_means(label.y=max(rdf$Value,na.rm=T)+5, size=7, family="Arial", fontface= "bold")
p <- p + ylab("Total No. of Tumors") + xlab("")
p <- p + theme(text=element_text(family="Arial", face = "bold", size=14))
p <- p + theme(aspect.ratio = 1)
plot(p)
graph2ppt(x=p, file='FVB.pptx', append=TRUE)

image

graph2ppt() doesn't work1

Thanks for Tomwenseleers job in R packages-export, it is so wonderful that I have spent several hours to install it.
however, once graph2ppt() was input where I wanted to save my plot generated by R, this bug would appear.

Error: 'ph_with_vg_at' is defunct.
Use 'officer::ph_with' instead.
See help("Defunct")

So I seek help here!
@tomwenseleers

Update for officeR?

Hello,

Any chance export will be updated given that reporteRs is deprecated in favor of officeR due to java capability issues?

Thanks!

Having problem installing the "export" package

Hi, thanks for the package~
I tried to install the package using the code as below

devtools::install_github("tomwenseleers/export")

And at the very end it shows:

* installing *source* package ‘export’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (export)

I thought the package has already installed, yet when I try to load it, I failed.

> library(export)
Registered S3 methods overwritten by 'broom':
  method             from
  augment.rowwise_df     
  augment.tbl_df         
  glance.rowwise_df      
  glance.tbl_df          
  tidy.rowwise_df        
  tidy.tbl_df            
错误: package or namespace load failed for ‘export’:
 loadNamespace()里算'broom'时.onLoad失败了,详细内容:
  调用: get0(oNam, envir = ns)
  错误: lazy-load database '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/backports/R/backports.rdb' is corrupt
此外: Warning messages:
1: In get0(oNam, envir = ns) : 重新评估被中断的许诺
2: In get0(oNam, envir = ns) : internal error -3 in R_decompress1

And here is my results of sessionInfo( ), I think this problem may associated with the R version. Since I used to install the package successfully in R version 3.5.

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] zh_CN.UTF-8/zh_CN.UTF-8/zh_CN.UTF-8/C/zh_CN.UTF-8/zh_CN.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] reshape2_1.4.3       canvasXpress_1.27.6  data.table_1.12.8   
[4] ggplot2_3.3.0        ggsignif_0.6.0       ggsci_2.9           
[7] dplyr_0.8.5          readxl_1.3.1         scatterplot3d_0.3-41

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6      lattice_0.20-38   tidyr_1.0.2      
 [4] prettyunits_1.1.1 ps_1.3.2          assertthat_0.2.1 
 [7] rprojroot_1.3-2   digest_0.6.25     utf8_1.1.4       
[10] R6_2.4.1          cellranger_1.1.0  plyr_1.8.6       
[13] backports_1.1.6   evaluate_0.14     pillar_1.4.3     
[16] gdtools_0.2.2     rlang_0.4.5       uuid_0.1-4       
[19] curl_4.3          rstudioapi_0.11   callr_3.4.3      
[22] flextable_0.5.9   rmarkdown_2.1     desc_1.2.0       
[25] labeling_0.3      devtools_2.2.2    stringr_1.4.0    
[28] munsell_0.5.0     compiler_3.6.3    xfun_0.12        
[31] pkgconfig_2.0.3   systemfonts_0.1.1 base64enc_0.1-3  
[34] pkgbuild_1.0.6    rvg_0.2.4         htmltools_0.4.0  
[37] tidyselect_1.0.0  tibble_3.0.0      fansi_0.4.1      
[40] crayon_1.3.4      withr_2.1.2       grid_3.6.3       
[43] nlme_3.1-144      gtable_0.3.0      lifecycle_0.2.0  
[46] magrittr_1.5      scales_1.1.0      zip_2.0.4        
[49] cli_2.0.2         stringi_1.4.6     farver_2.0.3     
[52] fs_1.3.2          remotes_2.1.1     testthat_2.3.2   
[55] xml2_1.3.1        generics_0.0.2    ellipsis_0.3.0   
[58] vctrs_0.2.4       openxlsx_4.1.4    stargazer_5.2.2  
[61] tools_3.6.3       glue_1.4.0        officer_0.3.8    
[64] purrr_0.3.3       processx_3.4.2    pkgload_1.0.2    
[67] yaml_2.2.1        colorspace_1.4-1  sessioninfo_1.1.1
[70] memoise_1.1.0     knitr_1.28        usethis_1.5.1  

graph2ppt connection error when exporting Seurat FeaturePlot in R 4.2 Rmarkdown

Dear developer,

Many thanks for the great tool! Very handy.
I'll be grateful for your assistance with the issue below.

I updated my rstudio to the latest version and R to 4.2 and now not able to export getting the error
'Warning in .Internal(environment(fun)) :
closing unused connection 3 (/var/folders/9h/zbzv_b3j3wz2r6mdgw9s2p04000lw8/T//RtmpkTyPis/filee19561b44ad/raster-rId000002.png)
Warning: cannot open file '/var/folders/9h/zbzv_b3j3wz2r6mdgw9s2p04000lw8/T//RtmpkTyPis/filee197fc756a/raster-rId000002.png': No such file or directoryError in open.connection(con, "rb") : cannot open the connection'

I have tried making a reproducible example with the dataset loaded into pbmc found here ( https://cf.10xgenomics.com/samples/cell/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz )

The code can be run in rmarkdown as below


title: "export trial"
output: html_document
date: "2023-01-25"

knitr::opts_chunk$set(echo = TRUE)
library(dplyr)
library(Seurat)
library(export)

# Load the PBMC dataset
pbmc.data <- Read10X(data.dir = "/Users/jr35/Google Drive/My Drive/PHD_documents/trial_datasets/filtered_gene_bc_matrices/hg19/")
# Initialize the Seurat object with the raw (non-normalized data).
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200)

pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)

pbmc <- ScaleData(pbmc)
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))

pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)

pbmc <- RunUMAP(pbmc, dims = 1:10)

Plotting and exporting

FeaturePlot(pbmc, features = "CCR7", dims = c(1,2), pt.size = 1.5, label = T, label.size = 5, repel = T) 
graph2ppt(file = '/Users/jr35/Google Drive/My Drive/PHD_documents/test_exp.ppt')

The output of session info is below

sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gdtools_0.3.0      export_0.3.0       patchwork_1.1.2    SeuratObject_4.1.3 Seurat_4.3.0       dplyr_1.0.10      

loaded via a namespace (and not attached):
  [1] utf8_1.2.2                  spatstat.explore_3.0-5      reticulate_1.27             tidyselect_1.2.0           
  [5] RSQLite_2.2.20              AnnotationDbi_1.60.0        htmlwidgets_1.6.1           grid_4.2.2                 
  [9] BiocParallel_1.32.5         Rtsne_0.16                  scatterpie_0.1.8            munsell_0.5.0              
 [13] codetools_0.2-18            ica_1.0-3                   future_1.30.0               miniUI_0.1.1.1             
 [17] withr_2.5.0                 spatstat.random_3.1-3       colorspace_2.1-0            GOSemSim_2.24.0            
 [21] progressr_0.13.0            Biobase_2.58.0              uuid_1.1-0                  knitr_1.42                 
 [25] rstudioapi_0.14             stats4_4.2.2                SingleCellExperiment_1.20.0 ROCR_1.0-11                
 [29] officer_0.5.1               tensor_1.5                  DOSE_3.25.0.002             listenv_0.9.0              
 [33] labeling_0.4.2              MatrixGenerics_1.10.0       GenomeInfoDbData_1.2.9      polyclip_1.10-4            
 [37] bit64_4.0.5                 farver_2.1.1                pheatmap_1.0.12             downloader_0.4             
 [41] treeio_1.22.0               parallelly_1.34.0           vctrs_0.5.2                 generics_0.1.3             
 [45] gson_0.0.9                  xfun_0.36                   qpdf_1.3.0                  R6_2.5.1                   
 [49] GenomeInfoDb_1.34.6         graphlayouts_0.8.4          bitops_1.0-7                spatstat.utils_3.0-1       
 [53] cachem_1.0.6                reshape_0.8.9               fgsea_1.24.0                gridGraphics_0.5-1         
 [57] DelayedArray_0.24.0         assertthat_0.2.1            promises_1.2.0.1            scales_1.2.1               
 [61] ggraph_2.1.0                enrichplot_1.19.1.991       gtable_0.3.1                globals_0.16.2             
 [65] goftest_1.2-3               tidygraph_1.2.2             rlang_1.0.6                 systemfonts_1.0.4          
 [69] splines_4.2.2               lazyeval_0.2.2              broom_1.0.3                 spatstat.geom_3.0-5        
 [73] rgl_1.0.1                   yaml_2.3.7                  reshape2_1.4.4              abind_1.4-5                
 [77] backports_1.4.1             httpuv_1.6.8                qvalue_2.30.0               clusterProfiler_4.7.0      
 [81] tools_4.2.2                 ggplotify_0.1.0             ggplot2_3.4.0               ellipsis_0.3.2             
 [85] RColorBrewer_1.1-3          BiocGenerics_0.44.0         stargazer_5.2.3             ggridges_0.5.4             
 [89] devEMF_4.2                  Rcpp_1.0.10                 plyr_1.8.8                  base64enc_0.1-3            
 [93] zlibbioc_1.44.0             purrr_1.0.1                 RCurl_1.98-1.9              openssl_2.0.5              
 [97] deldir_1.0-6                pbapply_1.7-0               viridis_0.6.2               cowplot_1.1.1              
[101] S4Vectors_0.36.1            zoo_1.8-11                  SummarizedExperiment_1.28.0 ggrepel_0.9.2              
[105] cluster_2.1.4               crul_1.3                    magrittr_2.0.3              data.table_1.14.6          
[109] scattermore_0.8             openxlsx_4.2.5.1            flextable_0.8.4             lmtest_0.9-40              
[113] RANN_2.6.1                  fitdistrplus_1.1-8          matrixStats_0.63.0          mime_0.12                  
[117] evaluate_0.20               xtable_1.8-4                HDO.db_0.99.1               readxl_1.4.1               
[121] IRanges_2.32.0              gridExtra_2.3               compiler_4.2.2              tibble_3.1.8               
[125] shadowtext_0.1.2            KernSmooth_2.23-20          crayon_1.5.2                htmltools_0.5.4            
[129] ggfun_0.0.9                 later_1.3.0                 tidyr_1.3.0                 aplot_0.1.9                
[133] DBI_1.1.3                   tweenr_2.0.2                MASS_7.3-58.2               Matrix_1.5-3               
[137] cli_3.6.0                   parallel_4.2.2              igraph_1.3.5                GenomicRanges_1.50.2       
[141] pkgconfig_2.0.3             sp_1.6-0                    plotly_4.10.1               spatstat.sparse_3.0-0      
[145] xml2_1.3.3                  ggtree_3.6.2                XVector_0.38.0              rvg_0.3.2                  
[149] yulab.utils_0.0.6           stringr_1.5.0               digest_0.6.31               sctransform_0.3.5          
[153] RcppAnnoy_0.0.20            httpcode_0.3.0              spatstat.data_3.0-0         Biostrings_2.66.0          
[157] rmarkdown_2.20              cellranger_1.1.0            leiden_0.4.3                fastmatch_1.1-3            
[161] tidytree_0.4.2              uwot_0.1.14                 curl_5.0.0                  shiny_1.7.4                
[165] lifecycle_1.0.3             nlme_3.1-161                jsonlite_1.8.4              askpass_1.1                
[169] viridisLite_0.4.1           fansi_1.0.4                 pillar_1.8.1                lattice_0.20-45            
[173] GGally_2.1.2                KEGGREST_1.38.0             fastmap_1.1.0               httr_1.4.4                 
[177] survival_3.5-0              GO.db_3.16.0                glue_1.6.2                  zip_2.2.2                  
[181] png_0.1-8                   bit_4.0.5                   ggforce_0.4.1               stringi_1.7.12             
[185] blob_1.2.3                  gfonts_0.2.0                pdftools_3.3.2              memoise_2.0.1              
[189] irlba_2.3.5.1               future.apply_1.10.0         ape_5.6-2                  

Graphics API version mismatch for R 4.1

I tried to export figures to ppt, i got error: Graphics API version mismatch
I searched and found a solution at stackOverFlow: https://stackoverflow.com/questions/68753250/getting-the-error-graphics-api-version-mismatch
however, I re-installed export, the question still exists.
below is my command the session info

graph2ppt('test.pptx')
Error in PPTX_(file, bg, width, height, offx = offx, offy = offy, pointsize = pointsize, :
Graphics API version mismatch
R.version.string
[1] "R version 4.1.1 (2021-08-10)"

Graphics API version mismatch

Hi. I used the graph2ppt and it returned an error:

Error in PPTX_(file, bg, width, height, offx = offx, offy = offy, pointsize = pointsize,  : 
  Graphics API version mismatch

Problems when installing

Hi,

at first thanks a lot for the package. I actually try to install it but it fails:

devtools::install_github("tomwenseleers/export")
(...)
** R
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded

  • DONE (scales)
    '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL
    '/tmp/RtmpJAPGjG/devtools183d334284a3/tomwenseleers-export-e1aaccb' --library='/home/user/R/x86_64-pc-linux-gnu-library/3.4'
    --install-tests

ERROR: dependencies ‘ReporteRs’, ‘rtable’, ‘ggthemes’ are not available for package ‘export’

  • removing ‘/home/user/R/x86_64-pc-linux-gnu-library/3.4/export’
    Installation failed: Command failed (1)

Can you please give me an advice?

edit: I've noticed that there already happened a problem when installing java:

configure: error: Java interpreter '/usr/lib/jvm/default-java/jre/bin/java' does not work
ERROR: configuration failed for package ‘rJava’

using `graph2ppt()` with {showtext}

Hi, thanks for the package - been using it for a while now.
I recently started using {showtext} to make use of extra fonts in my ggplots. However, I noticed that after running the required showtext::showtext_auto(), the exported .pptx have issues with their text - see the screenshot below.

library(export)
library(ggplot2)
library(showtext)
showtext::showtext_auto()

p <- ggplot(data = PlantGrowth,
            aes(y = weight, x = group)) +
  geom_point() +
  labs(title = "This is a relevant title",
       subtitle = "Here is also a subtitle",
       caption = "And here is a caption")
  
p

export::graph2ppt(p, file = "Rplot")
#> Exported graph as Rplot.pptx

Created on 2022-01-19 by the reprex package (v2.0.1)

This is a Screenshot of Rplot.pptx:
image

Ultimately, I have these questions:

  1. Is there a fix for this so that I can use {showtext} in combination with graph2ppt()?
  2. Taking a step back - the only reason I am exporting to pptx in the first place is to get the figures in my docx files to be as crisp-looking as possible. I achieve this via copying the graph from the pptx file and pasting it into word as an enhanced metafile. Does this sound reasonable to you or do you have a better suggestion?
  3. I usually export my plots as pdf, png and pptx. The first two I could do via ggsave(), but I actually only do so for pdf and subsequently run pdftools::pdf_render_page(pdf_path, page = 1, dpi = 300) %>% png::writePNG(bitmap, png_path) (see my custom export function). This seems to do the trick of always having the same font sizes and scales for both of these two exported files. Does this sound reasonable to you? Should I try to take a similar approach here with e.g. pdf2pptx::pdf2pptx()?

Problem when editing the axis text after graph2pdf.

Hi.
I have created a plot using ggplot2 and exported it using graph2pdf. I wanted to edit it using illustrator and found a problem when editing the text of the x axis. Several of the texts were merged together and cannot be edited separately. It seems the last number of each text is not in the right format.
I'm wondering if you can fix it.
Thanks.
Lin.

image
image

Error with table2 export

When attempting to export a table/dataframe to PPT or DOC (table2ppt or table2doc), I receive this error:

Error in colformat_num(x = tab, j = col.other, digits = digits) : unused argument (digits = digits)

It has worked in the past, I have recently updated my packages.

Reproducible example(s):

a = c(1,2,3,4,5,6)
b = c("a", "b", "c", "d", "e", "f")
x = data.frame(a, b)
table2doc(x=x)

or

a = c(1,2,3,4,5,6)
b = c("a", "b", "c", "d", "e", "f")
x = table(data.frame(a, b))
table2doc(x=x)

Results in the same error.

See sessionInfo() below:

R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] gdtools_0.2.3  tidyr_1.1.2    scales_1.1.1   ggplot2_3.3.3 
 [5] knitr_1.31     export_0.3.0   stringr_1.4.0  dplyr_1.0.4   
 [9] readxl_1.3.1   extrafont_0.17

loaded via a namespace (and not attached):
 [1] fs_1.5.0                usethis_2.0.1          
 [3] devtools_2.3.2          webshot_0.5.2          
 [5] rprojroot_2.0.2         tools_4.0.3            
 [7] backports_1.2.1         utf8_1.1.4             
 [9] R6_2.5.0                DBI_1.1.1              
[11] colorspace_2.0-0        manipulateWidget_0.10.1
[13] withr_2.4.1             tidyselect_1.1.0       
[15] prettyunits_1.1.1       processx_3.4.5         
[17] curl_4.3                compiler_4.0.3         
[19] extrafontdb_1.0         cli_2.3.1              
[21] flextable_0.6.3         xml2_1.3.2             
[23] desc_1.2.0              officer_0.3.16         
[25] labeling_0.4.2          callr_3.5.1            
[27] systemfonts_1.0.1       digest_0.6.27          
[29] rmarkdown_2.7.2         base64enc_0.1-3        
[31] pkgconfig_2.0.3         htmltools_0.5.1.1      
[33] sessioninfo_1.1.1       fastmap_1.1.0          
[35] highr_0.8               rvg_0.2.5              
[37] htmlwidgets_1.5.3       rlang_0.4.10           
[39] rstudioapi_0.13         shiny_1.6.0            
[41] farver_2.0.3            generics_0.1.0         
[43] jsonlite_1.7.2          crosstalk_1.1.1        
[45] zip_2.1.1               magrittr_2.0.1         
[47] Rcpp_1.0.6              munsell_0.5.0          
[49] fansi_0.4.2             lifecycle_1.0.0        
[51] stringi_1.5.3           yaml_2.2.1             
[53] pkgbuild_1.2.0          grid_4.0.3             
[55] promises_1.2.0.1        forcats_0.5.1          
[57] crayon_1.4.1            miniUI_0.1.1.1         
[59] stargazer_5.2.2         ps_1.5.0               
[61] pillar_1.5.0            igraph_1.2.6           
[63] uuid_0.1-4              pkgload_1.2.0          
[65] glue_1.4.2              evaluate_0.14          
[67] data.table_1.14.0       remotes_2.2.0          
[69] vctrs_0.3.6             httpuv_1.5.5           
[71] testthat_3.0.2          Rttf2pt1_1.3.8         
[73] cellranger_1.1.0        gtable_0.3.0           
[75] purrr_0.3.4             assertthat_0.2.1       
[77] cachem_1.0.4            xfun_0.21              
[79] openxlsx_4.2.3          mime_0.10              
[81] hablar_0.3.0            xtable_1.8-4           
[83] broom_0.7.5             later_1.1.0.1          
[85] tibble_3.1.0            memoise_2.0.0          
[87] rgl_0.105.13            ellipsis_0.3.1         
[89] devEMF_4.0-2

graph2ppt crashes with powerpoint open

Not entirely unexpected; having the PPT open and appending a slide to it crashes R.
Would there be a way to have the package check for open powerpoint windows before writing to the file?

body_add_vg is defunct

Using graph2doc with vector graphics enabled throws the following error:

Error: 'body_add_vg' is defunct.

graph2office failure

Hello,
I have a R script where I export a graph, first as to png, then as pptx as:
Cairo(file="Cairo_Rg_96dpi.png",
type="png",
bg="white",
units="pt",
width=600,
height=260,
pointsize=12*96/72,
dpi=96)
hplot = plot(oled$hour, oled$Rg, col=oled$OLED, pch=16, xlab='hours', ylab='Rg',
main='Rg evolution over time')
graph2office(x=hplot, file='Cairo_Rg', vector.graphic = TRUE)

Which fails with
Error in read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html, :
StartTag: invalid element name [68]

I tried on three machines: 2 are Windows 10, 1 in CentOS-8. R info
R version 4.0.2 (2020-06-22)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 8 (Core)
Rtools 4.0, evertything similar on three platforms
"export" package installed from github

I have this error on the CentOS-8 and one of the Windows 10 machine. Yesterday I installed R + Rstudio + Rtools on another Win10 machine, R was never installed before on it; and it worked, i.e. the plot was exported as .pptx file.

Any hint ?

TIA

Pascal Dupuis

Make export functions also work on systems without a graphics device in non-interactive mode?

Right now the export functions work on systems in non-interactive mode, provided that they have access to a graphics device (and ggplot2 plots can also be passed as an object). Some working in non-interactive mode, however, do not even have access to a graphics device. Would it be worth to also support that usage case? Feel free to give your thoughts & provide some reproducible example of what you would like to see supported & details on setup (@pearsonca)...

3.2.4

Unable to use it with the new version of R, this is one of my favorite packages, hoping it will get updated. Thanks for the hard work so far!

Error in dml(code = myplot()) : no "dml" function

I install export package from github as shown in README.
However, when I use graph2ppt to export ggplot object to ppt, an error occured. "Error in dml(code = myplot()) : no "dml" function".
I really do not know where I can get this function.

My system info is shown as bellow:
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] devEMF_4.0-2 scales_1.1.1 export_0.3.0 RColorBrewer_1.1-2
[5] stringi_1.4.6 reshape2_1.4.4 magrittr_1.5 ggplot2_3.3.2
[9] dplyr_0.8.5 readr_1.3.1 RevoUtils_11.0.3 RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
[1] tidyr_0.8.3 jsonlite_1.6.1 stargazer_5.2.2
[4] shiny_1.3.1 assertthat_0.2.1 cellranger_1.1.0
[7] gdtools_0.1.8 pillar_1.4.6 backports_1.1.6
[10] lattice_0.20-41 glue_1.4.0 uuid_0.1-2
[13] digest_0.6.25 manipulateWidget_0.10.0 promises_1.1.0
[16] colorspace_1.4-1 Matrix_1.2-18 htmltools_0.4.0
[19] httpuv_1.5.2 plyr_1.8.6 pkgconfig_2.0.3
[22] broom_0.5.2 purrr_0.3.4 xtable_1.8-3
[25] webshot_0.5.1 RSpectra_0.14-0 openxlsx_4.1.0
[28] later_1.0.0 officer_0.3.3 tibble_3.0.1
[31] generics_0.1.0 farver_2.0.3 ellipsis_0.3.0
[34] withr_2.3.0 cli_2.1.0 crayon_1.3.4
[37] readxl_1.3.1 mime_0.9 evaluate_0.14
[40] fansi_0.4.1 nlme_3.1-137 MASS_7.3-51.5
[43] xml2_1.3.2 tools_3.5.3 data.table_1.12.2
[46] hms_0.5.3 lifecycle_0.2.0 lfda_1.1.2
[49] stringr_1.4.0 flextable_0.5.2 munsell_0.5.0
[52] zip_2.0.1 compiler_3.5.3 rlang_0.4.5
[55] grid_3.5.3 rstudioapi_0.11 htmlwidgets_1.3
[58] crosstalk_1.0.0 miniUI_0.1.1.1 base64enc_0.1-3
[61] labeling_0.4.2 rmarkdown_1.12 gtable_0.3.0
[64] rARPACK_0.11-0 R6_2.5.0 rvg_0.2.0
[67] knitr_1.22 dml_1.1.0 Rcpp_1.0.4.6
[70] vctrs_0.2.4 rgl_0.100.19 tidyselect_1.0.0
[73] xfun_0.13

my code is like this:

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='my.pptx')

ppt I export graph to gets corrupted

Hello,
I've been using your graph2ppt() function which was working beautifully appending graphs I made to an existing ppt I had. Suddenly I got this error:

graph2ppt(, file="/Users/hwaterhouse/Google Drive ([email protected])/PhD/Modesto/Manuscript 2nd chapter/Figures.pptx", append=TRUE)
Error in zip::unzip(zipfile = file, exdir = folder) :
zip error: Cannot extract entry ppt/media/image14.emffrom archive/Users/hwaterhouse/Google Drive ([email protected])/PhD/Modesto/Manuscript 2nd chapter/Figures.pptx`` in file zip.c:305

It seems to think the ppt is zipped which it isn't... and now when I open my ppt other graphs I had in there from before using this function do not display (just a box with a red x in place of the picture of the graph). Any help would be greatly appreciated.

Thanks,
Hannah

PPTX files from graph2ppt end up corrupt

When using graph2ppt to export the following, it seems to go through fine in R, but the files are always corrupt and ppt is unable to repair them.
I am saving them to a onedrive directory if that matters.

`ggplot(LeafTemp2022SubsetNight, aes(x=Tamb, y=deltaT, group=interaction,color=treatment)) +
#geom_boxplot(position = position_dodge2(preserve = "single"))+
geom_point(shape=".",position=position_jitterdodge(jitter.width = 0.1 ,jitter.height = 0.1,dodge.width =0, seed = NA ),pch=20,size=0.02)+
geom_smooth(se=TRUE,level=0.95,method="lm",aes(color=treatment))+
labs(title ="Temperature differential leaf minus ambient Night '22", y="°C")+
theme_prism(base_line_size = 0.5,border = TRUE, base_rect_size = 0.5)+
#scale_colour_prism(palette = "winter_bright")+
theme(plot.title = element_text(hjust = 0.5))+
coord_cartesian(expand = FALSE,ylim = c(-4, 4))

graph2ppt(
file = "leafTemp",
width = 10,
aspectr = sqrt(2),
append = TRUE`

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.