-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") 
1

1 Answer 1

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) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.