I have a data frame, (aka df), and I want to multiply the Column Price when the column meets a specific condition, such as
df$US=='non US'`.
Here is my code:
df$Price <- df$Price[df$US=='non US']*0.85
Running the code above causes this error:
Error in `$<-.data.frame`(`*tip*`, CompPrice, value = c(140, 114.117647058824, :
replacement has 142 rows, data has 400
I understand the reason the error occurs, however, I don't know how to modify just the rows that meet the condition.
Thanks in advance.