Mary
2018-06-21 19:47:38 UTC
I have written the code below to create 6 plots of the same format. I get
the error code at the bottom in red when I run it. I do not directly
mention png in the code, so I'm guessing it has something to do with
renderPlot. The code within "ggModule" works in base R when "renderPlot"
is removed. I tried output$x before renderPlot, but there was an error
saying output was undefined
library(shiny)
library(ggplot2)
options(shiny.maxRequestSize=15*1024^2)
ggUI<-function(id){
ns<-NS(id)
tagList(
plotOutput(ns(id), height="750px")
)
}
ggModule<-function(input, output, session, c, t, d){
renderPlot({
e <- d[which(d$CATEGORY %in% c & d$FAIL == 1),]
p <- ggplot(e, aes(as.Date(DATE), CRIT_CODE, color=as.factor(FAIL))) +
geom_point(size=3) +
labs(title=t, x="Date", y="") +
scale_x_date(date_breaks="2 months", date_minor_breaks="1 month",
date_labels="%m-%Y") +
theme_light() +
theme(plot.title=element_text(hjust=0.5, size=20),
axis.text.x=element_text(size=12),
axis.text.y=element_text(size=12),
axis.title.x=element_text(size=14), legend.position="none")
print(p)
})
}
ui <- fluidPage(
titlePanel("OSV Audit Data Visualization"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept=".csv"),
width=3
),
mainPanel(
tabsetPanel(
tabPanel("Fails Per Audit", tableOutput("tab")),
navbarMenu("Plots",
tabPanel("OSV-Environment", ggUI("env")),
tabPanel("OSV-Machine", ggUI("mach")),
tabPanel("OSV-Man", ggUI("man")),
tabPanel("OSV-Material", ggUI("mat")),
tabPanel("OSV-Measure", ggUI("meas")),
tabPanel("OSV-Method", ggUI("met"))
)
)
)
)
)
server <- function(input, output, session) {
observe({
file1=input$file1
if (is.null(file1)){
return(NULL)
}
df<-read.csv(file1$datapath)
df$FAIL<-ifelse(df$OPERATION_STATUS %in% "FAIL",1,0)
df$CATEGORY<-sub("\\s+\\d+", "", df$CRIT_CODE)
output$env<-callModule(ggModule(c="OSV-ENVIRONMENT", t="Environment
Fails by Date", d=df()), "env")
output$mach<-callModule(ggModule(c="OSV-MACHINE", t="Machine Fails by
Date", d=df()), "mach")
output$man<-callModule(ggModule(c="OSV-MAN", t="Man Fails by Date",
d=df()), "man")
output$mat<-callModule(ggModule(c="OSV-MATERIAL", t="Material Fails by
Date", d=df()), "mat")
output$meas<-callModule(ggModule(c="OSV-MEASURE", t="Measure Fails by
Date", d=df()), "meas")
output$met<-callModule(ggModule(c="OSV-METHOD", t="Method Fails by
Date", d=df()), "met")
})
}
# Run the app ----
shinyApp(ui, server)
Listening on http://127.0.0.1:5701Warning in pngfun(filename = filename, width = width, height = height, res = res, : unable to allocate bitmapWarning in pngfun(filename = filename, width = width, height = height, res = res, : opening device failedWarning: Error in pngfun: unable to start png() device
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
the error code at the bottom in red when I run it. I do not directly
mention png in the code, so I'm guessing it has something to do with
renderPlot. The code within "ggModule" works in base R when "renderPlot"
is removed. I tried output$x before renderPlot, but there was an error
saying output was undefined
library(shiny)
library(ggplot2)
options(shiny.maxRequestSize=15*1024^2)
ggUI<-function(id){
ns<-NS(id)
tagList(
plotOutput(ns(id), height="750px")
)
}
ggModule<-function(input, output, session, c, t, d){
renderPlot({
e <- d[which(d$CATEGORY %in% c & d$FAIL == 1),]
p <- ggplot(e, aes(as.Date(DATE), CRIT_CODE, color=as.factor(FAIL))) +
geom_point(size=3) +
labs(title=t, x="Date", y="") +
scale_x_date(date_breaks="2 months", date_minor_breaks="1 month",
date_labels="%m-%Y") +
theme_light() +
theme(plot.title=element_text(hjust=0.5, size=20),
axis.text.x=element_text(size=12),
axis.text.y=element_text(size=12),
axis.title.x=element_text(size=14), legend.position="none")
print(p)
})
}
ui <- fluidPage(
titlePanel("OSV Audit Data Visualization"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept=".csv"),
width=3
),
mainPanel(
tabsetPanel(
tabPanel("Fails Per Audit", tableOutput("tab")),
navbarMenu("Plots",
tabPanel("OSV-Environment", ggUI("env")),
tabPanel("OSV-Machine", ggUI("mach")),
tabPanel("OSV-Man", ggUI("man")),
tabPanel("OSV-Material", ggUI("mat")),
tabPanel("OSV-Measure", ggUI("meas")),
tabPanel("OSV-Method", ggUI("met"))
)
)
)
)
)
server <- function(input, output, session) {
observe({
file1=input$file1
if (is.null(file1)){
return(NULL)
}
df<-read.csv(file1$datapath)
df$FAIL<-ifelse(df$OPERATION_STATUS %in% "FAIL",1,0)
df$CATEGORY<-sub("\\s+\\d+", "", df$CRIT_CODE)
output$env<-callModule(ggModule(c="OSV-ENVIRONMENT", t="Environment
Fails by Date", d=df()), "env")
output$mach<-callModule(ggModule(c="OSV-MACHINE", t="Machine Fails by
Date", d=df()), "mach")
output$man<-callModule(ggModule(c="OSV-MAN", t="Man Fails by Date",
d=df()), "man")
output$mat<-callModule(ggModule(c="OSV-MATERIAL", t="Material Fails by
Date", d=df()), "mat")
output$meas<-callModule(ggModule(c="OSV-MEASURE", t="Measure Fails by
Date", d=df()), "meas")
output$met<-callModule(ggModule(c="OSV-METHOD", t="Method Fails by
Date", d=df()), "met")
})
}
# Run the app ----
shinyApp(ui, server)
Listening on http://127.0.0.1:5701Warning in pngfun(filename = filename, width = width, height = height, res = res, : unable to allocate bitmapWarning in pngfun(filename = filename, width = width, height = height, res = res, : opening device failedWarning: Error in pngfun: unable to start png() device
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.