This project is part of the Developing Data Products course by Coursera. The goal was to create a Shiny Application.
The Shiny App is available on ShinyApps.
The source code is available on GitHub.
27 July 2017
This project is part of the Developing Data Products course by Coursera. The goal was to create a Shiny Application.
The Shiny App is available on ShinyApps.
The source code is available on GitHub.
The App allows you to analyse the stocks of the FTSE MIB, the Italian index including the top 40 companies for market capitalization. The user selects the company and the App downloads the data from Internet.
# Esample of getting data for Google and plotting the time series
library(dygraphs)
library(quantmod)
ucg <- getSymbols('GOOGL',auto.assign = F) #get stock prices for Google
Ad(ucg) %>% dygraph() %>% dyRangeSelector() #plot the time series
The code server.R and ui.R are available on GitHub. The following is the first part where the App downloads the stock prices and plots the chart.
shinyServer(function(input, output) {
stock <- reactive({
x <- Ad(getSymbols(input$stock,auto.assign = FALSE))
if (input$ma1){
if (input$ma1n<nrow(x)){
x$ma1 <- rollapply(x[,1],FUN=function(x)mean(x,na.rm = T),
width=input$ma1n,align='right')
}}
if (input$ma2){
if (input$ma2n<nrow(x)){
x$ma2 <- rollapply(x[,1],FUN=function(x)mean(x,na.rm = T),
width=input$ma2n,align='right')
}}
return(x)
})
output$plot1 <- renderDygraph({
x <- stock()
s <- input$stock
dygraph(x,main = s) %>% dyRangeSelector()
})