Page 245 - Data Science class 11
P. 245
2. The modulus operator is represented by %. ____________
3. Variable names are not case-sensitive. ____________
4. is.numeric() is a function that is used to check whether a variable is numeric or not. ____________
5. We can add elements at any position in a list. ____________
Standard Questions (Section B)
A. Short answer type questions:
1. Write a note on data frames.
Ans. A data frame is a table or a two-dimensional array-like structure in which each column contains values of one variable
and each row contains one set of values from each column.
In R, the data.frame() is used to create a data frame.
2. Explain the parameter dim of array() function.
Ans. This parameter is used to give the dimensions of the array. Dimensions (3,4,2) will create two rectangular matrices each
with three rows and four columns.
3. Name the functions which is used to change the type of a variable to another type.
Ans. The functions that are used to change the type of a variable to another type are as follows: as.numeric() changes the
variable type to numeric variable, as.character() changes the variable type to character variable and as.logical() changes
the variable to logical or Boolean type.
Ex: x<-65
print(is.numeric(x))
TRUE
as.character(x)
print(x)
print(is.numeric(x))
FALSE
B. Long answer type questions:
1. What is matrix? Explain the syntax of creating a matrix.
Ans. Matrix are the R objects in which the elements are arranged in a two-dimensional rectangular layout. They contain
elements of the same atomic type. They are an extension of numeric or character vectors. Matrix elements must be of
the same data type. To create a matrix in R, matrix() function is used.
Syntax: matrix(data, nrow, ncol,byrow,dimnames)
data-the input vector which becomes the data elements of the matrix.
nrow-number of rows to be created.
ncol-number of columns to be created.
byrow-represents a logical clue. When it is set to True, then the elements in the input
vector are organised by row.
dimnames-is the names assigned to the rows and columns.
Programming with R 243

