2

I am currently working on automated reports in R. please see the code below for automated function. the first plot can work well but the second plot didn't show anything. Could someone help me out this? many thanks!

multi_plot = function(specified_client){
specified_client <<- specified_client
daily_conv_X_specified_client <<- uq_platform[uq_platform$CustomerId == specified_client, ] 
pdf(file = paste0("D:/auto_report_testing/auto reporting for client ID = ", specified_client, ".pdf"), width = 25, height = (9 * ceiling(x = length(x = daily_conv_X_specified_client) / 2)))

par(mfrow = c(ceiling(x = length(x = daily_conv_X_specified_client) / 2), 2))

plot(x = daily_conv_X_specified_client$Date[daily_conv_X_specified_client$CustomerId == daily_conv_X_specified_client$CustomerId], y = daily_conv_X_specified_client$Total[daily_conv_X_specified_client$CustomerId == daily_conv_X_specified_client$CustomerId])
library(ggplot2)
library(ggTimeSeries)
ggplot(daily_conv_X_specified_client, aes(x= Date, y= Conversion, color= PlatformName)) + geom_point() + facet_grid(PlatformName ~ .)

dev.off()
    }
invisible(x = sapply(X = unique(x = uq_platform$CustomerId), FUN = multi_plot))
Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
Chris Chang
  • 61
  • 1
  • 7
  • 2
    Have you tried wrapping the ggplot call in a `print` statement (see [here](https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f))? Another option would be to use `ggsave`. – Roman Luštrik Nov 02 '16 at 11:15
  • Hi Roman, thanks for the reply.I sort it out! – Chris Chang Nov 02 '16 at 14:56

0 Answers0