0

I have the following question:

I have the following code that runs and works properly. In this code, I put a value from column3 into column1 under the condition that column2 is equal to x.

df1$column1[df1$column2=='x'] <- df1$column3[df1$column2=='x']

However, as I would like to have my R code run smoothly, I would like to do this in a pipeline (with dplyr as package).

Is this possible and if yes, how?

Thank you in advance!

SFKR
  • 13
  • 3
  • This comment is for clarification of the answer of this question: What I found is a properly working pipeline chunk is the following: `df1 <- df1 %>% mutate(column4 = column2=='x', column1 = ifelse(column4, 'x', 'not x')) %>% select(-column4)` – SFKR Sep 08 '22 at 09:38

0 Answers0