Answers to the exercises are available here. Exercise 1 Consider 3 vectors, day, month and year: year=c(2005:2016) month=c(1:12) day=c(1:31) Define a list Date such as: Date= $year [1] 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 $month [1] 1 2 3 4 5 6 7 8 9 10 11 12 $day […]

## List Vol.2: solutions

Below are the solutions to these exercises on list vol. 2. #################### # # # Exercise 1 # # # #################### #Consider 3 vectors, day, month and year: year=c(2005:2016) month=c(1:12) day=c(1:31) #Define a list Date such as: #Date= #$year #[1] 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 #$month # [1] […]

## Web Scraping Exercises

[For this exercise, before proceeding, first read the rvest package help and the selectorgadget help.] Answers to the exercises are available here. Exercise 1 Consider the url ‘http://statbel.fgov.be/en/statistics/figures/economy/indicators/prix_prod_con/’ Extract all the information load on table ‘Third Quarter 2016’. Exercise 2 Consider the url ‘http://www2.sas.com/proceedings/sugi30/toc.html’ Extract all the papers names, from 001-30 to 268-30 Exercise 3 […]

## Web Scraping Solutions

Below are the solutions to these exercises. #################### # # # Exercise 1 # # # #################### #Consider the url ‘http://statbel.fgov.be/en/statistics/figures/economy/indicators/prix_prod_con/’ #Extract all the information load on table ‘Third Quarter 2016’. library(‘rvest’) url=’http://statbel.fgov.be/en/statistics/figures/economy/indicators/prix_prod_con/’ TAB=read_html(url)%>%html_nodes(‘td’)%>%html_text() NAMES=read_html(url)%>%html_nodes(‘th’)%>%html_text() M=data.frame(matrix(TAB,ncol=5,nrow=9,byrow=T)) M=cbind(NAMES[7:15],M) names(M)=NAMES[1:6] M ## Gross indices (2010=100) I II III IV Year ## 1 2008 99.9 101.2 101.0 102.3 […]

## Recursive Partitioning and Regression Trees Exercises

[For this exercise, we will work using the package rpart. This is a beginner level exercise. Please refer to the help of rpart package] Answers to the exercises are available here. Exercise 1 Consider the Kyphosis data frame(type help(‘kyphosis’) for more details), that contains: -Kyphosis:a factor with levels absent present indicating if a kyphosis (a […]

## Recursive Partitioning and Regression Trees – Solutions

Below are the solutions to these . #################### # # # Exercise 1 # # # #################### #1) Build a tree to classify Kyphosis from Age, Number and Start. library(‘rpart’) TREE=rpart(Kyphosis ~ Age + Number + Start, data=kyphosis,method="class") TREE ## n= 81 ## ## node), split, n, loss, yval, (yprob) ## * denotes terminal node […]

## Matrix Vol. 2 Exercises

[For this exercise, first write down your answer, without using R. Then, check your answer using R.] Answers to the exercises are available here. Exercise 1 If M=matrix(c(1:10),nrow=5,ncol=2, dimnames=list(c(‘a’,’b’,’c’,’d’,’e’),c(‘A’,’B’))) What is the value of: M Exercise 2 Consider the matrix M, What is the value of: M[1,] M[,1] M[3,2] M[‘e’,’A’] Exercise 3 Consider the matrix […]

## Matrix Vol.2 Solutions

Below are the solutions to these exercises on regular sequences. #################### # # # Exercise 1 # # # #################### #If M=matrix(c(1:10),nrow=5,ncol=2,dimnames=list(c(‘a’,’b’,’c’,’d’,’e’),c(‘A’,’B’))) #What is the value of: M ## A B ## a 1 6 ## b 2 7 ## c 3 8 ## d 4 9 ## e 5 10 #################### # # # […]

## Functions exercises vol. 2

[For this exercise, first write down your answer, without using R. Then, check your answer using R.] Answers to the exercises are available here. Exercise 1 Create a function that given a data frame and a vector, will add a the vector (if the vector length match with the rows number of the data frame) […]

## Functions exercises vol. 2: solutions

Below are the solutions to these exercises. #################### # # # Exercise 1 # # # #################### # Create a function that given a data frame and a vector, will add a the vector (if the vector length match with the rows number of the data frame) # as a new variable to the data […]