-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,914
  • 6
  • 26
  • 47

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
  • 502,043
  • 27
  • 286
  • 360