















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive question bank for the course 'r programming in data science' (1922502), designed for students in their fifth semester (v) and third year (iii). The questions cover various aspects of r programming, including data types, data structures, data manipulation, and statistical analysis. The questions are categorized by bloom's taxonomy levels, providing a structured approach to learning and assessment.
Typology: Study notes
1 / 23
This page cannot be seen from the preview
Don't miss anything!
SRM Nagar , Kattankulathur – 603 203
SRM Nagar, Kattankulathur – 603203. DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE QUESTION BANK SUBJECT : 1922502 - R PROGRAMMING IN DATASCIENCE SEM/YEAR : V / III UNIT – I Introduction to R: R Software, R packages, Data Types in R: Scalars, Vectors, Matrices, Data frames, Lists, Variables and Logical Operations. R Matrix Create, Print, Column, Slice, Factors in R, Categorical and Continuous Variables. PART- A (2 Marks) Q. No Questions BT Level Compete nce 1 Define R programming. Remembering BTL- 1 2 Differentiate between Scalars, vector, list, Matrix and Data frame. Understanding BTL- 2 3 List out any five features of R. Remembering BTL- 1 4 Differentiate between R and Python in terms of functionality. Understanding BTL- 2 5 What are the applications of R? Understanding BTL- 2 6 Why do we use the command- install.packages(file.choose(),repos=NULL)? Analyzing BTL- 4 7 Summarize some packages in R, which can be used for data imputation? Evaluating BTL- 5 8 How to get the name of the current working directory in R? Applying BTL- 3
c. Access the element at 2nd^ column and 4th row in a matrix (^3) Write a R program to find the maximum and the minimum value of a given vector. Explain the functions with syntax. (13) Applying BTL- 3 4 Write a R program to find elements which are present in two given data frames (13) Applying BTL- 3 5 Write a R program to create a data frame using two given vectors and display the duplicated elements and unique rows of the data frame. Explain with a syntax. (13) Understanding BTL- 2 6 i. Illustrate the usage of all logical operator in R. ii. Explain the use of length () and mean() function.
Understanding BTL- 2 7 Elaborate the statistical and programming features of R. (13) Understanding BTL- 2 (^8) i. Write a R program to add a new item g4 = "Python" to a given list. g1=1:10,g2=”R Program”,g3=”HTML”. ii. Explain Data frame operations.
Evaluating BTL- 5 9 Write a R program to add 3 to each element of the first vector. Print the original and new vector. (13) Analyzing BTL- 4 10 Write a R program to reverse the order of given vector.
Analyzing BTL- 4 11 Check whether the value of the element of a given vector greater than 10 or not. Return TRUE or FALSE.
Understanding BTL- 2 (^12) Write a R program to create an ordered factor from data consisting of the names of months.
Analyzing BTL- 4 13 Write a R program to create a correlation matrix from a data frame of same datatype. Explain the functions with syntax.
Applying BTL- 3 14 Create the following: Creating BTL- 6
a. Create a matrix taking a given vector of numbers as input. Display the matrix. b. To access the element at 3rd^ column and 2 nd^ row, only the 3rd^ row and 4th^ column of a given matrix.
(^15) List out the properties of the following: a. Matrix subtraction b. Matrix Division c. Matrix addition d. Matrix multiplication
Remembering BTL- 1 (^16) i. What is Factor in R and its function? ii. Distinguish two types of variables with an example.
Remembering BTL- 1 17 Explain categorical variables with an example. (13) Evaluating BTL- 5 PART – C (15 Marks) 1 i. Explain main features to write R code that runs faster. ii. Difference between package and library. With examples
Evaluating BTL- 5 2 a. i.Let’s create the following vectors: u <- 4 v <- 8 Use the elementary arithmetic operators +, - , *, /, and ^ to: add u and v subtract v from u multiply u by v divide u by v raise u to the power of v ii. Write a R program to create a vector and find the length and the dimension of the vector.
Creating BTL- 6
e. Write a R program to create inner, outer, left, right join(merge) from given two data frames
5 Create the following: a. Create factor variables b. Create ordered factor variables c. Adding and dropping levels in factor variable
Creating BTL- 6 UNIT – II R DATA STRUCTURES Scalars - Vectors Matrices - List - Data Frames-Factors - Packages - Data Reshaping
- Data management with repeats, sorting, ordering and lists - Vector indexing, factors, Data management with strings, display and formatting. PART – A (2-Marks) Q. No Questions BT Level Compete nce 1 Define R vector? Understanding BTL- 2 (^2) Define R lists? Understanding BTL- 2 (^3) To reverse the order of given vector using R vector. Remembering BTL- 1 4 Difference between data frame and a matrix in R? Analyzing BTL- 4 5 List out the various forms of reshaping data in a data frame. Remembering BTL- 1 6 Examine why R- data reshaping is important? Applying BTL- 3 7 Define Transpose of a matrix. Understanding BTL- 2 8 Define melt() and cast() function. Understanding BTL- 2 (^9) Define Tidyr package. Understanding BTL- 2 (^10) Identify the use of sort () function. Remembering BTL- 1 11 List out the various sorting mechanisms. Remembering BTL- 1 12 Explain factor variable? Evaluating BTL- 5 13 Explain the recycling of elements in an R vector? Give an example. Evaluating BTL- 5 14 Differentiate vector index and Negative index. Analyzing BTL- 4 (^15) Analyze what is meant by out-of-range index? Analyzing BTL- 4
(^16) Explain the use of length () function? Evaluating BTL- 5 (^17) Point out the attributes of a factor. Analyzing BTL- 4 18 Show how to count the number of NA values in a data frame column Remembering BTL- 1 (^19) Convert a matrix to a 1-dimensional array using Rcode. Applying BTL- 3 (^20) How will you read a .csv file in R language? Applying BTL- 3 21 Convert a given pH levels of soil to an ordered factor using R Code. Applying BTL- 3 (^22) Write a R program to get the structure of a given data frame Creating BTL- 6 (^23) Write a R program to get the length of the first two vectors of a given list. g1=1:10,g2=”R Program”,g3=”HTML”. Creating BTL- 6 24 Show the R code to Add 10 to each element of the first vector in a given list. g1=1:10,g2=”R Program”,g3=”HTML”. Remembering BTL- 1 PART- B (13 Marks) 1 Explain in detail about data frame with example R code. (13) Remembering BTL- 1 2 Demonstrate an R code to find the factorial of a number (use recursion) (13) Applying BTL- 3 3 Explain list data structure and its operations with examples. (13) Remembering BTL- 1 4 Create a simple data frame from 3 vectors. Order the entire data frame by the first column. (13) Understanding BTL- 2 5 i.Explain about how to create a list in R with an example? ii.Explain how to access list element? iii. Explain how to operate on lists in R?
Remembering BTL- 1 6 Convert the following multi-line operations to a single expression. Check that both approaches give the same result. Part a: w<- u + v w <- w / 2 (13) Evaluating BTL- 5
(^17) Illustrate R program to create two 2x3 matrix and add, subtract, multiply and divide the matrixes. (13) Analyzing BTL- 4 PART – C(15 Marks) 1 Create the vectors: (a) (1, 2, 3,... , 19, 20) (b) (20, 19,... , 2, 1) (c) (1, 2, 3,... , 19, 20, 19, 18,... , 2, 1) (d) (4, 6, 3) and assign it to the name tmp. For parts (e), (f) and (g) look at the help for the function rep. (e) (4, 6, 3, 4, 6, 3,... , 4, 6, 3) where there are 10 occurrences of 4. (f) (4, 6, 3, 4, 6, 3,... , 4, 6, 3, 4) where there are 11 occurrences of 4, 10 occurrences of 6 and 10 occurrences of 3. (g) (4, 4,... , 4, 6, 6,... , 6, 3, 3,... , 3) where there are 10 occurrences of 4, 20 occurrences of 6 and 30 occurrences of 3.
Creating BTL- 6 2 i. Explain operations on vectors. ii. Write R program to check a given number is Even or Odd.
Evaluating BTL- 5 3 Explain R function for differentiation and integration with an example? (15) Evaluating BTL- 5 (^4) i.Consider two vectors u and v: u <- c(8, 9, 10) v <- c(1, 2, 3) Create a new vector w in a single line of code: w <- (2 * u + v) / 10 or carry out each operation on a separate line: w <- 2 * u (7) Creating BTL- 6
w <- w + v w <- w / 10 ii.Convert the following expressions to separate operations, and check that both approaches give the same result: w <- (u + 0.5 * v) ^ 2 w <- (u + 2) * (u - 5) + v w <- (u + 2) / ((u - 5) * v)
5 i.Create a simple data frame from 3 vectors. Order the entire data frame by the first column. ii.Create a data frame from a matrix of your choice, change the row names so every row says id_i (where i is the row number) and change the column names to variable_i (where i is the column number). I.e., for column 1 it will say variable_1, and for row 2 will say id_2 and so on.
Creating BTL- 6 UNIT – III - DATA PREPARATIONS R Data Frame: Create, Append, Select, Subset. R sort a data Frame using Order (), R Dplyr: Data manipulation and Cleaning, Merge Data Frames in R: Full and Partial Match, Functions in R programming. PART-A (2 Marks) Q. No Questions BT Level Compete nce 1 List out the characteristics of a data frame. Remembering BTL- 1 2 Define the structure of a data frame using str () function. Applying BTL- 3 3 What is the use of nrow () function? Understanding BTL- 2 (^4) What is the use of subset() function? Understanding BTL- 2 (^5) Write R code to select a column of a data frame. Analyzing BTL- 4 (^6) List down the methods to sort a data frame. Remembering BTL- 1
(^5) List out the functions to select variables based on their names. (13) Remembering BTL- 1 (^6) List out the purpose of data cleaning in R with an example. (13) Remembering BTL- 1 7 Explain about Data Manipulation with dplyr package (13) Evaluating BTL- 5 8 With the dataset swiss, create a data frame of only the rows 1, 2, 3, 10, 11, 12 and 13, and only the variables Examination, Education and Infant.Mortality. a) The infant mortality of Sarine is wrong, it should be a NA, change it. b) Create a row that will be the total sum of the column, name it Total. c) Create a new variable that will be the proportion of Examination (Examination / Total)
Creating BTL- 6 (^9) Show how to clean the column names of a data frame using R Programming with an example. (13) Applying BTL- 3 (^10) Explain the following a. rbind() to merge two R data frames b. cbind() to merge two R data frames c. merge()
Understanding BTL- 2 11 Analyze R code for the following: a. Find partial match in a specific column b. Find several partial matches
Analyzing BTL- 4 (^12) Write the syntax for writing functions in R with a sample program. (13) Analyzing BTL- 4 13 Write the R code for the following a. Calling a function with default arguments b. Calling a function with arguments c. Calling a function without arguments
Applying BTL- 3 (^14) Summarize the features of R function? (13) Understanding BTL- 2
Explain the following: a. Full Match b. Partial match 15 Summarize the functions which helps in importing data from other applications in R. With an example. (13) Understanding BTL- 2 (^16) List out the commonly used functions in dplyr package. (13) Remembering BTL- 1 (^17) i.Explain the following example for writing a function a. Throwing a die ii.Write a short note on: a.Data Manipulation b.Data Cleaning (13) Understanding BTL- 2 PART-C (15 Marks) 1 Develop the R code for the following: a. Subset data frame by selecting columns b. Subset data frame by excluding columns c. Subset data frame by selecting rows (15) Creating BTL- 6 2 Create the dataframe data <- data.frame(x1 = 1:6, x2 = c(1, 2, 2, 3, 1, 2), x3 = c("F", "B", "C", "E", "A", "D")) Use the following functions a. Arrange function b. Filter function c. Mutate function d. Pull function e. Rename function f. Sample)n function g. Select function
Creating BTL- 6 3 Explain with a Sample (Dummy) Data in R and perform data manipulation with R. (15) Evaluating BTL- 5
(^16) Show Z-test and t-test explain with an equation? Applying BTL- 3 (^17) Show the purpose of using ANOVA test? Applying BTL- 3 18 Write the syntax of Covariance and Correlation. Creating BTL- 6 19 Discuss about variance. Evaluating BTL- 5 20 Discuss about standard deviation. Evaluating BTL- 5 (^21) Explain histogram. Evaluating BTL- 5 (^22) Explain Time series analysis. Analyzing BTL- 4 23 How R can be used for predictive analysis? Understanding BTL- 2 24 How would you measure correlation in R? Understanding BTL- 2 PART-B (13 Marks) 1 Summarize the operations that can be performed on a Data frame. (13) Evaluating BTL- 5 2 Demonstrate with syntax how to select the subset of the data frame. (13) Applying BTL- 3 3 How to access components of a Data Frame? (13) Understanding BTL- 2 4 Illustrate how to import data in R programming. (13) Applying BTL- 3 5 List out the various methods that one can export data to a text file with a syntax. (13) Remembering BTL- 1 6 How to create two different x and y-axes? Explain with an example. (13) Understanding BTL- 2 7 How to add or change the R plot’s legend? Write a syntax with an example. (13) Understanding BTL- 2 8 How to adjust the size of points in an R plot? Write a syntax with an example. (13) Understanding BTL- 2 9 Illustrate the bivariate analysis of two categorical variables. (13) Applying BTL- 3 10 Point out the function which is used for the conversion of covariance to correlation in R. Explain the function with syntax. (13) Analyzing BTL- 4 (^11) List out the methods for calculating the correlation with an example. (13) Remembering BTL- 1 12 Elaborate variance for regression model with an example program. (13) Analyzing BTL- 4
(^13) Analyze the difference between covariance and correlation. (13) Analyzing BTL- 4 (^14) i. List out few applications of covariance. ii.Briefly explain about statistical functions for central tendency.
Remembering BTL- 1 15 i.List out few applications of correlations. ii.How to handle the bivariate data through graphics?
Remembering BTL- 1 (^16) i.Discuss about plot () function. ii.Create the scatterplot for the relation between weight and miles per gallon.
Evaluating BTL- 5 17 Create the following for line chart: a. Simple line graph in R code with plot function b. Saving line graph in the PNG file. c. Create multiple lines in the line chart and add a legend to line graph
Creating BTL- 6 PART – C (15 Marks) (^1) Explain with an example a. how to create a data frame b. To add the new variables to data frame. c. How to modify a data frame in R?
Evaluating BTL- 5 2 Write a code to demonstrate various charts using tree datasets for the following a. Histogram b. Scatter plot c. Box plot d. Line chart
Creating BTL- 6 3 Show the inferences about skewness and kurtosis of a population given below: Frequency distribution of litter size in rats, n- 815 Litter Size 1 2 3 4 5 6 7 8 9 1 0 1 1 12 Freq- ency 7 3 8 5 8 116 125 126 121 107 5 6 3 7 2 5 4 (15) Creating BTL- 6
(^12) Why do you need to prune the decision tree? Remembering BTL- 1 (^13) Define Tree Boosting? Remembering BTL- 1 14 How is a Random Forest related to Decision trees? Applying BTL- 3 15 Define Entropy. Remembering BTL- 1 16 What is Out-of-Bag error? Remembering BTL- 1 (^17) What do you mean by Bagging? Remembering BTL- 1 (^18) Can random forest algorithm be used both for continuous and categorical target variables? Evaluating BTL- 5 (^19) Write Generalized Linear Model (GLM) function. Evaluating BTL- 5 20 How to create generalized linear model in R? Understanding BTL- 2 21 Write out the generalized linear model in R? Evaluating BTL- 5 22 What is the main difference between k-Means and k- Nearest Neighbours? Analyzing BTL- 4 23 What is the difference between the Manhattan Distance and Euclidean Distance in Clustering? Analyzing BTL- 4 24 Write about how to pre-process the data for k-Means? Creating BTL- 6 PART-B (13 Marks) 1 Illustrate with an example how to read a particular file from the working directory. (13) Applying BTL- 3 2 Explain merge () function and its use with an example. (13) Evaluating BTL- 5 3 List out text file properties with examples (13) Remembering BTL- 1 4 List out the basic assumptions of linear regression. (13) Remembering BTL- 1 5 i. How would you detect over fitting in linear models and how to avoid it? ii. Identify the problem of over fitting and under fitting.
Understanding BTL- 2 6 How is the Error calculated in a Linear Regression model? (13) Understanding BTL- 2 7 i.How does the CART algorithm produce Regression Trees? ii.Brief the following ( 7 ) Understanding BTL- 2
a. XML Files b. Binary Files c. CSV Files
(^8) Compare Linear Regression and Decision trees. (13) Analyzing BTL- 4 (^9) i.Explain the structure of decision tree. ii.Explain about Generalized Linear Model in R with example.
Evaluating BTL- 5 10 Compare how the random forest give output for classification and regression problems. (13) Analyzing BTL- 4 11 Summarize advantages of using Random Forest. (13) Understanding BTL- 2 12 Analyze how does Random Forest handle missing values? (13) Analyzing BTL- 4 13 Describe how it is possible to perform Unsupervised learning with random forest? (13) Remembering BTL- 1 14 Use the adult data set to illustrate Logistic regression. The “adult” is a great dataset for the classification task. The objective is to predict whether the annual income in dollar of an individual will exceed 50.000. The dataset contains 46,033 observations and ten features: age: age of the individual. Numeric education: Educational level of the individual. Factor. marital.status: Marital status of the individual. Factor i.e. Never-married, Married-civ-spouse, … gender: Gender of the individual. Factor, i.e. Male or Female (13) Applying BTL- 3