Some materials re: authoring R libraries with R Shiny capabilities using Rstudio and GitHub.

Overview: These materials are for our November 11 Biostatistics, Genetics, and Genomics meeting. They constitute some notable highlights from a series of talks given by Dr. Martin Morgan as part of his Intermediate R Software Development short course. The image captures and example code below were prepared primarily by Mr. Ziqiang Chen, based upon the materials provided by Dr. Morgan in his course.

Setup: Install Rstudio , Install git, and install devtools [ with the command  install.packages(“devtools”)  ]

Setting up a GitHub account: https://github.com/ . Create a new project called ‘Knees’.

knees_gitfrontpage

 

Create a new library in Rstudio:

Enable Git version control in Rstudio and connect to GitHub:

The Stick Person Code that we will use for our example library:

https://github.com/EconometricsBySimulation/R-Graphics/blob/master/Stick-Figures/draw.stick.R

Add this function and two others to our R library:

https://github.com/ziqiangc/Elbo/blob/master/R/sticky.R

Make sure to make some modfications for the ‘Knees’ package!

Document and Install and the Package:

knees_sticky1

Commit the changes locally:

knees_sticky2

Push the changes:

Run the code on the command line:

knees_sticky5

Now, setup the infrastructure for the RShiny App by creating a inst/sticky directory and adding these files:

https://github.com/ziqiangc/Elbo/blob/master/inst/sticky/server.R

https://github.com/ziqiangc/Elbo/blob/master/inst/sticky/ui.R

Install the library and Run the Shiny App!

knees_sticky6

 

If you wish to skip all of the above, and just load Ziqiang’s version of the library:

library(devtools)
install_github("ziqiangc/Knees")
library(Knees)
sticky()

 

Some Shiny RStudio Video tutorials (there are many to be found – thanks to Ziqiang Chen, for the links)
1. A (official) RStudio tutorial: http://shiny.rstudio.com/tutorial/ 
2. A comprehensive playlist of shiny tutorials: https://www.youtube.com/watch?v=_0ORRJqctHE&list=PL6wLL_RojB5xNOhe2OTSd-DPkMLVY9DfB

Some useful dplyr links

Some useful links provided to me by Ziqiang Chen:

1. The basic for dplyr and pipes, R markdown work through (GREAT): http://seananderson.ca/2014/09/13/dplyr-intro.html

2. Introduction of pipe: https://www.r-bloggers.com/simpler-r-coding-with-pipes-the-present-and-future-of-the-magrittr-package/

3. %.% operator: https://martinsbioblogg.wordpress.com/2014/03/27/more-fun-with-and/

4. The vignette of magrittr (illustrative examples): https://cran.r-project.org/web/packages/magrittr/vignettes/magrittr.html

Some Videos:

1. Basic, short walk through video about the pipe operator: https://www.youtube.com/watch?v=4fHNlUagm4g

2. A short tutorial about dplyr: https://www.youtube.com/watch?v=VnjujO8z4OI

3. A little longer tutorial about dplyr: https://www.youtube.com/watch?v=jWjqLW-u3hc

4. One hour presentation “Pipelines for Data Analysis” by Hadley Wickham: https://www.youtube.com/watch?v=40tyOFMZUSM

The origin  of the name for the magrittr R library:

 

blog-27-october-magritte-2

magrittepipe

Paintings by Rene Magritte