Dear All,
Weeks ago, I asked the question on data manupilation as follows. Several
people helped me out by providing the same answer.
> My sincere thanks to Nick Ellis, Bill Dunlap and Samuel Buttrey!
>
> My original question:
> =======================
>
> > I'm trying to table one variable according to other two factor varaibles,
> > with missing values generated automatically.
> >
> > Say,
> >
> > x <- c(rep(1, 3), rep(2,3), rep(3,4))
> > y <- c(rep(1:3,3), 4)
> > z <- runif(10)
> > cbind(x, y, z)
> >
> > x y z
> > [1,] 1 1 0.75
> > [2,] 1 2 0.58
> > [3,] 1 3 0.85
> > [4,] 2 1 0.09
> > [5,] 2 2 0.77
> > [6,] 2 3 0.88
> > [7,] 3 1 0.48
> > [8,] 3 2 0.55
> > [9,] 3 3 0.70
> > [10,] 3 4 0.52
> >
> > And what I want is the following matrix of z itself ordered by x and y.
> >
> > (Y) 1 2 3 4
> > (X)
> > 1 .75 .58 .85 NA
> > 2 .09 .77 .88 NA
> > 3 .48 .55 .70 .52
> >
>
> Solution provided by people I mentioned above:
> ===============================================
>
> tapply(z,list(x,y),function(w)w)
And tapply did work fine at that time. However, this just occurred to me.
Everytime when I tried to use the function tapply, it kept getting dumped
with the following error message, even for exactly the same command line
which went through succesively in the previous time.
> tapply(z, list(x, y), c)
Error in call to split(): Argument number 2 in call not matched
Dumped
Any suggestion or treatment for this puzzle is greatly apprecaited.
Merry Christmas and Happy Millenium to all!
Xiaogang Su
****************************
Xiaogang Su
U.S. Mail: Division of Statistics
University of California, at Davis
One Shilds Avenue
Davis, CA 95616
E-mail: xgsu@wald.ucdavis.edu
Phone: (530) 752-6103 (Office)
Web Site: http://anson.ucdavis.edu/users/xgsu/
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|