0

I am trying to replace the NA value in one row and column with a value in the same column but based on the conditional value in another column. However, I also need to maintain the 567 value for column Value_1. I don't think my code would be helpful in this instance. The data looks like:

Group_Name     Value_1     Status
    A            NA          NA
    A           12345      Active
    A           567          NA
   

The end result should be something like:

Group_Name       Value_1       Status
    A             12345          NA
    A             12345          Active
    A              567           NA

Any solution with tidyverse, data.table, or base R would be greatly appreciated

Henrik
  • 65,555
  • 14
  • 143
  • 159
emp88
  • 31
  • 4
  • Try `library(dplyr); df1 %>% mutate(Value_1 = Value_1[Status %in% 'Active'], .by = Group_Name)` – akrun May 25 '23 at 10:30
  • @akrun I slightly misstated the problem. I also need to retain Value_1 despite the status given it is already present. Is there an additional conditional statement required? – emp88 May 26 '23 at 19:30

0 Answers0