I have the following dataframe
structure(list(D_STA_F = c(NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_), ZFM_aux = c("S", "S", "S", "S", "S"), NFONTE201602 = c(1,
1, NA, 1, NA), NFONTE201603 = c(1, NA, NA, 1, NA)), row.names = c(NA,
-5L), class = c("tbl_df", "tbl", "data.frame"))
And I only want to replace NA with zeros in variables with name including NFONTE (not D_STA_F).
Here
my_data <- mutate_at(my_data, c("C1", "C4"), ~replace(., is.na(.), 0))
instead of "C1", "C4" how can I define the variable that include NFONTE in the name?
Or can I use if statement ou any loop?