using tabble
On Mon, 2010-01-18 at 17:17 +0800, Fan Dan wrote:
Dear Helper: I am using R to finish a project which is near the dealine. Please help me !!!!! I need to construct a table. The name of the table is the sequence from 1 to 7 with some missing values arbitrarily. For example 1 to 7 1 2 3 6 7 12 3 45 5 7 I want to add the missing numbers of the title which should be seq(1,7) In this case, 4 and 5 and the corresponding data is 0 So after revised the table should be like 1 2 3 4 5 6 7 12 3 45 0 0 5 7 Please tell me how I really appreaciate your time and helpn Yours Wolfgang AMadeurs [[alternative HTML version deleted]]
______________________________________________ R-help at 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.
Hi! If i understood your problem is easy create a fake data for example: set.seed(123) x<-rep(sample(1:7,5),3) table(x) x 3 4 5 6 7 3 3 3 3 3 In this example the values "1" and "2" are missing Solution change your variable to factor and determine your leveal x.factor<-factor(x,levels=1:7) table(x.factor) x 1 2 3 4 5 6 7 0 0 3 3 3 3 3
Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil