0% found this document useful (0 votes)
8 views5 pages

Activity 4

The document contains 15 multiple choice questions about the R programming language. It tests knowledge of basic functions and syntax like reading data, accessing vectors, using loops and conditional statements. Overall it covers fundamental concepts in R like data structures, importing/exporting data, and basic programming constructs.

Uploaded by

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

Activity 4

The document contains 15 multiple choice questions about the R programming language. It tests knowledge of basic functions and syntax like reading data, accessing vectors, using loops and conditional statements. Overall it covers fundamental concepts in R like data structures, importing/exporting data, and basic programming constructs.

Uploaded by

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

Activity: 4.

Section: _____________k22 CA _______


Reg. No.: ____12223607______________
Roll. No.: _______65_______________
Name: _____M.H.D AL FAHIM M.K____

1. How many output will be there for this code-


v<-c("hello","world")
count<-2
while(count<=7){
print(v)
count=count+1
}
a) 5
b) 6
c) 7
d) 4
2. In R, what function is used to read data from a CSV file?
a.) read.csv()
b) read.csvfile()
c) load.csv()
d) import.csv()

3. What does the str() function do in R?

a) Computes the standard deviation of a numeric vector


b) Displays the structure of an R object
c) Converts a string to lowercase
d) Finds the length of a vector or data frame

4. Output of below code is


x<- LETTERS[1:10] the English alphabet.
for (i in x){
print(i)
}
a.)A to J
b.) a to k
c.) a to L
d.) none

5. In R, how would you access the third element of a vector


named my_vector?

my_vector(3)
b) my_vector[[3]]
c) my_vector[3]
d) my_vector$3

6. What does the paste() function in R do?

a) Combines two vectors element-wise


b) Concatenates strings together
c) Computes the pairwise sum of two vectors
d) Multiplies corresponding elements of two vectors

7. Which symbol is used for comments in R?

a) //
b) #
c) --
d) <!—

8. What does the mean() function in R do?

a) Computes the median of a vector


b) Finds the maximum value in a vector
c) Calculates the arithmetic mean of a vector
d) Determines the mode of a vector
9. What is the correct syntax to create a vector named "my_vector"
with elements 1, 2, 3, 4, and 5 in R?
a) my_vector <- [1, 2, 3, 4, 5]
b) my_vector <- (1, 2, 3, 4, 5)
c) my_vector <- c(1, 2, 3, 4, 5)
d) my_vector = {1, 2, 3, 4, 5}

10. Which function is used to check the structure of an R


object?
a) describe()
b) summary()
c) str()
d) inspect()

11. What does the read.csv() function do in R?


a) Reads data from a CSV file
b) Reads data from a text file
c) Reads data from a JSON file
d) Reads data from a database

12. In R, how would you define a matrix with 3 rows and 2


columns filled with numbers from 1 to 6?
a) matrix(1:6, nrow = 3, ncol = 2)
b) matrix(1:6, ncol = 3, nrow = 2)
c) matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2)
d) matrix(c(1, 2, 3, 4, 5, 6), ncol = 3, nrow = 2)

13. Which of the following statements is true about R


programming language?
a) R is a procedural programming language.
b) R is primarily used for web development.
c) R is an open-source language used for statistical computing
and graphics.
d) R cannot handle large datasets efficiently.

14. What will be the output of this code-


vect<-c(2,3,10,15,23,14,17,20)
ifelse(vect%%2==0,"even","odd")

a.)Odd
b.)Even
c.)"even" "odd" "even" "odd" "odd" "even" "odd"
d.)"even" "odd" "even" "odd" "odd" "even" "odd" “even”

15. With respect to in operator output of following code will


be-
y<-c("key", "hardwork", "success")
if("key" %in% y && "hardwork" %in% y){
print("True")
}else{
print("False")
}
a.)True
b.)False
c.)Error
d.)None of these

You might also like