[Yuima-commits] r562 - in pkg/yuimaGUI: . R inst/yuimaGUI inst/yuimaGUI/www man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jan 10 17:22:10 CET 2017
Author: phoenix844
Date: 2017-01-10 17:22:09 +0100 (Tue, 10 Jan 2017)
New Revision: 562
Modified:
pkg/yuimaGUI/DESCRIPTION
pkg/yuimaGUI/R/sourceCodeYuimaGUI.R
pkg/yuimaGUI/inst/yuimaGUI/global.R
pkg/yuimaGUI/inst/yuimaGUI/server.R
pkg/yuimaGUI/inst/yuimaGUI/ui.R
pkg/yuimaGUI/inst/yuimaGUI/www/black.css
pkg/yuimaGUI/inst/yuimaGUI/www/white.css
pkg/yuimaGUI/man/yuimaGUI.Rd
Log:
Modified: pkg/yuimaGUI/DESCRIPTION
===================================================================
--- pkg/yuimaGUI/DESCRIPTION 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/DESCRIPTION 2017-01-10 16:22:09 UTC (rev 562)
@@ -1,7 +1,7 @@
Package: yuimaGUI
Type: Package
Title: A Graphical User Interface for the 'yuima' Package
-Version: 0.10.1
+Version: 0.10.2
Author: YUIMA Project Team
Maintainer: Emanuele Guidotti <emanuele.guidotti at studenti.unimi.it>
Description: Provides a graphical user interface for the 'yuima' package.
Modified: pkg/yuimaGUI/R/sourceCodeYuimaGUI.R
===================================================================
--- pkg/yuimaGUI/R/sourceCodeYuimaGUI.R 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/R/sourceCodeYuimaGUI.R 2017-01-10 16:22:09 UTC (rev 562)
@@ -1,20 +1,13 @@
-yuimaGUI <- function(theme = NULL) {
+yuimaGUI <- function(theme = "black") {
+ if(!(theme %in% c("black", "white"))) stop ("Theme not supported. Only 'black' or 'white' themes are available.")
print("Please wait while loading...")
- addr <- system.file("yuimaGUI", package = "yuimaGUI")
- if(!is.null(theme)){
- addr_from <- paste(addr, "/www/", theme, ".css", sep = "")
- addr_to <- paste(addr, "/www/custom.css", sep = "")
- if(file.exists(addr_from))
- file.copy(from = addr_from, to = addr_to, overwrite = TRUE)
- else print("Theme not supported. Using default.")
- }
+ options(yuimaGUItheme = theme)
-
utils::capture.output(
suppressWarnings(
- shiny::runApp(addr)
+ shiny::runApp(system.file("yuimaGUI", package = "yuimaGUI"))
)
)
Modified: pkg/yuimaGUI/inst/yuimaGUI/global.R
===================================================================
--- pkg/yuimaGUI/inst/yuimaGUI/global.R 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/inst/yuimaGUI/global.R 2017-01-10 16:22:09 UTC (rev 562)
@@ -12,6 +12,8 @@
if(!exists("yuimaGUIdata"))
yuimaGUIdata <- reactiveValues(series=list(), model=list(), usr_model = list(), simulation=list(), usr_simulation = list(), cp=list(), cpYuima=list(), llag = list(), cluster = list(), hedging = list())
+if(is.null(getOption("yuimaGUItheme"))) options(yuimaGUItheme = "black")
+
# getSimulation <- function(symb, n = 1){
# return(isolate({yuimaGUIdata$simulation[[symb]][[n]]}))
# }
Modified: pkg/yuimaGUI/inst/yuimaGUI/server.R
===================================================================
--- pkg/yuimaGUI/inst/yuimaGUI/server.R 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/inst/yuimaGUI/server.R 2017-01-10 16:22:09 UTC (rev 562)
@@ -146,7 +146,8 @@
temp <- temp[complete.cases(temp), ]
rownames(temp) <- temp[,"Index"]
colnames(temp) <- c("Index", symb)
- if (typeIndex=="numeric"){
+ if (all(is.na(temp[,2]))) err <- c(err, symb)
+ else if (typeIndex=="numeric"){
test <- try(read.zoo(temp, FUN=as.numeric, drop = FALSE))
if (class(test)!="try-error")
yuimaGUIdata$series[[symb]] <<- test
@@ -1490,10 +1491,30 @@
###############################################################################
###############################################################################
###############################################################################
+
+ output$saveSession <- {
+ downloadHandler(
+ filename = "yuimaGUIsession.Rdata",
+ content = function(file) {
+ save("yuimaGUIdata", file = file)
+ }
+ )
+ }
+ observeEvent(input$loadSession, {
+ try(load(choose.files(caption = "Select a yuimaGUIsession.Rdata file", multi = FALSE)))
+ yuimaGUIdata$series <<- yuimaGUIdata$series
+ yuimaGUIdata$model <<- yuimaGUIdata$model
+ yuimaGUIdata$usr_model <<- yuimaGUIdata$usr_model
+ yuimaGUIdata$simulation <<- yuimaGUIdata$simulation
+ yuimaGUIdata$usr_simulation <<- yuimaGUIdata$usr_simulation
+ yuimaGUIdata$cp <<- yuimaGUIdata$cp
+ yuimaGUIdata$cpYuima <<- yuimaGUIdata$cpYuima
+ yuimaGUIdata$llag <<- yuimaGUIdata$llag
+ yuimaGUIdata$cluster <<- yuimaGUIdata$cluster
+ })
-
########################Load Economic and Financial Data
########################
########################
@@ -1599,28 +1620,39 @@
########################
########################
+
+
###Read file
fileUp_O <- reactive({
if (!is.null(input$yourFile$datapath)){
sep <- input$yourFileSep
- if(input$yourFileSep=="default")
- sep <- ""
+ if(input$yourFileSep=="default") sep <- ""
+ skip <- input$yourFileLine-1
+ if(is.na(skip)) skip <- 0
+ dec <- input$yourFileDec
+ if(input$yourFileDec=="") dec <- "."
if(input$yourFileHeader=="Only rows")
- z <- read.table(input$yourFile$datapath ,sep = sep, header = FALSE, row.names = 1, check.names = FALSE)
+ z <- read.csv(input$yourFile$datapath ,sep = sep, header = FALSE, row.names = 1, check.names = FALSE, stringsAsFactors = FALSE, dec = dec, na.strings = input$yourFileNA, skip = skip)
if(input$yourFileHeader=="Only columns"){
- z <- read.table(input$yourFile$datapath, sep = sep, header = FALSE, check.names = FALSE)
+ z <- read.csv(input$yourFile$datapath, sep = sep, header = FALSE, check.names = FALSE, stringsAsFactors = FALSE, dec = dec, na.strings = input$yourFileNA, skip = skip)
z <- data.frame(t(z), row.names = 1, check.names = FALSE)
z <- data.frame(t(z), check.names = FALSE)
}
if (input$yourFileHeader=="Both")
- z <- read.table(input$yourFile$datapath, sep = sep, header = TRUE, check.names = FALSE)
+ z <- read.csv(input$yourFile$datapath, sep = sep, header = TRUE, check.names = FALSE, stringsAsFactors = FALSE, dec = dec, na.strings = input$yourFileNA, skip = skip)
if (input$yourFileHeader=="None")
- z <- read.table(input$yourFile$datapath, sep = sep, header = FALSE, check.names = FALSE)
+ z <- read.csv(input$yourFile$datapath, sep = sep, header = FALSE, check.names = FALSE, stringsAsFactors = FALSE, dec = dec, na.strings = input$yourFileNA, skip = skip)
if (input$yourFileHeader=="Default")
- z <- read.table(input$yourFile$datapath, sep = sep, check.names = FALSE)
+ z <- read.csv(input$yourFile$datapath, sep = sep, check.names = FALSE, stringsAsFactors = FALSE, dec = dec, na.strings = input$yourFileNA, skip = skip)
if (input$yourFileHeader=="Only rows" | identical(colnames(z),paste("V",seq(1,length(colnames(z))),sep="")))
colnames(z) <- paste("X",seq(1,length(colnames(z))),"_",make.names(input$yourFile$name),sep="")
- return(z)
+ dec <- isolate({ifelse(input$yourFileDec=="", ".", input$yourFileDec)})
+ if(dec==".") dec <- "\\."
+ thnd <- input$yourFileThnd
+ if(thnd==".") thnd <- "\\."
+ zz <- data.frame(row.names = rownames(z), x = apply(z, 2, function(x) gsub(pattern = dec, replacement = ".", x = gsub(pattern = thnd, replacement = "", x = as.character(x)))))
+ colnames(zz) <- colnames(z)
+ return(zz)
}
})
@@ -1645,22 +1677,23 @@
return(selectInput("yourFileIndex",label = "Index", choices = c("Default"="default","Numeric"="numeric",temp), selected = "default"))
})
- ###Display choices for Index Type and set to "numeric" if Index is "numeric"
- output$yourFileFUN <- renderUI({
- if (!is.null(input$yourFileIndex)){
- sel <- "%Y-%m-%d"
- if (input$yourFileIndex=="numeric")
- sel <- "numeric"
- selectInput("yourFileFUN", label = "Index Format", choices = c("Numeric"="numeric", "Year-Month-Day (yyyy-mm-dd)"="%Y-%m-%d", "Month-Day-Year (mm-dd-yyyy)"="%m-%d-%Y", "Month-Day-Year (mm-dd-yy)"="%m-%d-%y", "Day-Month-Year (dd-mm-yyyy)"="%d-%m-%Y", "Day-Month-Year (dd-mm-yy)"="%d-%m-%y", "Year/Month/Day (yyyy/mm/dd)"="%Y/%m/%d", "Month/Day/Year (mm/dd/yyyy)"="%m/%d/%Y", "Month/Day/Year (mm/dd/yy)"="%m/%d/%y", "Day/Month/Year (dd/mm/yyyy)"="%d/%m/%Y", "Day/Month/Year (dd/mm/yy)"="%d/%m/%y"), selected = sel)
- }
- })
###File to upload
fileUp <- reactive({
if (!is.null(input$yourFile$datapath)){
z <- fileUp_O()
- if (input$yourFileSwitch==TRUE)
- z <- fileUp_T()
+ if (input$yourFileSwitch==TRUE) z <- fileUp_T()
+ ###Display choices for Index Type and set to "numeric" if Index is "numeric"
+ output$yourFileFUN <- renderUI({
+ if (!is.null(input$yourFileIndex)){
+ sel <- "%Y-%m-%d"
+ if (input$yourFileIndex=="numeric" |
+ "try-error"!=class(try(as.numeric(as.character(z[,input$yourFileIndex])))) |
+ ("try-error"!=class(try(as.numeric(as.character(rownames(z))))) & (input$yourFileIndex=="default")))
+ sel <- "numeric"
+ selectInput("yourFileFUN", label = "Index Format", choices = c("Numeric"="numeric", "Year-Month-Day (yyyy-mm-dd)"="%Y-%m-%d", "Month-Day-Year (mm-dd-yyyy)"="%m-%d-%Y", "Month-Day-Year (mm-dd-yy)"="%m-%d-%y", "Day-Month-Year (dd-mm-yyyy)"="%d-%m-%Y", "Day-Month-Year (dd-mm-yy)"="%d-%m-%y", "Year/Month/Day (yyyy/mm/dd)"="%Y/%m/%d", "Month/Day/Year (mm/dd/yyyy)"="%m/%d/%Y", "Month/Day/Year (mm/dd/yy)"="%m/%d/%y", "Day/Month/Year (dd/mm/yyyy)"="%d/%m/%Y", "Day/Month/Year (dd/mm/yy)"="%d/%m/%y"), selected = sel)
+ }
+ })
if(input$yourFileIndex!="default" & input$yourFileIndex!="numeric")
z <- data.frame(z, row.names = which(colnames(z)==input$yourFileIndex), check.names = FALSE)
if(input$yourFileIndex=="numeric")
@@ -1674,7 +1707,11 @@
if (!is.null(input$yourFile$datapath))
return(tags$button(type="button", id="yourFileGo", class = "action-button", em("Load data")))
})
-
+
+ observe({
+ shinyjs::toggle("yourFileButton", condition = "try-error"!=(class(try(fileUp()))))
+ })
+
###Display text "Preview"
output$yourFilePreviewText <- renderText ({
if (!is.null(input$yourFile$datapath))
Modified: pkg/yuimaGUI/inst/yuimaGUI/ui.R
===================================================================
--- pkg/yuimaGUI/inst/yuimaGUI/ui.R 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/inst/yuimaGUI/ui.R 2017-01-10 16:22:09 UTC (rev 562)
@@ -19,8 +19,13 @@
),
menuItem("Simulation", tabName = "simulate_section", icon = icon("area-chart"),
menuSubItem("Univariate", tabName = "simulate")
- )#,
- #hr(),
+ ),
+ hr(),
+ fluidRow(
+ column(12,
+ column(6,downloadButton("saveSession", label = "Save")),
+ column(6,actionButton("loadSession", label = "Load", icon = icon("open", lib = "glyphicon")))
+ ))
#menuItem("Finance", tabName = "finance",
# menuSubItem("P&L distribution", tabName = "hedging")
# )
@@ -28,7 +33,7 @@
)
body<-dashboardBody(
- tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")),
+ tags$head(tags$link(rel = "stylesheet", type = "text/css", href = paste(getOption("yuimaGUItheme"), ".css", sep = ""))),
shinyjs::useShinyjs(),
withMathJax(),
@@ -144,10 +149,17 @@
fileInput(inputId = "yourFile", label = "Choose file to upload", multiple = FALSE),
selectInput('yourFileHeader', 'Headers', choices = c("Default","Only columns", "Only rows", "Both", "None"), selected = "Default"),
selectInput(inputId = 'yourFileSep', label = 'Field Separator', choices = c("Space"="default", "Comma"=',', "Semicolon"=';', "Tab"='\t'), selected = "default"),
- selectInput('yourFileSwitch', 'Switch rows/columns', choices = c("No"=FALSE, "Yes"=TRUE)),
uiOutput("yourFileIndex"),
- uiOutput("yourFileFUN")
- ),
+ uiOutput("yourFileFUN"),
+ br(),
+ div(align = "center", box(width = 7, background = switch(getOption("yuimaGUItheme"), "black"="black", "white"=NULL), title = "More Settings", collapsible = TRUE, id = "yourFileMoreSettings", collapsed = TRUE,
+ selectInput('yourFileSwitch', 'Switch rows/columns', choices = c("No"=FALSE, "Yes"=TRUE)),
+ textInput('yourFileDec', 'Decimal Separator', value = "."),
+ textInput('yourFileThnd', 'Thousands Separator', value = ""),
+ textInput("yourFileNA", "Missing Value string", value = "NA"),
+ numericInput("yourFileLine", "Begin from line", value = 1, min = 1, step = 1)
+ )
+ )),
column(7,
textOutput("yourFilePreviewText"),
DT::dataTableOutput("yourFilePreview"),
Modified: pkg/yuimaGUI/inst/yuimaGUI/www/black.css
===================================================================
--- pkg/yuimaGUI/inst/yuimaGUI/www/black.css 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/inst/yuimaGUI/www/black.css 2017-01-10 16:22:09 UTC (rev 562)
@@ -252,3 +252,11 @@
border-color: #282828;
}
+
+#saveSession, #loadSession {
+ color: black;
+}
+
+#yourFileMoreSettings {
+ background-color: #282828;
+}
Modified: pkg/yuimaGUI/inst/yuimaGUI/www/white.css
===================================================================
--- pkg/yuimaGUI/inst/yuimaGUI/www/white.css 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/inst/yuimaGUI/www/white.css 2017-01-10 16:22:09 UTC (rev 562)
@@ -226,3 +226,7 @@
border-color: #282828;
}
+
+#saveSession, #loadSession {
+ color: black;
+}
Modified: pkg/yuimaGUI/man/yuimaGUI.Rd
===================================================================
--- pkg/yuimaGUI/man/yuimaGUI.Rd 2017-01-10 10:01:05 UTC (rev 561)
+++ pkg/yuimaGUI/man/yuimaGUI.Rd 2017-01-10 16:22:09 UTC (rev 562)
@@ -8,11 +8,11 @@
Runs yuima Graphical User Interface
}
\usage{
-yuimaGUI(theme = NULL)
+yuimaGUI(theme = "black")
}
\arguments{
- \item{theme}{GUI theme: "black" or "white". By default the last one you used is chosen.}
+ \item{theme}{GUI theme: "black" or "white".}
}
\value{
More information about the Yuima-commits
mailing list