Closed shengwei66 closed 1 year ago
Users have reported that an error is encountered in gentlg when creating the output for multiple graphs. The reprex is below.
library(dplyr) library(ggplot2) library(tidytlg)
adsl <- cdisc_adsl %>% filter(SAFFL == "Y")
tblid <- "test2plots"
plot1 <- ggplot(data = adsl, aes(x = HEIGHTBL, y = WEIGHTBL)) + geom_point() + labs(x = "Baseline Height (cm)", y = "Baseline Weight (kg)")
png("../output/plot1.png", width=2800, height=1800, res=300, type = "cairo")
plot1
dev.off()
plot2 <- ggplot(data = adsl, aes(x = WEIGHTBL, y = HEIGHTBL)) + geom_point() + labs(x = "Baseline Weight (kg)", y = "Baseline Height (cm)")
png("../output/plot2.png", width=2800, height=1800, res=300, type = "cairo")
plot2
gentlg(tlf = "g", plotnames = paste0("../output/", c("plot1.png","plot2.png")), opath = "../output", plotwidth = 8, plotheight = 5, orientation = "landscape", file = tblid, title = "Scatter plot")
Error in if (file.exists(plotnames)) { : the condition has length > 1
This used to work in previous version without error.
Users have reported that an error is encountered in gentlg when creating the output for multiple graphs. The reprex is below.
Prep Environment
library(dplyr) library(ggplot2) library(tidytlg)
adsl <- cdisc_adsl %>% filter(SAFFL == "Y")
tblid <- "test2plots"
Generate Results
plot1 <- ggplot(data = adsl, aes(x = HEIGHTBL, y = WEIGHTBL)) + geom_point() + labs(x = "Baseline Height (cm)", y = "Baseline Weight (kg)")
create png file of plot1
png("../output/plot1.png", width=2800, height=1800, res=300, type = "cairo")
plot1
dev.off()
plot2 <- ggplot(data = adsl, aes(x = WEIGHTBL, y = HEIGHTBL)) + geom_point() + labs(x = "Baseline Weight (kg)", y = "Baseline Height (cm)")
create png file of plot2
png("../output/plot2.png", width=2800, height=1800, res=300, type = "cairo")
plot2
dev.off()
Output Results
gentlg(tlf = "g", plotnames = paste0("../output/", c("plot1.png","plot2.png")), opath = "../output", plotwidth = 8, plotheight = 5, orientation = "landscape", file = tblid, title = "Scatter plot")
Error in if (file.exists(plotnames)) { : the condition has length > 1
This used to work in previous version without error.