[R] Make a blank dataframe with given dimensions

Richard M. Heiberger rmh at temple.edu
Thu Oct 8 01:02:59 CEST 2009

 > tmp <- data.frame(matrix(nrow=0, ncol=32))
 > tmp
 [1] X1  X2  X3  X4  X5  X6  X7  X8  X9  X10 X11 X12 X13 X14 X15 X16 X17 
X18 X19
[20] X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 X32
<0 rows> (or 0-length row.names)
 > names(tmp) <- c(letters, LETTERS[1:6])
 > tmp
 [1] a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F
<0 rows> (or 0-length row.names)

More information about the R-help mailing list