Closed jpmorris closed 9 years ago
Hi,
The vector.graphics
argument need to be set in the addPlot
function, not the plot
function.
myppt = addPlot(myppt, vector.graphics=F, fun = function(){
plot(model.ctree)
})
This will solve your issue by switching the graphical device to png and not to ReporteRs' one (where code need to be improved to handle UTF-8 when running within R for Windows).
David
vector.graphics = F seems to crash my rstudio session (using your code above for these ctrees)
I can't reproduce the problem. I ran:
library("partykit")
ls <- data.frame(y = gl(3, 50, labels = c("A", "B", "C")),
x1 = rnorm(150) + rep(c(1, 0, 0), c(50, 50, 50)),
x2 = runif(150))
ct <- ctree(y ~ x1 + x2, data = ls)
library( ReporteRs )
myppt = pptx()
myppt = addSlide( myppt, "Title and Content")
myppt = addPlot(myppt, vector.graphic = T, fun = function(){
plot(ct)
})
myppt = addSlide( myppt, "Title and Content")
myppt = addPlot(myppt, vector.graphic = F, fun = function(){
plot(ct)
})
writeDoc( myppt, "jpmorris.pptx")
Below a screenshot of the resulting file:
Hmmm. Doesn't work for me with my pared down example:
Sys.setenv(JAVA_HOME="C:\\Users\\mor20\\progs\\jre1.8.0_45")
library( ReporteRs )
library(dplyr)
library(partykit)
myppt = pptx(template = "PowerPoint Template.pptx")
myppt = addSlide(myppt, "Title and Content")
myppt = addTitle(myppt, "test")
#
#
current.trans.2005.etm <- currentTransactions_2005 %>%
select(GENERATION_TXT, SERVICE_RANGE_TXT, GENDER_TXT, ANNUAL_SALARY_AMT, ETHNICITY_TXT, MY.termtype) %>%
mutate(MY.termpred = factor(ifelse(MY.termtype %in% c("Involuntary", "Other", "Voluntary", "Retirement"), "non-Active", "Active")))
model.ctree = ctree(MY.termpred ~ GENERATION_TXT + SERVICE_RANGE_TXT + GENDER_TXT + ANNUAL_SALARY_AMT + ETHNICITY_TXT, data=current.trans.2005.etm)
myppt = addPlot(myppt, vector.graphics = F, fun = function(){
plot(model.ctree)
})
writeDoc( myppt, "C:/Users/mor20/Downloads/pp_simple_example.pptx" )
I guess it could be my environment (java I'm using), template, or dataset?
Ok, after modifying your example with my template, dplyr data.frame, java version I found the problem, I was using "vector.graphics" not "vector.graphic" (notice trailing 's'). This causes rstudio to crash for me. Thanks for your help.
Hi,
a quick comment,
If your JRE is correctly installed, you don't need
Sys.setenv(JAVA_HOME="C:\\Users\\mor20\\progs\\jre1.8.0_45")
Because I don't have admin access to this machine, and because I get Java 32/64 bit confilct with a particular website, this is the easiest solution I've found that doesn't break a different webpage I use on a regular basis.
It plots with the right words in Rstudio, but whenit outputs to the ppx, it suddenly turns to greek at one point in the plot. My environment is:
Which I think is the correct encoding. Either way, trying to set based on other Issue reports I get: