Back to DrivenData | Blog

How to merge hhold_train and indiv_train datasets in r


#1

Hi All,

Anyone, please tell me how to merge hhold_train and indiv_train datasets in r.

Regards,
Kishore


#2

You can create new features from indiv_train and add to hhold_train.


#3

As Sagol mentioned, you can create features in hhold_train and merge with indiv_train dataset on ‘id’ column.


#4

@sagol thanks for reply.
then i need to build models for both datasets right, my assumption is correct @sagol, please tell me if i am wrong.


#5

When you add new features from indiv_train to hhold_train dataset you’ll get only one combined dataset for modelling.


#6

@sagol got it now, please have a look below r code and output image,
library(reshape2)
data_w<- dcast(a_indiv_train, id ~ HeUgMnzF,value.var=“iid”)

output:

is this correct way to do, please correct me if i am do any mistake