r - Convert column name to var name -


i have 2 data frames (df1 & df2). 1 data frame has 1 column 1000 rows, , second data frame has 1000 columns. want make df1 column 1 row content var name df2. default names there df1/2 v1, v2....

here examples:

df1 v1 b c d  df2 v1   v2  v3 a1   b1  c1 a2   b2  c2 a3   b3  c3 

final output should this

df3   b   c a1  b1  c1 a2  b2  c2 a3  b3  c3  names(df3) "a" "b" "c" 

set names() of df2 vector of df1:

df3 <- df2 names(df3) <- df1$v1 

assumes rows of df1 , columns of df2 same length.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -