Help adding new column by indexing

#1
I have a dataset that looks something like this

structure(list(Red = c(65.76, 57.07, 32.93, 43.78, 189.55, 115.87,
72.96, 51.84, 52.39, 59.03, 70.37, 83.95, 44.98, 47.38, 73.32,
108.53, 50.21, 54.44, 56.9, 53.06, 173.95, 153.75, 69.81, 27.01,
21.24), Green = c(15.22, 162.1, 65.84, 105.57, 11.62, 17.33,
148.83, 35.75, 124.44, 75.61, 15.84, 20.72, 115.34, 80.41, 23.89,
24.36, 134.22, 22, 27.04, 127.73, 17.45, 23.31, 15.83, 77.75,
82.83)), .Names = c("Red", "Green"), row.names = c(NA, 25L), class = "data.frame")
>

I would like to add a new column to this dataset called Cell Color.. So for example, any row that has a 'Green' value over 50 and a 'Red' value under 50 would be called 'Green'

anything that is over 50 for 'Red' and under 50 for 'Green' would be 'Red'

anything that is over 50 for both colors would be double labeled 'Double'

Thank you in advance!!
 
#2
I've named your dataframe as df. Then using the package dplyr you can do:

Code:
library(dplyr)
df.new <- df %>% 
            mutate(Color = case_when(.$Green > 50 & .$Red > 50 ~ "Double",
                                     .$Green > 50 & .$Red < 50 ~ "Green",
                                     .$Green < 50 & .$Red > 50 ~ "Red"))
Your new dataframe df.new should have the info needed.