Problems for the function: mutate | efelse

Hello

I want to use a conditional in a database.

I need to create a variable that specifies:
If the column "CANTIDAD_SUBITEM" = 0, that brings me values ​​from the column "CANTIDAD_ESTADISTICA", otherwise it stays with the values ​​of the column "CANTIDAD_SUBITEM"

I was using the following code but it doesn't work for me:

Base1 %>% mutate(Quantity = ifelse(CANTIDAD_SUBITEM = 0, SCANTIDAD_ESTADISTICA, CANTIDAD_SUBITEM))

The file is here: Base1.xlsx - Google Sheets

Replace = with ==

1 Like

Check the use of correct name in the columns and like said @ replace de =.
The data have CANTIDAD_ESTADISTICA, you type SCANTIDAD_ESTADISTICA

Base1 %>% mutate(Quantity = ifelse(CANTIDAD_SUBITEM == 0, CANTIDAD_ESTADISTICA, CANTIDAD_SUBITEM))
1 Like

thank you so much!! I was able to generate a column with the conditions

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.