-
-
Save anonymous/77412a00d924769772c2d31756b3a51b to your computer and use it in GitHub Desktop.
Multiple Modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Module UI function | |
csvFileInput <- function(id, label = "CSV file") { | |
# Create a namespace function using the provided id | |
ns <- NS(id) | |
tagList( | |
fileInput(ns("file"), label)) | |
} | |
# Module server function | |
csvFile <- function(input, output, session) { | |
colnames<-c("Scan","Tiempo","Global","Difusa","Directa1","Directa2", | |
"DFRCen_V","DFRCen_T","Cli_V3","Cli_V2","Cli_V1","BAR") | |
conf<-checkboxGroupInput('columnas',"Escoge las columnas de la tabla", | |
choices=colnames,selected=colnames[-c(1,9,10)]) | |
alphacen<-numericInput("alphacen",label=h5(strong("Alpha CENER")), | |
value=0.00015,step=0.00001,width='80%') | |
alphacli<-numericInput("alphacli",label=h5(strong("Alpha Cliente")), | |
value=0.0000,step=0.00001,width='80%') | |
clit<-numericInput("clit",label=h5(strong("Temperatura de la celula del cliente")), | |
value=25,step=0.25,width='80%') | |
# The selected file, if any | |
userFile <- reactive({ | |
# If no file is selected, don't do anything | |
req(input$file) | |
}) | |
# The user's data, parsed into a data frame | |
datafile <- reactive({ | |
read.csv(userFile()$datapath, | |
sep=",", | |
skip=50, | |
col.names=colnames, | |
fileEncoding="UCS-2LE") | |
}) | |
# Return the reactive that yields the data frame | |
return(datafile) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plotModuleUI<-function(id){ | |
ns <- NS(id) | |
g1<-plotOutput(ns("g1"),height=200) | |
} | |
plotModule<-function(input,output,session,datafile){ | |
g1<-renderPlot({ | |
plot(x=datafile()$Tiempo,y=datafile()$Directa1) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(DT) | |
library(shinydashboard) | |
library(ggplot2) | |
library(dplyr) | |
library(zoo) | |
source("dataTable.R") | |
source("plotmodule.R") | |
colnames<-c("Scan","Tiempo","Global","Difusa","Directa1","Directa2", | |
"DFRCen_V","DFRCen_T","Cli_V3","Cli_V2","Cli_V1","BAR") | |
conf<-checkboxGroupInput('columnas',"Escoge las columnas de la tabla", | |
choices=colnames,selected=colnames[-c(1,9,10)]) | |
alphacen<-numericInput("alphacen",label=h5(strong("Alpha CENER")), | |
value=0.00015,step=0.00001,width='80%') | |
alphacli<-numericInput("alphacli",label=h5(strong("Alpha Cliente")), | |
value=0.0000,step=0.00001,width='80%') | |
clit<-numericInput("clit",label=h5(strong("Temperatura de la celula del cliente")), | |
value=25,step=0.25,width='80%') | |
shinyServer(function(input, output, session) { | |
datafile<-callModule(csvFile,"datafile") | |
output$tb<-renderDataTable({ | |
DT::datatable(datafile() %>%select_(.dots=input$columnas), | |
extensions='FixedColumns', | |
options=list(searching=FALSE, | |
lengthMenu=list(c(10,25,50,-1), | |
c('10','25','50','Todo')), | |
autoWidth=TRUE,scrollX=400, | |
scrollY=400,fixedColumns=3 | |
)) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(DT) | |
library(shinydashboard) | |
library(ggplot2) | |
library(shinythemes) | |
library(dplyr) | |
library(zoo) | |
library(markdown) | |
source("dataTable.R") | |
source("plotmodule.R") | |
colnames<-c("Scan","Tiempo","Global","Difusa","Directa1","Directa2", | |
"DFRCen_V","DFRCen_T","Cli_V3","Cli_V2","Cli_V1","BAR") | |
conf<-checkboxGroupInput('columnas',"Escoge las columnas de la tabla", | |
choices=colnames,selected=colnames[-c(1,9,10)]) | |
alphacen<-numericInput("alphacen",label=h5(strong("Alpha CENER")), | |
value=0.00015,step=0.00001,width='80%') | |
alphacli<-numericInput("alphacli",label=h5(strong("Alpha Cliente")), | |
value=0.0000,step=0.00001,width='80%') | |
clit<-numericInput("clit",label=h5(strong("Temperatura de la celula del cliente")), | |
value=25,step=0.25,width='80%') | |
shinyUI(fluidPage( | |
dashboardPage( | |
dashboardHeader(), | |
dashboardSidebar( | |
sidebarMenu( | |
csvFileInput("datafile", "User data (.csv format)"), | |
menuItem(strong("Dia 1"),tabName="dia1") | |
) | |
), | |
dashboardBody( | |
tabItems( | |
tabItem(tabName="dia1", | |
tabsetPanel( | |
tabPanel("Configuracion",icon=icon("cog"), | |
column(width=4, | |
box(conf,width=NULL,status="warning")), | |
column(width=4, | |
box(clit,width=NULL,status="warning") | |
), | |
column(width=4, | |
box(alphacli,width=NULL,status="warning"), | |
box(alphacen,width=NULL,status="warning") | |
)), | |
tabPanel("Datos",icon=icon("table"), | |
dataTableOutput("tb")), | |
tabPanel("Salida dia",icon=icon("area-chart"), | |
column(width=12, | |
box(title=strong("Gt-Tiempo"),solidHeader=FALSE, | |
status="success",collapsible=TRUE, | |
callModule(plotModuleUI,"g1") | |
) | |
)) | |
) | |
) | |
)) | |
)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment