-
Notifications
You must be signed in to change notification settings - Fork 1
/
smhw-tem.R
77 lines (71 loc) · 2.06 KB
/
smhw-tem.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
library("shiny")
library("DT")
library("quantmod")
ui = shinyUI(
fluidPage(
titlePanel(" Hello, World! - Stock Market"),
sidebarLayout(
sidebarPanel(
h2( "Enter an abbreviation for name" ),
helpText("The default is Dow Jones Industrial "),
helpText("ex : Dow Jones Industrial (^DJI), TSMC (2330.TW)."),
textInput("canpabbnm", "", value = "^DJI" ),
submitButton("Submit", icon("refresh"), width = "40%")
),
mainPanel(
tabsetPanel(
tabPanel("Plot",
br(),
plotOutput("smplot")
),
tabPanel("Data",
br(),
DT::dataTableOutput("smtable")
),
tabPanel("summary",
br(),
verbatimTextOutput("smsumy")
),
tabPanel("Output",
br(),
downloadButton('smdlcsv', 'Download')
)
)
)
)
)
)
server = function(input, output) {
# tem
tmsp = reactiveValues()
output$smplot = renderPlot({
tmsp$temcanpabbnm = input$canpabbnm
tmsp$temcanp = getSymbols( tmsp$temcanpabbnm, auto.assign=FALSE)
chartSeries( tmsp$temcanp, theme = chartTheme("white"))
})
output$smtable = DT::renderDataTable({
tmsp$temcanpabbnm = input$canpabbnm
tmsp$temcanpdf = as.data.frame(getSymbols( tmsp$temcanpabbnm, auto.assign=FALSE))
DT::datatable(tmsp$temcanpdf , options = list(pageLength = 25))
})
output$smsumy = renderPrint({
tmsp$temcanpabbnm = input$canpabbnm
tmsp$temcanpdf = as.data.frame(getSymbols( tmsp$temcanpabbnm, auto.assign=FALSE))
summary(tmsp$temcanpdf)
})
output$smdlcsv = downloadHandler(
filename = function() {
paste( "sm", '.csv', sep = '')
tmsp$sdc = as.character(Sys.time())
tmsp$sdc1t = gsub( ":", " ", tmsp$sdc)
tmsp$sdc2t = gsub( "-", " ", tmsp$sdc1t)
tmsp$sdc3t = paste(strsplit( tmsp$sdc2t ,split = " ", fixed = T)[[1]],collapse="")
paste( "sm_", tmsp$sdc3t, ".csv", sep = '')
},
content = function(file) {
tmsp$temcanpabbnm = input$canpabbnm
tmsp$temcanpdf = as.data.frame(getSymbols( tmsp$temcanpabbnm, auto.assign=FALSE))
write.csv( tmsp$temcanpdf, file = file, quote = FALSE, sep = ",", row.names = FALSE)
}
)
}