I'm new to modules approach, and I'm getting the most sought out error in r shiny. Objects of type 'closure' is not subsettable,
I have checked how the function calls are made, and it looks reasonable to me. I'm not able to find an error in my function usage.
Below is my code,
ui.R
options(shiny.maxRequestSize=100*1024^2)
ui <- dashboardPage(skin = "yellow",
dashboardHeader(title = "Modelling Automation"),
dashboardSidebar(
sidebarMenu(
# Setting id makes input$tabs give the tabName of currently-selected tab
id = "tabs",
menuItem("Data Processing", tabName = "DP", icon = icon("database"),
menuSubItem("Data", tabName = "Data"),
menuSubItem("Plot", tabName = "Plot")),
menuItem("Parameter Extraction", icon = icon("book-open"), tabName = "PE",
menuSubItem("Parameters", tabName = "Parameters")),
menuItem("Model QA", tabName = "QA", icon = icon("angellist"))
),
dashboardBody(
tabItems(
tabItem("DP", "Dashboard tab content"),
tabItem("PE", "Widgets tab content"),
tabItem("Data", sidebarLayout(sidebarPanel(fileInput("datasets", "choose the files", accept = c(".txt",".esd"), multiple = TRUE)),
mainPanel(div(style='overflow-x:scroll',tableOutput("filetable"),tableOutput("filetable1"))))
),
tabItem("Plot",sidebarLayout(sidebarPanel(width=3,
#selectInput("plotdata","Choose a dataset to plot",choices = name, selected = 1, multiple = FALSE),
uiOutput("plotdata"), uiOutput("chip"),
uiOutput("macro"),
uiOutput("device"),uiOutput("temperature"), uiOutput("varx"),
uiOutput("vary")), mainPanel(width=9, plotlyOutput("PLOT")))))
server.R
server <- function(input,output, session) {
output$plotdata <- renderUI({
myfiles <- input$datasets
selectInput("plotdata","choose a dataset to plot",choices = myfiles$name, multiple = FALSE)
})
#sgptlpdata <- reactive({
#callModule(sgp_tlp, "sgptlpdata")
#})
input_file <- reactive({
if(startsWith(input$plotdata,"C")){
dmacsCVdata()
}else if(startsWith(input$plotdata,"D")){
dmacsDCdata()
}else if(startsWith(input$plotdata,"T")&endsWith(input$plotdata,".esd")){
jasperdataTLP()
}else if(startsWith(input$plotdata,"T")&endsWith(input$plotdata,".txt")){
source("sgp_tlp.R")
callModule(sgp_tlp, "input_file")
}else if(startsWith(input$plotdata,"V")&endsWith(input$plotdata,".esd")){
jasperdataVFTLP()
}else{
SGPjasperdataVFTLP()
}
})
# output$example <- renderTable({
# head(input_file())
# })
output$chip <- renderUI({
Data <- input_file()
#TLPdata$chip <- paste(TLPdata$chip)
selectInput("chip", "select the chip", choices = unique(Data$chip),multiple = TRUE, selected = unique(Data$chip)[1])
})
output$macro <- renderUI({
Data <- input_file()
#TLPdata$Macro <- paste(TLPdata$Macro)
Datachipfiltered <- Data[Data[,"chip"] == input$chip,]
selectInput("macro", "Select the Macro", choices = unique(Datachipfiltered$macro), multiple= TRUE , selected = unique(Data$macro)[1])
})
sgp_tlp.R #using this module in a seperate file
sgp_tlp <- function(input, output, session) {
SGPjasperdataTLP <- reactive({
myfiles <- input$datasets
if(is.null(myfiles)){
return(NULL)
}
SGPmyjasperTLPfile <- myfiles[which(startsWith(myfiles$name,"T")&endsWith(myfiles$name,".txt")|startsWith(myfiles$name,"t")&endsWith(myfiles$name,".txt") ),]
#read the input file
DATA <- readLines(SGPmyjasperTLPfile$datapath)
#get Macro details
Macroid <- vector(mode = "numeric", length = 0)
Macroid <- grep ( "Macro ID:", DATA, value = TRUE)
#Macroid <- str_extract(Macroid, "(?<=:\t).+")
Macroid <- substring(Macroid,10)
#get device details
DeviceName <- vector(mode = "numeric", length = 0)
DeviceName <- grep ( "Device ID/Name:", DATA, value = TRUE)
#DeviceName <- str_extract(DeviceName, "(?<=:\t).+")
DeviceName <- substring(DeviceName,16)
#get numerical values
StartPos <- str_which(DATA, "File Name:")
DataStartPos <- StartPos + 21
DataEndPos <- c(StartPos[2:length(StartPos)]-1, length(DATA))
#Create a new data frame
Values <- data.frame()
#Seperate numeric data and META data and bind to data frame
for (i in seq_along(DataStartPos)){
tmp <- as.data.frame(DATA[DataStartPos[i]:DataEndPos[i]])
tmp <- separate(tmp, col = 1, c("Amps", "Volts", "Leakage"), sep = "\t")
tmp$macro <- Macroid[i]
tmp$device <- DeviceName[i]
tmp$chip <- paste("0 0")
Values <- rbind(Values,tmp)
}
Values
})
return(SGPjasperdataTLP)
}