'How to make a list of variables the header for a data frame [R]

I have a data frame with no headers. It has 561 columns. It has the generic headers like so

V1 V2 ... V561

I also have a txt. file that has all of the variable names for that data frame. They are all in one column, like so:

1 tBodyAcc-mean()-X   
2 tBodyAcc-mean()-Y   
3 tBodyAcc-mean()-Z  
...  
561 angle(Z,gravityMean)

How would I go about reading that file in and putting all those variables as the column names for the original dataset?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source