Below are the solutions to these exercises on generalized linear models. if (!’titanic’ %in% installed.packages()) install.packages(‘titanic’) library(titanic) ## Warning: package ‘titanic’ was built under R version 3.3.3 DATA <- titanic_train[,-c(1,4,9,11)] #################### # # # Exercise 1 # # # #################### (lm_reg <- lm(formula = Survived ~ Age + Fare, data = DATA)) ## ## Call: […]

## Generalized linear functions (Beginners)

On this set of exercises, we are going to use the lm and glm functions to perform several generalized linear models on one dataset. Since this is a basic set of exercises we will take a closer look at the arguments of these functions and how to take advantage of the output of each function […]

## Probability functions advanced

In this set of exercises, we are going to explore some applications of probability functions and how to plot some density functions. The package MASS will be used in this set. Note: We are going to use random numbers functions and random processes functions in R such as runif. A problem with these functions is […]

## Probability functions advanced solutions

Below are the solutions to these exercises on probability functions. if (!’MASS’ %in% installed.packages()) install.packages(‘MASS’) library(MASS) #################### # # # Exercise 1 # # # #################### set.seed(1) random_numbers <- runif(100, min = .5, max = 6.5) (round(random_numbers)) ## [1] 2 3 4 6 2 6 6 4 4 1 2 2 5 3 5 3 […]

## Probability functions intermediate solutions

Below are the solutions to these exercises on probability functions. if (!’MASS’ %in% installed.packages()) install.packages(‘MASS’) library(MASS) #################### # # # Exercise 1 # # # #################### set.seed(1) (random_numbers <- runif(30, min = 0, max = 6)) ## [1] 1.5930520 2.2327434 3.4371202 5.4492467 1.2100916 5.3903381 5.6680516 ## [8] 3.9647868 3.7746843 0.3707176 1.2358474 1.0593405 4.1221371 2.3046223 ## […]

## Probability functions intermediate

In this set of exercises, we are going to explore some of the probability functions in R by using practical applications. Basic probability knowledge is required. In case you are not familiarized with the function apply, check the R documentation. Note: We are going to use random numbers functions and random processes functions in R […]

## Probability functions beginner

On this set of exercises, we are going to explore some of the probability functions in R with practical applications. Basic probability knowledge is required. Note: We are going to use random number functions and random process functions in R such as runif, a problem with these functions is that every time you run them […]

## Probabilty functions beginner solution

Below are the solutions to these exercises on probability functions. #################### # # # Exercise 1 # # # #################### set.seed(1) random_numbers <- runif(10) #################### # # # Exercise 2 # # # #################### (coin_tosses_1 <- ifelse(random_numbers>.5, ‘head’, ‘tail’)) ## [1] “tail” “tail” “head” “head” “tail” “head” “head” “head” “head” “tail” set.seed(1) (coin_tosses <- rbinom(n […]

## Character Functions (Advanced)

This set of exercises will help you to help you improve your skills with character functions in R. Most of the exercises are related with text mining, a statistical technique that analyses text using statistics. If you find them interesting I would suggest checking the library tm, this includes functions designed for this task. There […]

## Character Functions Advanced (Solutions)

Below are the solutions to these exercises on character functions. #Run before the first exercise if (!’tm’ %in% installed.packages()) install.packages(‘tm’) library(tm) txt <- system.file(“texts”, “txt”, package = “tm”) ovid <- VCorpus(DirSource(txt, encoding = “UTF-8”), readerControl = list(language = “lat”)) TEXT <- lapply(ovid[1:5], as.character) TEXT1 <- TEXT[[4]] OVID <- c(data.frame(text=unlist(TEXT), stringsAsFactors = F))$text #################### # # […]