-3

I want to add a column to a data frame that has a fix value, so based on this solution 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?

Alex
  • 1,708
  • 5
  • 22
  • 41

1 Answers1

3

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'
Tim Biegeleisen
  • 451,927
  • 24
  • 239
  • 318