How do you multiply a number by a percentage increase in R. E.g.
43424 increasing by 120% would be 43424 * 2 + 43424 * 0.2
I have increases by 200% + and decreases in percentage as well
How do you multiply a number by a percentage increase in R. E.g.
43424 increasing by 120% would be 43424 * 2 + 43424 * 0.2
I have increases by 200% + and decreases in percentage as well
The simple case:
increase <- 1.20
start_value <- 43424
inc_value <- start_value * (1 + increase)
If you don't want for some reason calculate the percentage, define a value without the %
-sign
percentage <- 120
increase <- percentage/100
start_value <- 43424
inc_value <- start_value * (1 + increase)
If you just have values with %
you could transform them into numerical values
percentage <- c("120 %", "-200%")
increase <- as.numeric(gsub("[[:space:]]*%", "", percentage))/100
start_value <- 43424
inc_value <- start_value * (1 + increase)
The regular expression uses removes all spaces and a following %
. Hope this solves your issue.