Page 246 - Data Science class 11
P. 246
2. Explain variable assignment in R.
Ans. There are three methods of variable assignment. The three ways are: leftward, rightward and equal to operators of R.
Assignment using the equal to operator
X=65
Assignment using the leftward operator
X←65
Assignment using the rightward operator
65→X
3. What are the four main categories of operators for vectors in R programming language?
Ans. The four main categories of operators in R are as follows:
• Arithmetic operators:
• These operators are used to perform arithmetic operations on vectors. The operators are +, -, *, / ,%%, ^.
• Relational operators:
• These operators compare elements of one vector with the corresponding elements of the second vector. The
relational operator are: >, < , >=, <=, ==, !=
• Logical operators:
• These operators are applicable only to logical, numeric or complex type. The result of the comparison is a Boolean
value. The logical operators are: &, |, ! (all these three check individual elements of the vector) &&(only checks the
first element of both the vectors).
Unsolved Exercise
Objective Type Questions (Section A)
A. Tick ( ) the correct option.
1. How many types of R objects are present in the R data type?
a. 4 b. 5
c. 6 d. 7
2. The ______________________ in R is a vector.
a. Basic data structure b. Basic datatypes
c. Both a and b d. None of these
3. Vectors come in two parts: ______________________ and ______________________.
a. Atomic vectors and matrix b. Atomic vectors and array
c. Atomic vectors and list d. None of these
4. ______________________ and ______________________ are types of matrices functions?
a. Apply and supply b. Apply and lapply
c. Both a and b d. None of these
5. Which of the following finds the maximum value in the vector x, excluding missing values ______________________?
a. rm(x) b. all(x)
c. max(x, na.rm=TRUE) d. x%in%y
244 Touchpad Data Science-XI

