salary <- c(5000, 3000, 2000, 1000, 5000)
currency <- c('USD', 'EUR', 'JPY', 'CHF', 'CAD')
df <- data.frame(salary, currency)
I want to convert all the salaries to USD, so if I want to convert the 3000 to USD I will multiply 3000 by 1.12. It worked with a for loop and if statement, but I wonder if there's a faster and shorter way.
df$USD_salary = df$salary * df$convert