You can use the apply function along with a custom function to replace the last non-NA entry in each row. Here's an example:
main.r761 chars34 lines
This code defines a custom function replace_last_non_na that takes a row and a new value as input, finds the last non-NA entry in the row, and replaces it with the new value. The apply function is then used to apply this custom function to each row of the dataframe, replacing the last non-NA entry with the value from the new_col column.
Note that this code uses the dplyr library for data manipulation and assumes that the dataframe has a column named new_col containing the values to replace the last non-NA entry with.
gistlibby LogSnag