Site icon R-bloggers

R shiny stock analysis

[This article was first published on R – Artificial thoughts, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Introduction

This post we deploy our own R-shiny app.

  1. You can select a stock
  2. The app fetches the data, does some number crunching and plots the results

The source code is on github.

Bear in mind that I might not run the demo-server indefinitely, or that it might not be responsive, so first here’s a screenshot:

Here is the demo:

If you want to see this in a full page view here’s the link: https://arthought.shinyapps.io/15_stock_analysis/

Remark: This application might not be available as there is a fairly tight limit on the number of hours the free-plan shinyapps.io based apps will run. There is another server accessible using this link.

 

< !--more-->There are various options as to how you can use Shiny server:

  1. You can host your own server, instructions are here and then here
  2. You can sign up at https://www.shinyapps.io/

There are pros and cons to either, here’s a summary:

 Own serverhttps://www.shinyapps.io/
Complexity
Cost
Scalability
< !-- #tablepress-3 from cache -->

For this post we choose the free account option of https://www.shinyapps.io , which is limited to 5 Applications and 25 Active Hours (per month).

We then use an iframe to reference the shiny app in this post (as shown in the previous post).

Discussion of the code

In the typical shiny app there are two files, one representing the “frontend”/user interface called ui.R, and one representing the “backend” called server.R.  The ui.R defines the user interface widgets, the server.R defines e.g. calculations or plots.

So let’s briefly discuss these two components in our app.

The “frontend”/user interface called ui.R

In the ui.R file we have the following:

In the server.R we have the following

Success!

To leave a comment for the author, please follow the link and comment on their blog: R – Artificial thoughts.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.