[R] using tabble

Jim Lemon jim at bitwrit.com.au
Mon Jan 18 10:46:24 CET 2010


On 01/18/2010 08:17 PM, 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

Mozart, Mozart, what are we to do?

Mozartdat<-c(rep(1,12),rep(2,3),rep(3,45),rep(6,5),rep(7,7))
Mozart.table<-tabulate(Mozartdat)
names(Mozart.table)<-1:7
Mozart.table

Jim



More information about the R-help mailing list