- 1. [S] stacking data.frame (score: 1)
- Author: Winson Taam <taam@Oakland.edu>
- Date: Wed, 23 Feb 2000 10:57:15 -0500 (EST)
- 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. a 1 a 1 a 1 c 2 c 2 c 2 b 5 b 5 b 5 b
- /archives/html/s-news/2000-02/msg00220.html (7,755 bytes)
- 2. Re: [S] stacking data.frame (score: 1)
- Author: Prof Brian D Ripley <ripley@stats.ox.ac.uk>
- Date: Wed, 23 Feb 2000 16:04:16 +0000 (GMT)
- 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
- /archives/html/s-news/2000-02/msg00221.html (8,316 bytes)
- 3. Re: [S] stacking data.frame (score: 1)
- Author: Tim Hesterberg <THesterberg@statsci.com>
- Date: Sat, 26 Feb 2000 09:49:04 -0800 (PST)
- Equivalently (but simpler): tmp[rep(1:nr, each=3), , drop=FALSE] The drop=F part is necessary if tmp had a single column. Alternately, set the dup.row.names attribute to non-NULL, e.g. one of: attr(
- /archives/html/s-news/2000-02/msg00273.html (9,513 bytes)
This search system is powered by
Namazu