[R] create a data frame with the given column names
Peter Ehlers
ehlers at ucalgary.ca
Thu Feb 17 11:00:30 CET 2011
On 2011-02-16 13:29, Sam Steingold wrote:
> how do I create a data frame with the given column names
> _NOT KNOWN IN ADVANCE_?
> i.e., I have a vector of strings for names and I want to get an _EMPTY_
> data frame with these column names.
> is it at all possible?
>
It's not really clear to me what you want to do.
If you want to create a zero-rows dataframe (why?),
here's one way:
nm <- letters[11:14]
d <- as.data.frame(
matrix(nrow = 0, ncol = 4,
dimnames = list(NULL, nm)))
Peter Ehlers
More information about the R-help
mailing list