search for: matb_want

Displaying 1 result from an estimated 1 matches for "matb_want".

Did you mean: matb_wanted
2009 Jun 20
1
how to apply the dummy coding rule in a dataframe with complete factor levels to another dataframe with incomplete factor levels?
...9;))) #dfB's factor variables have less number of levels #use model.matrix on dfA (matA<-model.matrix(~f1+f2,data=dfA)) #use model.matrix on dfB (matB<-model.matrix(~f1+f2,data=dfB)) #I actaully like to dummy code dfB using the dummy coding rule defined in model.matrix(~f1+f2,data=dfA)) #matB_wanted is below (matB_wanted<-rbind(c(1,0,0,0,0),c(1,1,0,1,0),c(1,1,0,1,0)) ) colnames(matB_wanted)<-colnames(matA) matB_wanted Can someone kindly show me how to get matB_wanted? Many thanks in advance! -Sean [[alternative HTML version deleted]]