Sorry for the wrong question framing. Iam a newbie,trying to learn R on my own.
I have a scenario like,
t1_df
id name address
1 x india
2 y usa
t2_df
id name address
3 a india
4 b usa
Now i tried to add extra column "msg" using data.frame i.e
t1_df <- data.frame(t1_df,msg)
t2_df <- data.frame(t2_df,msg)
t1_df
id name address msg
1 x india hi
2 y usa hello
t2_df
id name address msg
3 a india go
4 b usa bye
when i tried to do rbind it gives error as col names are not matching because both df's having different col names
When i tried to cbind on both df's into single dataframe is t, it included all the columns from both df's i.e
colnames(t)
id name address t1_msg id name address t2_msg
But i would like to get the dataframe as
id name address t1_msg t2_msg
1 x india hi NA
2 y usa hello NA
3 a india NA go
4 b usa NA bye
How can i get the output as i have mentioned above.
Please suggest me.
Thanks in Advance Mohan.V
rbindlistfromdata.tablei.e.rbindlist(list(t1_df, t2_df))- akrunt1_msgandt2_msgand usebind_rowsfromdplyri.e.names(t1_df)[4] <- "t1_msg"; names(t2_df)[4] <- "t2_msg"; bind_rows(t1_df, t2_df)- akrun