0% found this document useful (0 votes)
25 views22 pages

PROGRAMMING IN R (UBCCDE51)

Uploaded by

kill2king007
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)
25 views22 pages

PROGRAMMING IN R (UBCCDE51)

Uploaded by

kill2king007
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/ 22

ISLAMIAH COLLEGE (AUTONOMOUS)

Accredited by NAAC with ‘A++’ Grade


New Town, Vaniyambadi – 653 752.

PROGRAMMING IN R
(UBCCDE51)
Question Bank

Prepared by

Department of Computer Science & BCA


For the students admitted from
Academic year 2024-2025
ISLAMIAH COLLEGE [AUTONOMOUS]
VANIYAMBADI.
UNIT- I

Part-A (MCQ questions)

1. In 1991, R was created by Ross Ihaka and Robert Gentleman in the Department of

Statistics at the University of _____?

a. John Hopkins b. California c. Harvard d. Auckland

2. What is R?
a. A stastical programming language b. A Spread Sheet Program
c. A Web development language d. An operating system

3. R is technically much closer to the schema language than it is to the original___


language.

a. B b. B c. C++ d. S

4. Functions are defined using the_____ directive and are stores as R objects.

a.function() b. funct() c. functions() d. fun()

5. Point out the wrong statement?

a. Functions in R are “second class objects”


b. The writing of a function allows a developer to create an interface to the
code, that is explicitly specified with a set of parameters.
c.Functions provide an abstraction of the code to potential users.
d.Writing functions is a core activity of an R programmer

6. Which of the following is a valid variable name in R?

a. 2var b. var2 c.var_2 d.var#2

7. How can you assign the same value to multiple variables in one line?

a.var1, var2, var3 <- "Orange" b. var1, var2, var3 = "Orange"


c. var1, var2, var3 => "Orange" d. var1, var2, var3 => "Orange"

8. How many atomic vector types does R have?

a. 6 b. 5 c. 4 d. 3

9. Numbers in Rare generally treated as _______ precision real numbers.

a. single b. double c. real d. imaginary


10. If you explicitly want an integer, you need to specify the _____ suffix.

a. D b. R c. L d. K

11. In R programming, the very basic data types are the R-objects called?

a. Lists b. Matrices c. Vectors d. Arrays

12. Which function is used to combine the elements into a vector?

a. C() b. D() c. E() d. F()

13. Data Frames are created using the?

a. frame() function b. data.Frame() function


c. data() function d. frame.Data() function

14. A data frame is a special type of list where every element of the list has ______ length.

a. Same b. Different c. May be different d. May be same

15. A __________ is an R-object which can contain many different types of elements
inside it.

a. Vector b. Lists c. Matrix d. Functions

16. Lists can be coerced with which function?

a. As.lists b. Has. Lists c. In.lists d. Co.lists

17. A _________ is a two-dimensional rectangular data set.

a. Vector b. Lists c. Matrix d. Functions

18. __________are Data frames which contain lists of homogeneous data in a tabular
format.

a. Matrix b. Vector c. Lists d. Array

19. Which function takes a dim attribute which creates the required number of
dimensions?

a. Vector b. Array c. Matrix d. Lists


20. Which class not belongs to R classes?

a. S2 b. S3 c. S4 d. Reference Classes

Part-B (Short Answer Questions)

1. Who invented R Programming?


2. When was R Programming Language invented?
3. Why was R Programming Created?
4. Why R is called R?
5. What is meant by R Programming?
6. Who uses R?
7. What does in R mean?
8. Write any four Math Functions in R.
9. List the difference between Vector and List.
10. Define Lists.
11. What is meant by Matrices in R?
12. Define Arrays in R.
13. Differentiate between Array and Vector.
14. Write R-Code to Lazy Evaluation of Functions.
15. Calculate the Cumulative Sum and Cumulative Product for the given data using R-
Code 23, 1, 7, -2, 8, 10 and 17.
16. Find the Maximum and Minimum for R-Code: 14, 23, 16,20,0, -17, 100, 6.
17. What is Batch Mode?
18. What is Data Frame?
19. Write about Vectors in R.
20. What is meant by Default Value for arguments?
PART – C

1. What are the different modes of working with R?


2. What is a Vector in R? Explain operations on Vectors.
3. What is a List? Explain the Concept of Lists in R with examples.
4. Explain in detail about Data Frame and Arrays with example in R-Code.
5. What are the different forms of Data Types and how to test the data type in R? Give
on example for each.
6. Explain R as Calculator using basic operations and built-in functions with suitable
example.
7. Write any four Math Functions with suitable examples in R-Code.
8. How to Pass Default Values for arguments in R.
9. Write R-Code to Lazy Evaluation of functions.
10. Explain how to access list elements in R?
11. Explain in detail about Variables with suitable examples in R-Code.
12. Explain different Advanced Data Structures in R.
13. Explain different types of Operators in R.
14. Explain R Sessions in detail.

PART – D

1. Explain in detail about Basic Mathematical Operators with examples in R-Code.


2. Elaborate the following R Objects: a) Vector b) Data Frame c) Matrices d) List.
3. Identify the different ways to access the R objects. List the different data types in R
with suitable examples.
4. Explain R Sessions and Functions in detail.
5. What are the different forms of Vectors and how to test the Vectors in R? Give on
example for each.
6. Identify the different ways in Matrices to access the R Objects. List the different types
of Arrays in R with suitable examples.
7. What are the data structures in R that is used to perform statistical analyses and create
graph?
Unit-II

Part-A (MCQ questions)

1. How do you start writing an if statement in R?

a. if (x > y) b. if x > y: c. if x > y then: d. None of the above

2. Point out the correct statement?

a. Blocks are evaluated until a new line is entered after the closing brace
b. Single statements are evaluated.
c. The if/else statement conditionally evaluates two statements
d. Break will execute a loop while a condition is true

3. _______ is used to break the execution of a loop.

a. next b. skip c. break d. delete

4. What will be the output of the following R code?

> y <- fruit“”


> switch(y,fruit = “banana” , vegetable = “broccoli” , “Neither”)

a. “banana” b. “Neither” c. “broccoli” d. Error

5. The syntax of the for loop is?

a. for (name in vector) b. for ($name in vector)


statement1 statement1

c. for loop (name in vector) d. forif loop ($name in vector)


statement1 statement1

6. Which of the following R syntax is correct for while loop?

a. while ( statement1 ) statement2 b. while ( statement1 ) else statement2

c. while ( statement1 ) do statement2 d. while ( statement2 ) doelse statement2

7. ________ initiates an infinite loop right from the start.

a. never b. repeat c. break d. set


8. Which of the following is apply function in R?

a. apply() b. tapply() c.fapply() d.rapply()

9. Point out the correct statement?

a.Writing functions is a core activity of an R programmer

b. Functions are often used to encapsulate a sequence of expressions that need to be


executed numerous times.

c. Functions are also often written when code must be shared with others or the public

d. All of the mentioned

10. ________ loop over a list and evaluate a function on each element.

a. apply() b. lapply() c. sapply() d.mapply()

11. R code can be tested using _________________ package.

a. Dplyr b. Hadley’s testthat c. SKLearn d. KNN

12. The __________ function returns a list of all the formal arguments of a function.

a. formals() b. funct() c. formal() d. fun()

13. You can check to see whether an R object is NULL with the _________ function.

a. is.null() b. is.nullobj() c. as.null() d. as.nullobj()

14. Point out the correct statement?

a. In R, a function is an object which has the mode function


b. R interpreter is able to pass control to the function, along with arguments that may
be necessary for the function to accomplish the actions that are desired.
c. Functions are also often written when code must be shared with others or the public
d. All of the mentioned
15. Which of the following code will print NULL?
a. >args(paste) b. >arg(paste) c. >args(pastebin) d. arg(bin)

16. Which function calculates the absolute value?


a. log() b. sqrt() c. abs() d. mean()
17. Which function is used to read information from CSV file?
a. read.csv() b.write.csv c. Read.table() d.Write.table()

18. How many ways we can pass arguments to function?


a. 5 b. 3 c.4 d. 2

19. Which package is used to implement pointer concept in R programming?


a. ‘pointr’ package b. caret c. dplyr d. ggplot

20. Which one is not a type of recursion in R programming?


a. Direct Recursion b. Nested Recursion
c. Mutual Recursion d. conquer Recursion

PART – B (Short Answer Questions)


1. What are the three types of loops available in R?
2. What is use of if-else statement in R?
3. Give the syntax for loop in R.
4. Define Break and Next statement in R.
5. Mention the use of lapply () function.
6. What is a vector in R Programming?
7. Write syntax of if else in R.
8. Define recursive function.
9. Define binary search tree.
10. Define a function and mention its uses.
11. What is meant by default value for arguments?
12. Write syntax of next statement.
13. Differentiate between While and Repeat Statement.
PART – C

1. Draw the flow chart for the for loop and print the numbers from 1 to 10 using for
loop.
2. Write an R program to find a square for the given vector x->c (5, 12, 13).
3. Discuss about while statement with suitable example.
4. Define Repeat statement and discuss with suitable examples.
5. Write a note and draw the flow chart for the following Statement:
a) Break b) Next
6. Discuss about Looping Over Non-Vector Sets.
7. What are return values? Give an example for return values.
8. Write short notes on No Pointers in R.
9. Write R Code for Quick Sort.
10. Write R Code for Recursion.
11. Explain Functions are Objects in R.
12. Write R Code to return complex object.
13. Describe Default Values for Arguments with suitable example in R.

PART – D

1. Explain Loops in Control Statements with examples in R.


2. What are the different forms of return values and how to test the return values in R?
Give on example for each.
3. Explain in Conditional Statements with examples in R.
4. Write about apply method in R? Write about lapply (), sapply () with suitable
examples.
5. Describe Arithmetic and Boolean Operators and Values with suitable examples in R.
6. Explain Binary Search Tree Implementation using R.
Unit-III

Part-A (MCQ questions)

1. What is R used for in math?

a. R=real numbers b. Z= integers

c. N= natural numbers d. All of the above

2. Both mathematical and logical concepts are used in computer system in _____ form.

a. Simulation Modelling b. Complex algebra modelling


c. Software applications d. programming languages

3. ________ generate random Normal variates with a given mean and standard deviation.

a. dnorm b. rnorm c. pnorm d. rpois

4. Point out the correct statement?

a. R comes with a set of pseudo-random number generators


b. Random number generators cannot be used to model random inputs
c. Statistical procedure does not require random number generation
d. For each probability distribution there are typically three functions

5. Which function rounds a number upwards to its nearest integer?

a. abs() b. ceiling() c. floor() d. max()

6. Which function is used to return cumulative sums?

a. cumsum() b. cumprod() c. cumulative() d. sum()

7. Which function returns the vevtor of the pair-wise minima?

a. min() b. max() c. optmin() d. pmin

8. ______ evaluate the cumulative distribution function for a Normal distribution.

a. dnorm b. rnorm c. pnorm d. rpois

9. _______ generate random Poisson variates with a given rate.

a. dnorm b. rnorm c. pnorm d. rpois


10. Which of the following evaluate the Normal probability density (with a given
mean/SD) at a point?

a. rnorm b. dnorm c.rpois d.pnorm

11. _________ is the most common probability distribution to work with.

a.Parametric b. Gaussian c. Simulation d. Paradox

12. Which one is not a function of stastical distribution?

a. dbinom() b. pchisq() c. pbinom() d.gnorm()

13. Which function is used to sort an element in a vector?

a. order() b. sort() c. asc() d. des()

14. Which one will not performlinear algebraic operations on a given matrix?

a. Rank b. Transpose c. inverse d. reverse

15. The cumulative distribution function F(x) is a ……… function of X.

a.increasing b. non-increasing c. non-decreasing d. decreasing

16. The Relation between Variance and Standard deviation is_______?

a. var=S.D2 b. var-S.D=0 c. var=S.D d. var-S.D

17. Which law is used over set operations?


a. partition law b.cartesian product
c. De Morgan’s law d.mutally exclusive

18. _______function input a script and runs a script in the current session?
a. in() b. sink() c.append() d. source()

19. ______ function defines the direction of terminal output?


a. sink() b. source() c. dev.off( ) d. append()

20. Which of the following argument denotes if the file has a header line?
a. header b. sep c. file d. footer
PART – B(Short Answer Questions)

1. Differentiate between Solve () and Sweep () function.


2. Define Calculus in R.
3. Write syntax of rewinding a fine.
4. What is meant by cat () function?
5. What is use of print () function?
6. Mention the use of scan () function.
7. What are the four types of Math functions available in R?
8. Differentiate between readline () and readlines () function.
9. What are the different types of writing data to a file available in R?
10. Compare readlines () and read.table () function.
11. Define Sorting.
12. What is rank () function?
13. How to used order () function in R?
14. Explain which.min () and which.max () function.
15. Explain crossprod () function.

PART – C

1. Write R-Code Cumulative Sums and Cumulative Products.


2. Explain Calculating a Probability implementation in detail.
3. Explain different types of Math functions in R.
4. Explain Finding Stationary Distribution of Markov Chains Implementation using R.
5. Describe the Sorting functions with suitable examples in R.
6. Write short notes on Minima and Maxima in R.
7. Explain Vector Cross Product Implementation using R.
8. Write short notes on Accessing the Keyboard in R.
9. How many ways are there to read and write files?
10. Explain an extended example of Connections.
11. How to read data from the Keyboard?

12. Explain how to write files?


PART – D

1. What are the different forms of doing Math and Simulation in R. List the different
types of Math with suitable examples in for each?
2. Explain Functions for Statistical Distribution in R.
3. Describe Linear Algebra Operation on Vectors and Matrices with suitable examples
in R.
4. Explain in detail about Set Operations with suitable examples in R.
5. Briefly Discuss about Accessing the Keyboard and Monitor with examples in R.
6. Mention how you can read and writing files with suitable examples in R.
Unit-IV
Part-A (MCQ questions)

1. The most convenient way to use R is at a graphics workstation running a _____


system?

a. Widowing b. Running c. Interfacing d. Matrix

2. Which facilities provide basic building blocks that can be used to build up graphs step
by step?
a. low-level graphics facilities b. high-level graphics facilities
c. calling functions d. sequence of functions

3. Which level of graphical facilities variety of pre-assembled graphical displays?

a. Graphics window b. calling functions


c. low-level graphics facilities d. high-level graphics facilities

4. Which level plotting commands generate figures?

a. Low b. High c. Both high and low d. No levels

5. Which function call is used to create the new graphics window?

a. plot.new() b. axis(1) c. axis(2) d. Box()

6. Which function call sets the limits for the x and y coordinates in the graph?

a. abline() b. plot.new() c. plot.window() d. title()

7. Which data structure is used to plot x-axis and y-axis in plot() function?

a. Matrix b. List c. Frame d. Vector

8. Which one is the workhorse or generic function for most of the graphical operations?

a. abline() b. plot() c. points() d. text()

9. Which one are the correct parameters to use with plot function?

a. plot(v, type, col,main,xlab,ylab) b. plot(v, type, row,main,xlab,ylab)

c. plot(v, type, col,main,xmin,ylab) d. plot(v, type, col,main,ymin,ylab)


10. Which function can be used to add a set of points to a plot?

a. segments b. points() c. abline() d. polygon()

11. Which one are the correct arguments of segment () function?

a. segments(x0, y0, x1, y1) b. segments(x0, y1)

c. segments(y0, y1) d. segments(x1, y1, x0, y0)

12. Which function is used to draws text strings into a plot?

a. legend() b. axis.text() c. text() d. drawplot()

13. Which function is used to draw line graphs using vectors over plotted window?

a. lines() b. plot.new() c. axis() d.drawbox()

14. _______ Arguments is used to produce line plot?

a. plot(x, y, type="0") b. plot(x, y, type="1")


c. plot(x, y, col="1") d. plot(x, y, row="1")

15. Which arguments is used to produced empty plots with a call to plot () function?

a. plot(x, y, type="n") b. plot(x, y, type="b")


c. plot(x, y, type="c") d. plot(x, y, type="r")

16. Which function allows expanding or shrinking characters within a graph?

a. expand() b.cex() c. shrink() d. curve()

17. Which function is used to graph between equations?

a.lowess () b. curve() c.points() d.sex

18. _________ functionis function is used to draw arbitrary polygonal objects.

a. Polygon() b. plot() c. seq() d. curve()

19. Which one is correct syntax to save saving graph as a pdfobject?

a. ping(pdf-path) b. jpeg(pdf-path) c. pdf(pdf-path) d.dataframe()


20. Which icon is used exported plotted graph to our own device if you are using the R
studio editor?

a. “Export” b. save as c. share d. des()

PART – B (Short Answer Questions)

1. Write about Lines () function.


2. Write about Polygon () function.
3. Define Graphics.
4. Define Plot () function.
5. What is x11() function?
6. Write R Script to create a Line Graph.
7. What are all arguments used in Plot () function?
8. Write a syntax in barplot () function.
9. Write a syntax in boxplot () function.
10. Give the syntax for creating Scatter Plot matrices.
11. Define Rainbow () function.
12. What is heat.colors () function?
13. Write cm.colors () function in R.
14. Define Histogram () function.
15. Write a syntax in Pie Chart () function.
16. What is cex () function?
17. Compare text () and legend () function.
18. What is meant by point () function?
19. How to use xlim and ylim options in plot () function?
20. Which function is used to create a boxplot graph in R?
PART – C

1. Write about Scatter Plot and Histograms with examples? Explain its importance.
2. How to Plot multiple curves in same graph? Explain with examples.
3. Differentiate between Barplot () and Boxplot () function.
4. Explain Histogram () function in R with suitable examples.
5. Write short notes on Strip-Chart () function in R.
6. Explain Pie-Chart () function in R with suitable examples.
7. Explain in Bar-Plot () function in R.
8. Discuss in Box-Plot () function in w with suitable examples.
9. How to save a graph in R?
10. How to specifying through the Hexa-Decimal Values in R.
11. Explain in detail about Color Palette with suitable examples in R.
12. What is Box Plot? Explain importance of boxplot with example.

PART – D

1. Elaborate the following R Objects: a) Points () b) Legend () C) Text () d) Locator ()


2. Identify the different ways to access R base graphics. List the different types of Plots
function in R with suitable examples.
3. Explain in detail about Saving Graphs to Files with suitable examples in R.
4. Explain R – Colors in detail.
5. Elaborate the following R objects: a) Bar-Plot () b) Box-Plot () c) Pie-Chart ()
d) Strip-Chart ().
6. Describe Customizing graphs with suitable examples in R.
7. Explain R Graphics Devices.
Unit-V
PART-A (MCQ)
1. Which of the following are types of correlation?
a. Positive and Negative b. simple, partial and multiple
c. Linear and non-linear d. All the above

2. The values of the coefficient of the correlation ‘r’ lies between _________.

a. 0 and 1 b. -1 and 0 c. -1 and +1 d. – 0.5 and + 0.5

3. It calculates the relationship between two variables and how one would change in
response to changes in the other ?

a. correlation b. covariance c. comparison d. causality

4. How much variance is explained by a correlation of 0.9?

a. 81% b. 18% c. 9% d. 99%

5. The correlation coefficient is used to determine:

a. A specific value of the y-variable given a specific value of the x-variable ()


b. A specific value of the x-variable given a specific value of the y-variable
c. The strength of the relationship between the x and y variables
d. None of these

6. If there is a very strong correlation between two variables then the correlation
coefficient must be:

a. any value larger than 1


b. much smaller than 0, if the correlation is negative
c. much larger than 0, regardless of whether the correlation is negative or positive
d. None of these alternatives is correct

7. Which of the following statements is true for correlation analysis?

a. It is a bivariate analysis b. Univariate analysis


c. Multivariate analysis d. Both a and c
8. Which of the following statements is true about the arithmetic mean of two regression
coefficients?

a. It is less than the correlation coefficient.


b. It is equal to the correlation coefficient.
c. It is greater than or equal to the correlation coefficient.
d. It is greater than the correlation coefficient.

9. ______ is used to view all packages installedin R programming.

a. library() b.search() c. .libPaths() d. stringr()

10. Which package is used to create lattice graphs?


a. ggplot2 package b. lattice package
c.splot d. SplitReg
11. _______ type of lattice graph that shows the hierarchical structure of a dataset.

a. strip plot b. dendrogram c. Density plot d. Barchart

12. Which function used to create heat maps from lattice package?

a. xyplot() b. levelplot() c. bwplot() d. wireframe()

13. ______ function used to create scatterplots, boxplots, and 3D surface plots
respectively.

a. geom_raster() b. levelplot() c. xyplot() d. wireframe()

14. _____ is a type of lattice graph that is used to display the values of afunction of two
variables over a rectangular region.

a. bwplot() b. levelplot() c. “mosaic” d. geom_raster()

15. What is ggplot2 an implementation of?

a.The Grammar of Graphics developed by Leland Wilkinson


b. curve()
c.The S language originally developed by Bell Labs
d.The base plotting system in R
16. What is a geom in the ggplot2 system?

a. Plotting object like point, line, or other shape


b. Method for making conditioning plots
c. Method for mapping data to attributes like color and size
d. Statistical transformation

17. Which of the following is used to find variance of all values?

a. var() b. sd() c. mean() d.anova()

18. Goodness of Fit of a distribution is tested by?

a. T - test b. chi - square test c. F - test d. Q - test

19. In conducting one way analysis of variance, which of the following test statistics would
be used ?
a. Z b. T c. X2 d.F

20. Which of the following best describes the purpose of using ANOVA in research?

a. ANOVA is used to compare the means of two groups


b. ANOVA is used to compare the means of more than two groups
c. ANOVA is used to determine the correlation between two variables
d. ANOVA is used to determine the interaction effect between dependent
variables
PART – B (Short Answer Questions)

1. Define Statistics.
2. Define Normal Distribution.
3. What is meant by Linear Regression?
4. How R is used in Linear Models?
5. X is the Vector C (5, 9.2, 3, 8.5,1, NA), what is the output of mean(X)?
6. Define ANOVA.
7. What are R Spines?
8. Write about Decision in R.
9. How to used Covariance in R?
10. Write about Logistic Regression in R.
11. Define Multiple Regressions.
12. Explain dnorm () function.
13. Write about Binomial Distribution.
14. Write about Poisson distribution.
15. What is the Probability Distribution in R?
16. How R is used in Logistic Regression?

PART – C

1. Mention how you can produce Correlations and Covariance in R.


2. Explain about Logistic Regression in R.
3. How do you get the Standard Deviation for a Vector x?
4. Explain Binomial Distribution in R.
5. Describe Simple Linear Regression in R.
6. How R is used Poisson Regression with suitable examples.
7. Explain Survival Analysis in R.
8. Explain Normal Distribution in R.
9. Write short notes on Non-Linear Models in R.
10. Explain Poisson distribution in R.
11. Find median and mode of following numbers: 12,13,11,0,9,11,7,11,10,15,16,11.
12. What is Linear Regression in R Programming Language?
PART – D

1. Elaborate the following R Objects: a) Mean b) Median C) Mode d) Variance e)


Standard Deviation
2. Calculate the Coefficient of Correlation to the following data:
X 10 12 18 24 23 27
Y 13 18 12 25 30 10
3. Explain in detail about other distributions in R.
4. Discuss about Multiple Regression Generalized Linear Models with suitable examples
in R.
5. Explain how to other generalized Linear Models in R.
6. Calculate the Measuring the Central Tendency to the following data:
3,3,5,6,7,7,8,1,1,1,4,5,6.
7. Compute the Correlation Coefficient for the following data:
X 68 64 75 50 64 80 75 40 55 64
Y 62 58 68 45 81 60 68 48 58 70
8. Find Covariance for following data set: x= {2,5,6,8,9} and y= {4,3,7,5,6}.
9. Using the Covariance formula, find covariance for the following data set: x=
{5,6,8,11,4,6} and y= {1,4,3,7,9,12}.

You might also like