Categories
status

functions depending on the data types in …

functions depending on the data types in R
[table id=1 /]

Categories
status

Differences in single argument subscript …

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.

> 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