I was looking for some way to change class of variables in one data frame by using the reference of another data frame which has information of class for each variable. 

I have a data which contains around 150 variables. All the variables are in character format. Now I want to change the class of each variable depending upon its type. For this we created a separate data frame having information of class for each of the variables. Let me explain with an sample data frame.

Consider my original data frame to be df with 5 variables -

```
df <- data.frame(A="a",B="1",C="111111",D="d",E="e")

```

Now we have another data frame "variable\_info" which contains just 2 variables, one "variable\_name" and another "variable\_class".

```
variable_info <- data.frame(variable_name=c("A","B","C","D","E"),variable_class=c("character","integer","numeric","character","character"))

```

Now using the variable\_info data frame I want to change the class for each of the variables in df so that their class is as specified in "variable\_info$variable\_class" linking the variable name with "variable\_info$variable\_name"

How can we do this for a data frame? Will it be good to do this in data.table? How can we do this in data.table?

Thank you!!

Prasad