Alex Alex - 3 years ago 193
R Question

R: How to add a column of labels to a data frame?

I want to add a column to a data frame that has a fix value, so I do :

lessthan7.labels [, 'interval']= c(rep( 'week', nrow(lessthan7)))

but then it creates two columns: "interval", "rep(\"week\", nrow(lessthan7))".

How to get rid of this extra column?

Answer Source

If you just want to assign a constant value to a new column in a data frame, you can just use the following list notation:

lessthan7$interval <- 'week'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download