I have this dataset, I want to add a new column for different ranges of number based on
day. The ranges of number I am interested on are stored in
ex <- data.frame('id'= seq(1:26), 'day'= c(105:115, 1:12,28:30), 'letter' = LETTERS[1:26], s = rep(1:26, each = 3, len = 26) ) v1 <- c(107,112,10) v2 <- c(109,115,28) word <- c("pen","desk","light")
The column I want to add is stored in
day 107:109 I want to add the word "pen", 112:115 "desk", and 10:28 "light". For the rest of the values that fall outside of these ranges, I want to use the word "undetermined".
I am aware of this post Adding Values to a New Column in a Dataframe by Index - General - RStudio Community, but not sure how to extend it to my case.
Thank you in advance!