我使用R中的Markdown创建了简单的ShinyApp。
重点是在全尺寸窗口中打开应用程序。
这里的代码: 用户界面:
library(shiny)
library(pdfetch)
library(quantmod)
quotes <- c(
"3M Company"="MMM",
"American Express Company"="AXP",
"Apple Inc."="AAPL",
"Caterpillar Inc."="CAT",
"Chevron Corporation"="CVX",
"Cisco Systems, Inc."="CSCO",
"Exxon Mobil Corporation"="XOM",
"General Electric Company"="GE",
"Intel Corporation"="INTC",
"International Business Machines Corporation"="IBM",
"Johnson & Johnson"="JNJ",
"JPMorgan Chase & Co."="JPM",
"McDonald's Corporation"="MCD",
"Merck & Co., Inc."="MRK",
"Microsoft Corporation"="MSFT",
"NIKE, Inc."="NKE",
"Pfizer Inc."="PFE",
"The Boeing Company"="BA",
"The Coca-Cola Company"="KO",
"The Goldman Sachs Group, Inc."="GS",
"The Home Depot, Inc."="HD",
"The Procter & Gamble Company"="PG",
"The Travelers Companies, Inc."="TRV",
"The Walt Disney Company"="DIS",
"United Technologies Corporation"="UTX",
"UnitedHealth Group Incorporated"="UNH",
"Verizon Communications Inc."="VZ",
"Visa Inc."="V",
"Wal-Mart Stores, Inc."="WMT")
ui<-
pageWithSidebar(
headerPanel("Porownanie prognozy metoda regresji oraz symulacji"),
sidebarPanel(tags$hr(style="border-color: gray;"),
br(),
selectInput(inputId = "symb",label = "Wybierz akcje", choices = quotes),
dateInput(inputId = "data",label = "Wybierz date poczatkowa", min = "1900-01-01",max = Sys.Date(),
startview = "decade", value = Sys.Date()-365,
language = "pl"),
br(),
br(),
actionButton("Pobierz", label = "Pobierz dane",icon = icon("download")),
br(),
br(),
br(),
br(),
tags$hr(style="border-color: gray;"),
sliderInput(inputId = "dni",label = "Liczba dni prognozy", min=1,max=365,value=30,step=1),
sliderInput(inputId = "symulacje",label = "Liczba sumulacji", min=1,max=1000,value=100,step=1),
align = "center",
br(),
br(),
actionButton(inputId = "analiza",label = "Analizuj",icon = icon("calculator")),
br(),
br()
),
# Show a tabset that includes a plot, summary, and table view
# of the generated distribution
mainPanel(
tabsetPanel(
tabPanel("DaneHistoryczne",
plotOutput("Historia"),
dataTableOutput("DaneHistoria"),
icon = icon("database")),
tabPanel("Analiza regresji",
plotOutput("regression_plot"),
dataTableOutput("finance_statement"),
icon = icon("line-chart")),
tabPanel("Symulacja Monte Carlo",
h5("May take a couple seconds to load."),
plotOutput("regression_plot2"),
icon = icon("random")),
tabPanel("Podsumowanie",
plotOutput("regression_plot3"),
dataTableOutput("finance_statement3"),
icon = icon("file-text"))
)
)
)
和服务器:
# Define server logic for random distribution application
server<-function(input, output) {
# acquiring data
dataInput <- reactive({
if (input$Pobierz == 0)
return(isolate({
pdfetch_YAHOO("MMM",from = as.Date(input$data),to=Sys.Date())
}))
return(isolate({
pdfetch_YAHOO(input$symb,from = as.Date(input$data),to=Sys.Date())
}))
})
datesInput <- reactive({
if (input$Pobierz == 0)
return(NULL)
return(isolate({
paste0(input$data, "::", Sys.Date())
}))
})
output$Historia <- renderPlot({
chartSeries(dataInput(),
name = input$symb,
subset = datesInput(),
theme = "white")
})
}
shinyApp(ui,server, options = list(height=980,width = 1100))
我得到的结果是: Whitespace
我需要适合窗口或至少摆脱左侧的空白。 我尝试使用FluidPage,FillPage,更改宽度和高度。什么都行不通。