DAR Question Bank (All Module)
DAR Question Bank (All Module)
Question Bank
Module 1
4. Explain the following flow control statements in R with suitable examples for each
i. If and else statement
ii.Switch Statement
10. Develop R code to calculate the following financial metrics in order to assess the financial
statement of an organization being supplied with 2 vectors of data: Monthly Revenue =[50, 60,
70, 80, 90, 100, 110, 120, 130, 140, 155, 165] and Monthly Expenses =[30, 35, 40, 45, 50, 55,
60, 65, 70, 75, 80, 85] for the financial year
(i)Profit for each month.
(ii)Profit after tax for each month (Tax Rate is 30%).
(iii)Profit margin for each month equals to profit after tax divided by revenue.
(iv)Good Months – where the profit after tax was greater than the mean for the year.
v). Bad Months – where the profit after tax was less than the mean for the year.
vi. The best month – where the profit after tax was max for the year.
vii. The worst month – where the profit after tax was min for the year(10)
Module 2
1. Develop a R program to create two 3 X 3 matrices A and B and perform the following
operations i) Transpose of the matrix ii) addition iii) subtraction iv) multiplication, v)Access
the first row of matrix A
2. Describe the following with R programming example
(i)Creation of list
(ii) Assigning the names to elements of the list,
(iii)Accessing the elements of the list using index and names,
iv)conversion of the vector to list,
v)combine two lists.(10)
3. Determine the output of following R statement
(i)paste(c("Pine", "Red"),"Apple"),
(ii)substring("The cat is on the wall",3,10),
(iii)strsplit("I like Banana, Orange and Pineapple" , " "),
iv)gl(5,3,labels=c(‘one’,’two’,’three’,’four’,five))
7. Develop R program to create a DataFrame with following details and do the following
operations:(10M)
i. Subset the dataframe and display the details of only those items whose price is
greater than or equal to 350.
ii. Subset the dataframe and display only the items where the category is "Office
Supplies" and "Desktop Supplies".
iii. Create another dataframe called "item-details" with three different fields
itemCode, ItemQtyonHand and ItemRecorderLvl and merge the two frame.
8. Determine the output of the following functions applied on the given dataframe.(5M)
x<-c(5,6,7,8)
y<-c(15,16,17,18)
z<-c(25,26,27,28)
G<-data.frame(x,y,z)
i) colSums(G[,1:2])
ii)colMeans(G[,1:3])
iii)rowSums(G[1:3,])
iv)rowMeans(G[2:4,]
v)colMeans(,G[1:2])
9. Explain the following string functions with suitable examples.
i) cat()
ii) sprint()
iii) strsplit()
iv) substr()
v) toupper()
1. Describe the following data frame manipulation function with examples (10)
(i)with(),
(ii)within(),
(iii)order()
2. Design a data frame in R for storing about 10 employee details. Create a CSV file named
“input.csv” that defines all the required information about the employee such as id, name,
salary, start_date, dept. Import into R and do the following analysis.
i) Find the total number rows & columns
ii) Find the maximum salary
iii) Retrieve the details of the employee with maximum salary
iv) Retrieve all the employees working in the IT Department.
v) Retrieve the employees in the IT Department whose salary is greater than 20000
3. Develop R code to illustrate the concept of the following Grouping Function
(i)apply(),
(ii)lapply(),
(iii)mapply(),
(iv)rapply(),
(v)tapply()
4. List the types of files .Describe the functions used for importing and exporting various
types of files with example programs
5. Develop R code to demonstrate the concept of data reshaping using cbind() and rbind()
function with relevant input and output.
2. Write the basic syntax for creating pie chart and explain each parameter listed in the
syntax. Also write a R program to create a pie chart for the given list of flowers with count
[Rose=25, Lotus=35, Lilly=10, Sunflower=5, Jasmine=15]. Draw the created output chart.
(10)
male <-c(1000,2000,1500,4000,800)
female<-c(700,300,600,1200,800)
child<-c(1000,1200,1500,800,2000)
wages<-c(“Male”,”Female”,”Children”)
4. Write the syntax for plotting the histogram and plot the histogram for the following data.
x<-c(45,33,31,23,58,47,39,58,28,55,42,27)
6. Let us use the built-in dataset air quality which has Daily air quality measurements in New
York, May to September 1973. Develop R program to generate histogram by using
appropriate arguments for the following statements.
a) Assigning names, using the air quality data set.
b) Change colors of the Histogram
c) Remove Axis and Add labels to Histogram
d) Change Axis limits of a Histogram
e) Add Density curve to the histogram.
9.Plot the bar plot for following data, both horizontal and vertical.
x<-matrix(c(1000,900,1500,4400,800,2100,1700,2900,3800), nrow=3,ncol=3)
years<-c(“2011”,”2012”,”2013”)
city<-c(“Chennai”,”Mumbai”,”Kolkata”)
10. With relevant graphs illustrate vertical and horizontal bar plot using base graphics with R
programming examples.
11. Describe the following with examples
boxplot(), bwplot(), ggplot()
Module 5
1. Define the basic statistical measures mean, median, mode, standard deviation and Variance. Also
develop R code to create a vector x=[45,56,78,12,3,-91,-45,15,1,24] and to find the basic statistical
measures.
2. Explain the following statistical measures functions with syntax and example for each.
i)mean() ii)median() iii)mode() iv)sd() v)var()
3. Explain the following functions for normal distribution with syntax
i) dnorm() ii)pnorm() iii)qnorm() iv)rnorm
4. Explain the following functions for binomial distribution with syntax
i)dbinom() ii)pbinom() iii)qbinom() iv)rbinom
5. Write the R code to create a regression model, predict values and plot the regression line, for the
following data.
x<-c(1510, 1740, 1380, 1860,1280,1360,1790, 1630,1520,1310)
y<-c(6300,8100,5600,9100,4700,5700,7600,7200,6200,4800)
6. Consider the dataset mtcars available in the R environment. Develop R commands to do the following
(i)find the correlation between the horse power(“hp”) and mileage per gallon(“mpg”) of the cars
(ii)Plot “hp” versus “mpg” using plot command
(iii) Find the correlation between the horse power and the cylindrical displacement(“disp”) of the cars.
(iv) Plot “hp” versus “disp” using plot command
(v)Analyse the correlation between the various columns of “mtcars” dataset