In the Exercises we will discuss User Defined Function in R Answers to the exercises are available here. Exercise 1 Create a function to print square of number Exercise 2 Create a function to print a number raise to another with the one argument a default argument Exercise 3 Create a function to print class […]

## User Defined Functions in R Solutions (Part-1)

Below are the solutions to these User Defined Functions in R Part 1 #################### # # # Exercise 1 # # # #################### sqr<- function(number) { i<-1 while(i<=number){ s <- i^2 i=i+1 } print(s) } sqr(10) ## [1] 100 #################### # # # Exercise 2 # # # #################### raisefn<- function(num, r = 3) { […]

## Data Structures Exercises (Part 2)

In the Exercises we will cover Hashes, Factors and Zoo in R Answers to the exercises are available here. Exercise 1 Create a Hash based Key Value Pairs with three employees, with Employees as the key and the name as the values. Exercise 2 Create Hash of an Employee with the Name, Age, Address & […]

## 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 #################### […]

## 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 Structures Exercises (Part-1)

R Programming has various Data Structures for efficient manipulation of Data. Following are the list of data structures supported by R. 1. Vectors 2. Lists 3. Matrix 4. Data frame This exercise helps through various operations of R Data structures. Answers to the exercises are available here. Exercise 1 Create an atomic vector of Character […]