What will be the output of the following R code? [code] > x <- matrix(1:6, 2, 3) > x[1, ] [/code]

Nguyễn Hào

New member
What will be the output of the following R code?
Code:
> x <- matrix(1:6, 2, 3)
> x[1, ]
A. 1 3 5
B. 2 3 5
C. 3 3 5
D. file
 
Answer: a
Explanation: Matrices can be subsetted in the usual way with (i,j) type indices where i is the row and j is the column numbers. If only row or only column number is specified, then the respective full row or column is printed.
 

Tìm kiếm

Back
Top