Having this kind of data (see below), I try to create a new column IRISCOM based on a conditional test with mutate().
COMMUNE|IRIS|NB
35360|353600101|45
35361|ZZZZZZ|72
I have tried with data=mutate(data, IRISCOM= ifelse(IRIS == "ZZZZZZZZZ", COMMUNE, IRIS))
It writes correctly COMMUNE but does write 1 in place of IRIS code as expected.
I've tried some more experimentations with no success.
IRISis afactor; the numeric value corresponding to factor level353600101is1. - Maurits Evers