How to access single elements in a table in R

后端 未结 3 619
梦谈多话
梦谈多话 2020-12-23 20:52

How do I grab elements from a table in R.

My Data looks like this:

         V1     V2
1      12.448 13.919
2      22.242  4.606
3           


        
3条回答
  •  有刺的猬
    2020-12-23 21:18

    Maybe not so perfect as above ones, but I guess this is what you were looking for.

    data[1:1,3:3]    #works with positive integers
    data[1:1, -3:-3] #does not work, gives the entire 1st row without the 3rd element
    data[i:i,j:j]    #given that i and j are positive integers
    

    Here indexing will work from 1, i.e,

    data[1:1,1:1]    #means the top-leftmost element
    

提交回复
热议问题