Blog Archives

List Vol.2 Exercises

December 27, 2016
By
List Vol.2 Exercises

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 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 $month 1 2 3 4 5 6 7 8 9 10 11 12 $day

Read more »

Web Scraping Exercises

December 20, 2016
By
Web Scraping Exercises

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

Read more »

Recursive Partitioning and Regression Trees Exercises

December 13, 2016
By
Recursive Partitioning and Regression Trees Exercises

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

Read more »

Matrix Vol. 2 Exercises

Matrix Vol. 2 Exercises

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 M M M Exercise 3 Consider the matrix

Read more »

Functions exercises vol. 2

Functions exercises vol. 2

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)

Read more »

Scripting Loops exercises Vol.2

Scripting Loops exercises Vol.2

Answers to the exercises are available here. Exercise 1 Using the following variables: x=1 i=c(1:10) For this exercise, write a for() loop that increments x by two for each i. Exercise 2 Using the following variables: x=1 y=40

Read more »

Data frame exercises Vol. 2

November 28, 2016
By
Data frame exercises Vol. 2

Answers to the exercises are available here. Exercise 1 Consider two vectors: x=seq(1,43,along.with=Id) y=seq(-20,0,along.with=Id) Create a data.frame df: >df Id Letter x y 1 1 a 1.000000 -20.000000 2 1 b 4.818182 -18.181818 3 1 c 8.636364 -16.363636 4 2 a 12.454545 -14.545455 5

Read more »

If else sequences Exercises

November 22, 2016
By
If else sequences Exercises

Answers to the exercises are available here. Exercise 1 What is the output of: ifelse(sqrt(9)<2,sqrt(9),0) Exercise 2 What is the output of: ifelse(sqrt(100)>9,sqrt(100),0) Exercise 3 What is the output y of: x=12 if(is.numeric(x)) y=x*2 Exercise 4 What is the output x,y of: z=-1 if(z<0){x=abs(z);y=z*3} Exercise 5 What is the output y of: z=6 if(z<0) y=z*3

Read more »

Vectors Vol. 2 Exercises

November 15, 2016
By
Vectors Vol. 2 Exercises

Answers to the exercises are available here. Exercise 1 Consider two vectors, x, y x=c(4,6,5,7,10,9,4,15) y=c(0,10,1,8,2,3,4,1) What is the value of: x*y Exercise 2 Consider two vectors, a, b a=c(1,2,4,5,6) b=c(3,2,4,1,9) What is the value of: cbind(a,b) Exercise

Read more »

Regular Sequences Vol. 2 Exercises

Regular Sequences Vol. 2 Exercises

Answers to the exercises are available here. Exercise 1 if x <- c(a = 1, b = 2,c=3,d=4) What is the output for the code: seq(5,11,along.with =x) Exercise 2 If x= seq(4,12,4) , what is the output for

Read more »

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)