Below are the solutions to these exercises on forecasting using linear models. #################### # # # Exercise 1 # # # #################### df <- read.csv("ecommerce.csv") series <- ts(df, frequency = 4, start = c(1999, 4)) plot(series) #################### # # # Exercise 2 # # # #################### require(forecast) fcast_naive <- naive(series, h = 8) #################### # […]

# Solutions

## Data Science for Operational Excellence (Part-2)

Below are the solutions to these exercises on Linear Programming. #################### # # # Exercise 1 # # # #################### library(lpSolve) library(igraph) f.obj <- c(1,9,1) f.con <- matrix(c(1,2,3,3,2,2), nrow = 2, byrow = T) f.dir <- c("<=", "<=") f.rhs <- c(9,15) lp("max", f.obj, f.con, f.dir, f.rhs) ## Success: the objective function is 40.5 lp("max", f.obj, […]

## Forecasting for small business Solutions (Part-1)

Below are the solutions to these exercises on time series. #################### # # # Exercise 1 # # # #################### data(treering) str(treering) ## Time-Series [1:7980] from -6000 to 1979: 1.34 1.08 1.54 1.32 1.41 … length(treering) ## [1] 7980 #################### # # # Exercise 2 # # # #################### ts1 <- window(treering, start=1500, end=2000) ## […]

## Data Structures Solutions (Part 2)

Below are the solutions to these exercises on Data Structures Part 2. #################### # # # Exercise 1 # # # #################### Employee_Name<-hash(keys=c(“Employee1″,”Employee2″,”Employee3”),values=c(‘Alan’,’Ryan’,’Serah’)) print(Employee_Name) ## <hash> containing 3 key-value pair(s). ## Employee1 : Alan ## Employee2 : Ryan ## Employee3 : Serah print(Employee_Name$Employee1) ## [1] “Alan” print(Employee_Name$Employee2) ## [1] “Ryan” print(length(Employee_Name)) ## [1] 3 #################### […]

## Building Shiny App solutions part 10

Below are the solutions to these exercises on Building Shiny App. #################### # # # Exercise 1 # # # #################### #ui.r library(shiny) library(shinydashboard) dashboardPage( dashboardHeader(title = "Shiny App", dropdownMenu(type = "messages", messageItem( from = "Bob Carter", message = "Excellent dashboard.Keep the good job" ), messageItem( from = "New User", message = "How do I […]

## Forecasting: Time Series Exploration (Part-1) Solutions

Below are the solutions to these exercises on time series exploration. #################### # # # Exercise 1 # # # #################### df <- read.csv("sales.csv") #################### # # # Exercise 2 # # # #################### series <- ts(df, frequency = 12, start = c(1992,1)) print(series) ## Jan Feb Mar Apr May Jun Jul Aug Sep Oct […]

## Correlation and Correlogram Solutions

Below are the solutions to these exercises on correlations and correlograms. #################### # # # Exercise 1 # # # #################### auto <- read.csv(“auto.csv”) cor(auto$MPG, auto$Price) ## [1] -0.4757351 #################### # # # Exercise 2 # # # #################### cor.test(auto$MPG, auto$Price) ## ## Pearson’s product-moment correlation ## ## data: auto$MPG and auto$Price ## t = […]

## Data structures Solutions (Part 1)

Below are the solutions to these exercises on R Data Structures. #################### # # # Exercise 1 # # # #################### charactertype<-‘A’ integertype<-10 logicaltype<-TRUE complextype<-2+3i rawtype<-charToRaw(‘x’) print(charactertype) ## [1] "A" print(integertype) ## [1] 10 print(logicaltype) ## [1] TRUE print(complextype) ## [1] 2+3i print(rawtype) ## [1] 78 #################### # # # Exercise 2 # # # […]

## Data Science for Operational Excellence (Part-1)

Below are the solutions to these exercises on Linear Programming. #################### # # # Exercise 1 # # # #################### library(lpSolve) library(igraph) #################### # # # Exercise 2 # # # #################### set.seed(1234) assign.costs <- matrix(sample(50:100, 16, replace=T), ncol=4) #################### # # # Exercise 3 # # # #################### x <- lp.assign(assign.costs) x$solution ## [,1] […]

## Data science for Doctors: Inferential Statistics Solutions(Part-4)

Below are the solutions to these exercises on inferential statistics. #################### # # # Exercise 1 # # # #################### f_1 <- rnorm(28,29,3) f_2 <- rnorm(23,29,6) f <- sd(f_1)^2/sd(f_2)^2;f ## [1] 0.253262 #OR f <- var(f_1)/var(f_2); f ## [1] 0.253262 #################### # # # Exercise 2 # # # #################### df_num <- length(f_1)-1; df_num ## […]