This is a slightly different formulation of your problem, but you  
might find it easier to work with:

Start by making a data frame):
        df=data.frame("Father"=c 
("Fred","Fred","Fred","Barney","Barney"),"Mother"=c 
("Mary","Mary","Mary","Liz","Liz"),"Child.Age"=c(4,7,9,3,5))

If you want to add a "wedding date" column to this data frame, then
df=data.frame(df,"WeddingDate"=c("December 12th, 1980","December  
12th, 1980","December 12th, 1980","March 3rd, 2003","March 3rd, 2003"))

If, for example, you wanted to delete row #4, this is what you could do:
df=data.frame(df[-4,])

Similarly for column #4:
df=data.frame(df[,-4])



Kyle H. Ambert
Graduate Student, Dept. Behavioral Neuroscience
Oregon Health & Science University
[EMAIL PROTECTED]





On Mar 26, 2007, at 8:24 AM, Schmitt, Corinna wrote:
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

______________________________________________
R-help@stat.math.ethz.ch 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.



        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to