0

is there a way to extract column names from a df and convert into a vector? In fact, what I am trying to do is rbing two df's, the second has no names so returning a name matching error? Maybe there is an easier way to copy the df1 column names to df2 so rbind will work?

1 Answers1

0

In one line:

df3 <- rbind(df1, setNames(df2, names(df1)))
Mikael Jagan
  • 6,005
  • 1
  • 9
  • 28