I have data that belongs in a data frame, I want to change N/A values in "col1" where "col2" has text. Any "col1" N/A values which have text in "col2" I would like to change the "col1" value to "<1 Year":
Data:
col1 | col2
<1 YEAR | abcdefg
1 YEAR | xyz
N/A | abcde
N/A | abc
N/A |
This is the code I have tried for the first part:
df = mutate(df, col1 = ifelse(is.na(col1) && nchar(col2)>1,"lol",col1))