-3

I have 4 data frame:

temp2011, temp2012, temp2013, temp2014

These dataframe have same column name. (date, temp, humid, rain) I want to extract a column like this:

temp2011$temp
temp2012$temp
temp2013$temp
temp2014$temp

It is very hassle, so I change the code like this:

col <- "temp"
temp2011$col
temp2012$col
temp2013$col
temp2014$col

but this is not work.

How can I do this problem.

Sonny
  • 2,943
  • 1
  • 7
  • 19
monsoon
  • 17
  • 6
  • It's a little unclear what you want to do. Do you just need to get a column from one data set? Changing `temp` to `col` has no effect in my opinion. Are these merged data sets? – NelsonGon May 01 '19 at 12:56

1 Answers1

2

Use [[]] instead of $ as temp2011[[col]]

Sonny
  • 2,943
  • 1
  • 7
  • 19