I have a df as below
df <- data.frame(col = c("Acer laurinum", "Acer laurinum"),
author = c("", "Hassk."),
value = c(1,1))
df
col author value1 value2
1 Acer laurinum 1 2
2 Acer laurinum Hassk. 1 3
3 Acronychia pedunculata (L.) Miq. 0 1
4 Acronychia pedunculata 0 0
I would like to update the author column saying that if I found any duplicated rows in col column, then the blank cell of author associated with the value (i.e. Acer laurinum) will be updated to Hassk. And the value must be retained.
- Desired output
col author value1 value2
1 Acer laurinum Hassk. 1 2
2 Acer laurinum Hassk. 1 3
3 Acronychia pedunculata (L.) Miq. 0 1
4 Acronychia pedunculata (L.) Miq. 0 0
Any suggestions for this?