Question 1: What is R Programming?
- R Programming language was created by Ross Ihaka and Robert Gentleman, at the University of Auckland.
- R Programming language is generally used for developing statistical analysis, graphics representation, and reporting.
- Now, R is developed by the R Development Core Team.
Question 2: What are the different data objects in R?
- vectors
- lists
- arrays
- matrices
- data frames
- tables
Question 3: What makes a variable name valid in R?
- Variable name starts with an alphabet letter
- Variable consisting of number, dot, and underscore
Question 4: What is the main difference between an array and a matrix?
| Matrix | Array |
| Matrix can be only two dimensional | Array can be multi-dimensional |
| Matrix has rows and columns | Array can be represented by multiple matrices |
Question 5: Which data object in R is used to store and process categorical data?
Question 6: How can you load and use CSV files in R?
Question 7: How do you get the name of the current working directory in R?
Question 8: What is the R Base package?
- R Base package basically provides input/output functionality and arithmetic calculation functionality.
- R Base package is automatically installed at the time of the R Programming Environment setup.
Question 9: How is R used in logistic regression?
Question 10: How do you access the element in the 3rd column and 1st row of a matrix named M?
Example
- M = matrix( c('a','a','b','c','b','a'), nrow = 2, ncol = 3, byrow = TRUE)
- print(M[1,3])

Question 11: What is the recycling of elements in a vector? Give an example.
- v1 <- c(4,1,0,6)
- v2 <- c(2,4)
- print(v1*v2)

Question 12: What are different ways to call a function in R?
- Calling a function with argument values (by position and by name)
- # Create a function with arguments.
- new.fun <- function(x,y,z) {
- res <- x * y + z
- print(res)
- }
- # Call the function by the position of arguments.
- new.fun(5,3,11)
- # Call the function by names of the arguments.
- new.fun(x = 11, y = 5, z = 3)

- Calling a function with default argument
- # Create a function with arguments.
- new.fun <- function(a = 10, b = 20) {
- res <- a * b
- print(res)
- }
- # Call the function without giving any argument.
- new.fun()
- # Call the function by giving new values of the argument.
- new.fun(9,5)

- Calling a function without an argument
- # Create a function without an argument.
- new.fun <- function() {
- for(j in 1:5) {
- print(j^2)
- }
- }
- # Call the function without supplying an argument.
- new.fun()

Question 13: What is a lazy function evaluation in R?
Example
- # Create a function with arguments.
- new.fun <- function(x, y) {
- print(x^2)
- print(x)
- print(y)
- }
- # Evaluate the function without supplying one of the arguments.
- new.fun(20)

Question 14: How do you install a package in R?
- install.packages("package Name")
Question 15: Name an R package that is used to read XML files?
Example
- # Load the package required to read XML files.
- library("XML")
- # Also load the other required package.
- library("methods")
- # Give the input file name to the function.
- res <- xmlParse(file = "input.xml")
- # Print the result.
- print(res)






Hadshana KamalanathanPosted Jul 22, 2018, 3:57 AM
Useful one
Ajay MalikPosted Jul 28, 2016, 7:40 AM
Thanks @mahesh chand sir..
Mahesh ChandPosted Jul 28, 2016, 7:36 AM
Nice Ajay. Good to see questions on R, one of the most demanding languages for data analysts.
Shobana JPosted Jul 28, 2016, 7:08 AM
Nice share
Vignesh ManiPosted Jul 28, 2016, 6:40 AM
Thanks for sharing
Ajay MalikPosted Jul 28, 2016, 12:45 AM
Tq
Prasanna MuraliPosted Jul 27, 2016, 9:34 PM
Nice share