[R] data-frame adding/deleting column
Schmitt, Corinna
Corinna.Schmitt at igb.fraunhofer.de
Mon Mar 26 17:24:57 CEST 2007
Hallo,
I have got an existing data frame and want to add a new column. The
existing data frame was created like this:
> df <- rbind( c("Fred", "Mary", 4), c("Fred", "Mary", 7),
+ c("Fred", "Mary", 9), c("Barney", "Liz", 3),
+ c("Barney", "Liz", 5) )
> df <- data.frame(df)
> colnames(df) <- c("Father", "Mother", "Child.Age")
> df
Father Mother Child.Age
1 Fred Mary 4
2 Fred Mary 7
3 Fred Mary 9
4 Barney Liz 3
5 Barney Liz 5
I want to add a column named weddingdate. How does this work and how can
I save the corresponding dates in the cells? (Fred-Mary: 12.12.1980,
Barney-Liz: 3.3.2003)
How can I delet a whole column or row if it is needed?
Thanks, Corinna
More information about the R-help
mailing list