January 7, 2017

Install packages in RStudio

  • install.packages("AppliedPredictiveModeling")
  • install.packages("plotly")

Load packages and data

## Load packages
suppressMessages(library(plotly))
suppressMessages(library(AppliedPredictiveModeling))

## Load Data
data(AlzheimerDisease)
adData = data.frame(diagnosis,predictors)

Find all the predictor variables begin with IL

predName <- names(adData)
ILpredictor <- predName[substr(predName, 1, 2) == "IL"]
ILpredictor
##  [1] "IL_11"         "IL_13"         "IL_16"         "IL_17E"       
##  [5] "IL_1alpha"     "IL_3"          "IL_4"          "IL_5"         
##  [9] "IL_6"          "IL_6_Receptor" "IL_7"          "IL_8"

Create a plot of interleukin 3 values by diagnosis, i.e. between patients ("impaired") and normal individuals ("control")

il3<-plot_ly(adData, x = ~diagnosis, y= adData$IL_3, type="box")  
il3<-il3 %>% layout(il3,title="IL3")

The final plot