I have to data tables. Data table 1 has two variables and 561 observations while data table 2 has 563 variables and 10,000 observations. I'm trying to figure out how can I the observations of `code_name` variable from data table 1 to rename the variables in data table 2.

**What I have:**

Data table 1

```
code   code_name 
11      rasf
04      iadf
27      pqwr
09      pklf
86      irmw
30      pwql

```

Data table 2 

```
activity    subject     V1      V2      V3      V4    V5     V6 
   5            2       0.29    0.19    5.3     1.8    8.3   0.3
   9            7       0.11    0.10    7.8     2.0    0.5   0.9
   9            7       0.19    1.10    8.0     1.9    0.4   0.7

```

**What I need:**

```
activity    subject    rasf    iadf    pqwr    pklf   irmw  pwql 
   5            2       0.29    0.19    5.3     1.8    8.3   0.3
   9            7       0.11    0.10    7.8     2.0    0.5   0.9
   9            7       0.19    1.10    8.0     1.9    0.4   0.7

```

**What I did:**

```
#Extracts all rows and just column two from the data table 1

new_data_table1 <- data_table1[,2]

#Set names on data table 2 to build the final data

final_data <- setnames(data_table2, names(data_table2), c("activity", "subject", new_data_table1))

```

The problem with my code is that when I extract all rows from data table 1 it gives a long list, showing vectors for the structure and labels of the data. Because of that, when I run my code I get this table: 

```
activity   subject      243     244     245     246    247   248 
   5            2       0.29    0.19    5.3     1.8    8.3   0.3
   9            7       0.11    0.10    7.8     2.0    0.5   0.9
   9            7       0.19    1.10    8.0     1.9    0.4   0.7

```

The new names for the variables are numbers because they are the structures and not the labels.