Below are the solutions to these exercises on Multivariate Apply. #################### # # # Exercise 1 # # # #################### PersonnelData <- data.frame(Representative=c(1:4), Sales=c(95,110,115,90), Territory=c(1:4)) mapply(class, PersonnelData) ## Representative Sales Territory ## “integer” “numeric” “integer” #################### # # # Exercise 2 # # # #################### mapply(print, PersonnelData) ## [1] 1 2 3 4 ## [1] […]

# Solutions

## Multiple Regression (Part 1) Solutions

Below are the solutions to these exercises on Multiple Regression (part 1). #################### # # # Exercise 1 # # # #################### #a. data(state) #b. state77 <- as.data.frame(state.x77) #c. names(state77)[4] <- “Life.Exp” names(state77)[6] <- “HS.Grad” #################### # # # Exercise 2 # # # #################### model <- lm(Life.Exp ~ ., data=state77) #the ‘.’ means ‘all’ […]

## Let’s get started with dplyr Solution

Below are the solutions to these exercises on dplyr. ############### # # # Exercise 1 # # # ############### df=data.frame(Theoph) library(dplyr) ############### # # # Exercise 2 # # # ############### names(df) ## [1] "Subject" "Wt" "Dose" "Time" "conc" ############### # # # Exercise 3 # # # ############### select(df,Subject:Dose) ## Subject Wt Dose ## […]

## Getting started with Plotly: basic Plots – Solutions

Below are the solutions to these exercises on plotly basic plots library(plotly) ############### # # # Exercise 1 # # # ############### plot_ly(x = iris[,1]) #type = “histogram” is the argument to be included to specify the chart type ############### # # # Exercise 2 # # # ############### #nbinsx is the argument to specify […]

## Descriptive Analytics-Part 6: Interactive dashboard ( 2/2) solutions

Below are the solutions to these exercises on interactive dashboarding. In case, you feel like you need the full script, you can find it here. ############### # # # Exercise 1 # # # ############### ui <- fluidPage(pageWithSidebar( headerPanel(“Visualization”))) ## Error in eval(expr, envir, enclos): could not find function “fluidPage” ############### # # # Exercise […]

## Intermediate Tree 2

Below are the solutions to these intermediate exercise on decision tree 2 df=read.csv("C:/Contract/adult.csv",header=FALSE) library(caTools) colnames(df)=c("age","workclass","fnlwgt","education","education-num","marital-status","occupation","relationhip","race","sex","capital-gain","capital-loss","hours-per-week","native-country","class") df$class=ifelse(df$class==" >50K", 1, 0) df$class=as.factor(df$class) set.seed(1000) split=sample.split(df$class, SplitRatio=0.8) Train=df[split==TRUE,] Test=df[split==FALSE,] library(rpart) library(rpart.plot) ## Warning: package ‘rpart.plot’ was built under R version 3.3.2 dec=rpart(class~., data=Train) par(mar = rep(2, 4)) ############### # # # Exercise 1 # # # ############### pred_dec=predict(dec,newdata = […]

## Descriptive Analytics-Part 6: Interactive dashboard ( 1/2) Solutions

Below are the solutions to these exercises on interactive dashboarding. In case, you feel like you need the full script, you can find it here. ############### # # # Exercise 1 # # # ############### ui <- fluidPage(pageWithSidebar( headerPanel(“Descriptive Analysis”))) ############### # # # Exercise 2 # # # ############### ui <- fluidPage(pageWithSidebar( headerPanel(“Descriptive Analysis”), […]

## Working with Shapefiles in R Solutions

Below are the solutions to these exercises on Working with Shapeflies in R. if (!require(rgdal)){install.packages(rgdal, dep=T)} ## Warning: package ‘rgdal’ was built under R version 3.3.2 ## Warning: package ‘sp’ was built under R version 3.3.2 library(rgdal) #################### # # # Exercise 1 # # # #################### london <- readOGR(dsn = ".", layer = "london_sport") […]

## Building Shiny App solutions part 4

Below are the solutions to these exercises on Building Shiny App. #################### # # # Exercise 1 # # # #################### #ui.R library(shiny) shinyUI(fluidPage( titlePanel(“Shiny App”), sidebarLayout( sidebarPanel(h2(“Menu”), br(), fluidRow( column(6, h4(“Actionbutton”), actionButton(“per”, label = “Perform”)), column(6, h4(“Help Text”), helpText(“Just for help”))), br(), fluidRow( column(6, h4(“Submitbutton”), submitButton(“Submit”)), column(6, numericInput(“numer”, label = h4(“Numeric Input”), value = […]

## intermediate tree 1

Below are the solutions to these intermediate exercise on decision tree ############### # # # Exercise 1 # # # ############### df=read.csv("C:/Contract/adult.csv",header=FALSE) str(df) ## ‘data.frame’: 15916 obs. of 15 variables: ## $ V1 : int 39 50 38 53 28 37 49 52 31 42 … ## $ V2 : Factor w/ 9 levels " […]