maximusdooku
maximusdooku

Reputation: 5542

How can I concatenate data frames without losing brackets in column names?

I have two dataframes (df1 and df2) with these column names

 add (1 unit), add (2 unit), sub

second dataframe

 add1, sdd1h, Li2c

I combine these dataframes using

x <- data.frame(df1,df2)

But I am losing the names in df1, where it becomes add.1.unit in the new dataframe. How can I keep the column names as it is?

Note: I don't have to merge by row or anything. These are unrelated columns of same length that needs to be in the same dataframe

Upvotes: 1

Views: 343

Answers (1)

Kelli-Jean
Kelli-Jean

Reputation: 1447

Add check.names=FALSE when combining the data frames:

x <- data.frame(df1, df2, check.names=FALSE)

Upvotes: 4

Related Questions