Tuesday, December 19, 2017

How do I access individual table cells in a table.read() in R?

Once you have read data into R using table.read() as described here, you can also access each of the cells in the 9 element grid of the 3 columns X 3 rows by providing row and column numbers.

You defined the table as shown here:



You can access row1, column 1 using this code:
-----------
> df[1, "Col1"]
[1] A
-----------
Using code similar to the above you can access each element providing row number and column number as shown.

df[1, Col1]   df[1, "Col2"]   df[1, "Col3"]
df[2, Col1]   df[2, "Col2"]   df[2, "Col3"]
df[3, Col1]   df[3, "Col2"]   df[3, "Col3"]

No comments: