On Wed, 23 Feb 2000, Winson Taam wrote:
>
> This may sound simple but I can't find a good way to do it.
>
> tmp is a data.frame with elements
>
> a 1
> c 2
> b 5
> b 4
> a 4
> c 3
>
> I want to replicate each row 3 times. i.e.
>
nr <- nrow(tmp)
tmp[rep(1:nr, rep(3, nr)), , drop=FALSE]
Note that row names in data frames are supposed to be unique, and if
you want to replicate them, make them into another column first.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-----------------------------------------------------------------------
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
|