On 2009.04.18 13:52:35, Serguei Kaniovski wrote: > Bernardo: this is not quite what I am looking for, > > Let the data be: > y,i,j > 1,AUT,BEL > 2,AUT,GER > 3,BEL,GER > > then the dummies sould look like: > > y,i,j,d_AUT,d_BEL,d_GER > 1,AUT,BEL,1,1,0 > 2,AUT,GER,1,0,1 > 3,BEL,GER,0,1,1 > > I can generate the above dummies but can this design be imputed in a > reg. model directly? > > Serguei
Hello Serguei, I am sure there is a better way to do this, but the following seems to work: # Create sample data.frame() i <- c("AUT", "AUT", "BEL") j <- c("BEL", "GER", "GER") df <- data.frame(i=i, j=j) # Create dummy vectors df$d.aut <- ifelse(df$i=="AUT"|df$j=="AUT", 1, 0) df$d.bel <- ifelse(df$i=="BEL"|df$j=="BEL", 1, 0) df$d.ger <- ifelse(df$i=="GER"|df$j=="GER", 1, 0) # Print results df HTH, ~Jason -- Jason W. Morgan Graduate Student, Political Science *The Ohio State University* ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.