Hi, I have a dataset (728 obs) containing three variables code of a company, year and revenue. Some companies have a complete history of 5 years, others have not a complete history (for instance observations for three or four years).I would like to determine the companies with a complete history using a dummy variables.I have written the following program but there is somehting wrong because the dummy variable that I have create is always equal to zero.Can somebody help me?Thanks, gm
z<-read.table(file="c:/Rp/cddat.txt", sep="", header=T) attach(z) n<-length(z$cod) // number of obs dataset d1<-numeric(n) // dummy variable for (i in 5:n) { if (z$cod[i]==z$cod[i-4]) // cod is the code of a company { d1[i]<=1} else { d1[i]<=0} // d1=1 for a company with complete history, d1=0 if the history is not complete }d1 When I run the program d1 is always equal to zero. Why? Once I have create the dummy variable with subset I obtains the code of the companies with a complete history and finally with a merge I determine a panel of companies with a complete history.But how to determine correctly d1?My best regards, gm [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.