0% found this document useful (0 votes)
62 views4 pages

R Programming Imp Questions Unit 1 & 2

Uploaded by

Amruta Sawakar
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)
62 views4 pages

R Programming Imp Questions Unit 1 & 2

Uploaded by

Amruta Sawakar
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/ 4

R Programming

Important questions of Unit 1 & 2


Two marks Questions
1. Define R programming.
2. Write the Statement to declare a numeric variable and print the value of the variable.
3. List the Arithmetic Operators in R.
4. List the Assignment Operators in R.
5. Define Vector.
6. Write the statement to create an array.
7. Write the statement to create a Matrix .
8. Write the statement to create a List.
9. What is the difference between List and Vector in R?
10. What is the difference between Matrix and Vector in R?
11. List the data structure in R.
12. Create a Simple matrix with 3x3 size in R.
13. What is a data frame?
14. What is the purpose of R?
15. What are the features of R?
16. List the Operators in R.
17. Define Arrays.
18. Define List.
19. What is Class ?
20. What is the difference between List and Matrix in R ?
21. Write about vectors in R .
22. Write about type conversions in R?
23. Explain the importance of dataframe?
24. Write about complex objects in R.
25. Write syntax of if else in R.
26. Explain different matrix operation functions in R?
27. Write about Boolean operators in R.
28. Write the Advantages of R Programming language.
29. How will you merge two data frames in the R programming language?
30. What is the difference between a data frame and a matrix in R?
31. Write the Disadvantages of R Programming language.
32. Differentiate between lapply and sapply.
33. Explain about classes.
34. Define binary search tree .
35. Discuss about variables in R.
36. Give an example for returning complex objects.
37. Explain about apply() and sapply() functions.
38. Explain about apply() and tapply() functions.
39. Define Quick sort.
40. Give an example for lapply ( ) function.
41. Give an example for sapply ( ) function.
42. Give an example for tapply( ) function.
43. Give an example for apply() function .
44. What is a reference class?
45. Write syntax of for loop in R.
46. Differentiate between try ( ) and trycatch( ) statements.
47. Write syntax of While loop in R.
48. What is Plotting?
49. List the looping statements in R.
50. Define Function in R programming.
51. Write syntax of if statement in R.
52. Write syntax of repeat loop in R.
53. What is Recursion in R.
54. Two vectors X and Y are defined as follows – X <- c(3, 2, 4) and Y <- c(1, 2). What will be output of
vector Z that is defined as Z <- X*Y.
Ans: In R language when the vectors have different lengths, the multiplication begins with the
smaller vector and continues till all the elements in the larger vector have been multiplied.
The output of the above code will be –
Z <- (3, 4, 4)
55. Explain about looping over non vector sets.
Long questions for 5 m or 6 m or 7m or 10 marks .
1. Explain different data structures in R.
2. Implement a binary search tree with R .
3. Explain different types of operators in R.
4. Write about control statements in R
5. Write about scatter plots and histograms with examples? Explain its importance?
6. Write about a data frame? Write about operations on a data frame.
7. Write about the apply method in R? write about lapply, sapply, tapply with suitable examples?
8. Explain about default values and in return statements in functions? Write syntax and examples?
9. Write a R program to implement quicksort.
10. What is Box plot? Explain the importance of boxplot with examples?
11. Explain about Variables,constants and Data Types in R Programming.
12. How to create, name ,access , merging and manipulate and removing elements from list ? Explain
with examples.
13. Write about Arithmetic and Boolean operators in R programming?
14. What is Recursion? Write an R program to find the Factorial of a given number using recursion .
15. What is a vector? How to create it? Create a vector A of elements 5, 2, -2, 6,7, 10,12,14,15 and from
it create a vector Y containing elements of A>6
Ans: A<-c(5, 2, -2, 6,7,10,12,14,15) # Create a vector
Y<-A[A>6]
Print ( Y)
Output : [1] 7 10 12 14 15
16 . Explain if-else statements with examples.
17. Discuss about return values in R.
18. What is R programming? How to run R?
19. Discuss in detail about matrices in R with examples.
20. What are various data types used in R? Explain in detail with examples.
21. How does R programming manage without pointers? Explain with examples.
Ans: R does not allow usage of pointers as a result of which sometimes you may face restrictions in
changing the values directly.
This can make programming more difficult in some cases. The fundamental thought is to create a class
constructor and have every instantiation of the class be its own environment. One can then pass the
object/condition into a function and it will be passed by reference instead of by value, because unlike other
R objects, environments are not copied when passed to functions. Changes to the object in the function will
change the object in the calling frame. In this way, one can operate on the object and change internal
elements without having to create a copy of the object when the function is called, nor pass the entire object
back from the function. For large objects, this saves memory and time.
Flower <- c("rose","lily","Tulips","lotus")
sort(flower)
o/p: [1] "lily" "lotus" "rose" "Tulips"
flower[1]
## [1] "rose"
Here, the function to sort could not change the flower object. If we want to change x, then we should
reassign it.
flower<-sort(flower)
print(flower)
## [1] "lily" "lotus" "rose" "Tulips"
If a function has several outputs then a solution is to gather them together into a list, call the function with
this list as an argument, have the function return the list, and then reassign to the original list. An example is
the following function, which determines the indices of odd and even numbers in a vector of integers:
y<-function(v){
odd<-which(v%%2==1)
even<-which(v%%2==0)
list(o=odd,e=even)
}
y(c(2,34,1,5))
$o
[1]34
$e
[1]12
22. Discuss about loops in R programming with examples.
23. Describe the following statement: “Functions are objects”
24. What is recursion? Explain recursion concept with example.
25. What is a list? Explain the concept of lists in R with examples.
26. Explain looping over non vector sets with examples.
27. Explain the concept of data frames with examples.
28. What is a reference class? Explain with examples.
29. Explain the different types of array in R programming.
30. Differentiate between R and C programming.
31. How to create, Accessing matrix elements, modify, and deleting rows and columns .
32. Write down the steps used to install R in windows.
33. Write about the advantages and disadvantages of R.
34. Create a 3- dimensional array in R.
35. Explain Classes in R with suitable examples
36. Differentiate between try( ) and trycatch( ) statements.
37.Explain the different types of plotting.
38. Differentiate between single and multidimensional arrays with examples for each.
39. Differentiate between while loop and repeat loop .
40. Explain break and next statement in R with an examples for each.
41. Differentiate between bar and histogram plotting .
42. Explain about handling errors in R programming .
43. Write an R program illustrate with for loop and stop on condition, to print the error message.
44. Explain about the Special values in R.
45. What is Coercion? Explain the concept of Coercion (type casting ) in R.

You might also like