Reputation: 5
Table1 <- read.csv("table1.csv", header = T, sep = ",")
Table2 <- read.csv("table2.csv", header = T, sep = ",")
Table3 <- read.csv("table3.csv", header = T, sep = ",")
Table4 <- read.csv("table4.csv", header = T, sep = ",")
tables <- c("Table1", "Table2", "Table3", "Table4")
tables
[1] "Table1" "Table2" "Table3" "Table4"
tables[2]
[1] "Table2"
Above are my codes. I wish to extract the data in "tables". For example, when I select tables[2], I wish to see the data in table2.csv instead of just the word "Table2". How do I do this? Can anyone please help? Thanks!
Upvotes: 0
Views: 38
Reputation: 102625
get(tables[2])
which fetches object Table2
from your global environment
tables
, i.e., tables <- list(Table1, Table2, Table3, Table4)
then you can call tables[[2]]
Upvotes: 0
Reputation: 4169
Make a list of your tables if you really want:
tables <- list(Table1, Table2, Table3, Table4)
E.g.
tables[[1]]
What you've done is make a vector of strings, where your strings are "Table1", "Table2" etc. rather than storing the table objects.
Upvotes: 1