Replace NA by other value in column_not working_is it because I have a tibble instead of df?

I am trying to replace NA values in one column by the values in another column (same row) and tried the following code but it is not working.

Code I tried from research online and answer in Posit community (Replace "NA" with values from another column):
DF <- DF %>% mutate(pm25 = ifelse(is.na(pm25), prop25, pm25))
My column names are different as my data set is different but I think I otherwise applied this code correctly.

When I print the result, the NA values are still there, so this code does not appear to work.

I am working with data in tydverse so I think I have a tibble rather than a dataframe. Is that why it i snot working? If so, what is the code to use that is equivalent but would work for a tibble? Or is my issue different? Thanks for any advice.

It looks like I found a solution from another source (R - Replace Column Value with Another Column - Spark By {Examples}):
mutate(depth2_cm = ifelse(depth2_cm == 'NA', depth1_cm, depth2_cm))
It works! Posting in case it is useful to someone.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.