Dear All,

This sounds simple but can't figure out a good way to do it.

Let's say that I have an empty data frame "df":

## creates the df
df = data.frame( id=1, data=2)

## empties the df, perhaps there is a more elegant way to create an empty
df?
df = df[-c(1),]

> df
[1] id   data
<0 rows> (or 0-length row.names)

Now, how can I add a third column name to that empty df?

Normally I would use df$new.col = 1

But here I can't use this because it's empty!

I tried df$new.col=NULL -- this doesn't give an error but doesn't add the
column.

Thanks for your help,

Emmanuel

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to