-1

I have a dataframe of linear regression results with 88 rows and 9 columns. Rows 1 to 44 are from unadjusted models and rows 45 to 88 are from adjusted models.

How can I add a new column called Model that takes character values of Model 1 for rows 1:44 and 'Model 2 for rows 45:88?

So far I have generated this column as follows but not sure how to edit the value to take 'Model 2for rows 45-88

results.all <- results.all %>% mutate(Model="Model 1")
aelhak
  • 441
  • 4
  • 14

1 Answers1

3

How about

results.all$Model <- c(rep("Model 1", 44), rep("Model 2", 44))

or (from the comments)

results.all$Model <- rep(c("Model 1", "Model 2"), each = 44)
duckmayr
  • 16,303
  • 3
  • 35
  • 53