Let say I have a database (dat) including ID variable and two quantitative continuous variables on several times (peso1_v00 - baseline, peso1_v66 - 6 months / cintura1_v00 - baseline, cintura1_v66 - 6 months)
I want to create another variable based on the values of weight and waist circumference. If the measurement at 6 months has reduced in x % the category is y if .....
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usadola condici�n tiene longitud > 1 y s�lo el primer elemento ser� usadola condici�n tiene longitud > 1 y s�lo el primer elemento ser� usadola condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
I am not sure what I am doing wrong but it is not working
You can read further here
I couldn't test it since I don't know what your data looks like, but if it doesn't work and you need further help, please post a sample of your data.
Use dput(head(your_data)) and paste it in your reply in code format.
A bunch of nested ifelse() statements could work as well as it is vectorized, but the code would be harder to read, so yes, case_when() is the best choice in your case.