Hi Dimitri, Thanks for help, i knew that way that you have suggested but in fact my case is a little bit complicated than this, therefore, i am writing a better explanation now, my model is trying to see the effect of eco-innovative industries on total output, thats why i am trying to estimate by-industry regression: the model is lnQ~lnC+lnM+lnL+lnE+eco_inno+inno+(sum)ind_3d capital,material expendtrs, #labor, energy expendtrs, eco-innovation expenditures and innovation expenditures and i have in my disposal the 3-digit industry codes where total number of them are 99 ( not all of them belong to the same industry) so in order to be able to do by-industry regression i need to create 3-digit dummies for every different industry group for example for the 1st group, from 111 to 119 this will be the 1st model to estimate then from 131 to 139#another model then from 141 to 149#another model so on so forth... so at the end my aim is to compare the effect of eco-innovations on for these industry groups. so if i apply the way you have suggested it will take into account all the 3-digit industries which is not i want. in fact i know that people create this kind of dummies by using loop since there are many dummies to create, but i dont know how to do it. i hope i could be more explicit now, and you could help me more at this time. Thank you for your help in advance -------------------------- Serdal, I think what David is saying: just take those 2 variables you have and specify them as factors. Assuming your data frame is called "MyData": MyData$Ind_1<-as.factor(MyData$Ind_1) MyData$Ind_2<-as.factor(MyData$Ind_2) This way R will know they are not numeric variables but categorical variables. Then, when you do analyses using those variables, R will treat them as such and will build dummies "automatically" (e.g., if you use regression, etc.). Actually - it'd be nice to know what you are building your dummies for. Dimitri On Fri, Apr 23, 2010 at 11:34 AM, David Winsemius <dwinsem...@comcast.net> wrote: > > On Apr 23, 2010, at 11:26 AM, serdal ozusaglam wrote: > >> >> Dear R users, >> >> I have a simple question (probably) but i couldnt how to find a solution >> for that. >> >> i am using 2 digit industry codes and 3 digit industry codes for my model, >> and i need to create dummies for the industries. The case is simple for the >> 2-digit industries since there are not that mcuh of them, so i am creating >> my dummies as following >> ind_2da<-(ind_2d==11)#for the 11th industry >> ind_2dc<-(ind_2d==12)#for the 12th industry and so on so forth ... then i >> directly put the dummy into the regression which works well. >> >> but creating dummies for the 3-digit is rather complicated since there are >> alot of sub-industries, for example:111,112,113...119 and this is just for >> the 11th industry >> so when i consider the codes continues till 40, it would be exhausting to >> do it by hand. >> >> so i was looking for the loop commands to do it faster but since i am a >> newbie i got lost in it. >> >> so is there some one who can help me for this problem? > > Don't use dummies. > > ?factor > >> > -- > > David Winsemius, MD > West Hartford, CT _________________________________________________________________ Yeni Windows 7: Size en uygun bilgisayarı bulun. Daha fazla bilgi edinin. http://windows.microsoft.com/shop [[alternative HTML version deleted]]
______________________________________________ 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.