r - Use data from dataframe Y to rename columns in data frame X with dplyr? -


I have dataframe w and looks something like this:

  y = data.fr (Names = as.factor (c ("name1", "name2"), other = c (1,2))   

and a dataframe X that looks something like this:

  x = data. Frames (col1 = c (1,0,1,1), col2 = c (0,0,0,1), col3 = c (0,0,0, 1))   

I want to rename X's column.

  X = data.frame (name1 = c (1,0,1, 1), name 2 = c (0,0,0,1), col3 = c (0,0,0,1))   

I tried the following, but this work Does not

  the library Rename (dplyr) X = X%>% (As Cheture (Y $ name [[1]] = col1)   

Thanks for the help!

Try this:

  colnames (X) & lt; -Y $ names    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -