0% found this document useful (0 votes)
33 views6 pages

DAR Question Bank (All Module)

The document is a comprehensive question bank for a Data Analytics course using R, covering various topics such as basic data types, flow control statements, loops, financial metrics calculations, data frames, string manipulation, graphical representations, and statistical measures. It includes practical exercises and R code development tasks to reinforce learning. The content is organized into modules, each focusing on different aspects of data analysis with R.

Uploaded by

mssd7511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views6 pages

DAR Question Bank (All Module)

The document is a comprehensive question bank for a Data Analytics course using R, covering various topics such as basic data types, flow control statements, loops, financial metrics calculations, data frames, string manipulation, graphical representations, and statistical measures. It includes practical exercises and R code development tasks to reinforce learning. The content is organized into modules, each focusing on different aspects of data analysis with R.

Uploaded by

mssd7511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Data Analytics with R BDS306C

Question Bank
Module 1

1. Find the output of the following:(5M)


i. sum(7:10)
ii.7:12+12:17
iii.c(3,1,8,6,7)+c(9,2,5,7,1)
iv.mean(7:10)
v.median(7,8,9,10)

2. Determine the output of following R statement


(i) c(1,2,3,4,5)+c(6,7,8,9,10)
(ii) -1:4*-2:3
(iii) identical(2^3,2**3)
(iv) 5:9%/%2
(v) c(2,4-2,1+1)==0

3. Explain the basic data types of R with examples(10M)

4. Explain the following flow control statements in R with suitable examples for each
i. If and else statement
ii.Switch Statement

5. Find the output for the following


i. seq(1:5)
ii.length(1:7)
iii.rep(1:3,4)
iv.c(“Week”,”WEEK”,”week”,”weak”)==”week”
v.5:9%%2

6.List the logical operators in R with suitable examples.(5M)


7.Develop a R program to find the factorial of given number using recursive function calls.(5)
8.Explain repeat, while and for loop with R programing example (10)

9. Explain the following loops in R with suitable examples.(10M)


i.While loop
ii.For loop

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)

11.Develop R Code to Perform the following:


a) Assign different type of values to variables and display the type of variable.
Assign different types such as Double, Integer, Logical, Complex and Character and
understand the difference between each data type.
b) Demonstrate Arithmetic and Logical Operations with simple examples.
C) Demonstrate generation of sequences and creation of vectors.
d) Demonstrate Creation of Matrices
e) Demonstrate the Creation of Matrices from Vectors using Binding Function.
f) Demonstrate element extraction from vectors, matrices and arrays

12. Explain Environment and Functions in R


13. Explain Initiating R with examples

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))

4. Describe cbind and rbind functions with example (5M)


5. Explain the date and time function with examples (5)
6. Determine the output of following examples(5M)
i. gl()
ii.paste(c(“Pine”,”Red”),”Apple”,sep=”-”))
iii.cat(“Black\nBerry”,fill=TRUE)
iv.substr(“The cat is on the wall”,5,10)
v.date1<-strptime(“22:15:45 22|08|2015”,”%H:%H:%S %d|%m|%y”)

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()

10. Describe the following with R programming example


(i)Creation of an Array
(ii) Assigning the names to elements of the array,
(iii)Accessing the elements of the array using index and names,
Module 3

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.

6. Determine the output of the following string manipulating functions.


i) grep(“my”, This is my pen”)
ii) sub(“my”, “your”, “This is my pen”)
iii)str_detect(“This is my pen”, “my”)
iv)str_split(“I like mangoes, oranges and pineapples”,”,”)
v) str_count(“I like mangoes, oranges and pineapples”,”s”)

7. Determine the output of the following string manipulation functions


i) grepl(“my”, This is my pen)
ii)gsub(“my”, “your”,”This is my pen”)
iii)str_split_fixed(“I like mangoes, oranges and pineapples”, “,|and”, n=3)
iv)str_count(“I like mangoes, oranges and pineapples”,”a|o”)
v)str_replace_all(“I like mangoes, oranges and pineapples”, “s”, “sss”)
Module 4

1. Write a note on the main graphical Packages in R.

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)

3. For the following data, plot a line plot.

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)

5. Describe the line plot and histogram with examples

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.

7. Explain the exploratory data analysis

8. Explain different parts of the box plot.

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

7. Explain linear regression analysis with example


8. Explain Analysis of Variance(ANOVA) with example
9. Demonstrate the progression of salary with years of experience using a suitable data set (You can create
your own dataset). Plot the graph visualizing the best fit line on the plot of the given data points. Plot a
curve of Actual Values vs. Predicted values to show their correlation and performance of the model.
Interpret the meaning of the slope and y-intercept of the line with respect to the given data. Implement
using lm function. Save the graphs and coefficients in files. Attach the predicted values of salaries as a
new column to the original data set and save the data as a new CSV file

You might also like