Hi Sorry for banal question How to create empty data frame with for example 30 variables without typying: data.frame(x=1,y=1....) Jarek
Try this: do.call(data.frame, as.list(paste("var", 1:30, sep="."))) On 07/02/2008, Jaros?aw Jasiewicz <jarekj at amu.edu.pl> wrote:> Hi > Sorry for banal question > How to create empty data frame with for example 30 variables without > typying: data.frame(x=1,y=1....) > Jarek > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
> data.frame(a = character(0), b = double(0))[1] a b <0 rows> (or 0-length row.names) On Feb 7, 2008 5:48 AM, Jaros?aw Jasiewicz <jarekj at amu.edu.pl> wrote:> Hi > Sorry for banal question > How to create empty data frame with for example 30 variables without > typying: data.frame(x=1,y=1....) > Jarek
Jaros?aw Jasiewicz wrote:> Hi > Sorry for banal question > How to create empty data frame with for example 30 variables without > typying: data.frame(x=1,y=1....) > Jarek > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Or: data.frame(sapply(1:30, function(x) data.frame(x))) cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +31302535773 Fax: +31302531145 http://intamap.geo.uu.nl/~paul