Differences in single argument subscript …


Kuchāman Differences in single argument subscripting in matrix and data frame.
Even though the two variables look similar, the results are different depending on the data type.
The single argument scripting of data frame returns a column, while matrix returns an element according to its position as matrix is a vector.

Meru > class(my2) [1] "data.frame" > my2 a1 b c a1.1 1 10 20 30 35 2 10 20 30 35 > my2[1] a1 1 10 2 10 > class(my2.matrix) [1] "matrix" > my2.matrix a1 b c a1.1 1 10 20 30 35 1 10 20 30 35 > my2.matrix[1] [1] 10


Leave a Reply

Your email address will not be published. Required fields are marked *