R how to change dafaframe column name by using listname

Viewed 39

I have list y like below. I want to change the first column name of each data frame (rn) to the name of the data frame (SA, TA). So it will look like y1.

> y
$SA
          rn  X1   X2   X3  X4   X5  X6
1: timepoint   0 3.75 4.25 4.5 4.75   5
2:      plot 234  304  285 279  256 238

$TA
          rn  X7  X8   X9  X10  X11 X12
1: timepoint   0   5 4.25 3.75 4.75 4.5
2:      plot 208 299  272  261  254 218

> y1
$SA
          SA  X1   X2   X3  X4   X5  X6
1: timepoint   0 3.75 4.25 4.5 4.75   5
2:      plot 234  304  285 279  256 238

$TA
          TA  X7  X8   X9  X10  X11 X12
1: timepoint   0   5 4.25 3.75 4.75 4.5
2:      plot 208 299  272  261  254 218
1 Answers
Related