[R] How to create a data.frame "like" another, but longer?

Kaspar Pflugshaupt pflugshaupt at geobot.umnw.ethz.ch
Wed Dec 19 12:08:44 CET 2001


Hello,

does anyone know of a quick way to create a data frame "like" another, but
with more rows?

What I'd like to do is this:

if mydata is a data.frame like

a   b       c
1   TRUE    yes
2   FALSE   no
3   TRUE    yes

I'd like to get mydata2 with the same column names and column types, but
without the values and with more rows.

All I could think of was to manually do mydata2 <- maydata, then repeat
mydata2 <- rbind(mydata2, mydata2) until mydata2 is long enough, then cut to
desired length and overwrite with new data. Not exactly elegant...

Is there a R function or some handy trick to achieve this?


Cheers

Kaspar

-- 

Kaspar Pflugshaupt
Geobotanisches Institut
Zuerichbergstr. 38
CH-8044 Zuerich

Tel. ++41 1 632 43 19
Fax  ++41 1 632 12 15

mailto:pflugshaupt at geobot.umnw.ethz.ch
privat:pflugshaupt at mails.ch
http://www.geobot.umnw.ethz.ch

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list