My data looks like this:
library(tidyverse)
df <- tibble(
x_val = c(10.3, 14.3, 18.7)
)
After passing each x_val
to my_fun
...
my_fun <- function(x) {
x * pi
}
df %>% rowwise() %>% mutate(y_val = my_fun(x_val))
...I get the following:
# A tibble: 3 × 2
x_val y_val
<dbl> <dbl>
1 10.3 32.35840
2 14.3 44.92477
3 18.7 58.74778
How might I reverse the function (without just dividing by pi! because my actual function is a lot more complex) to find the appropriate value of x_val
to get y_val
that is the nearest integer - 0.01
.. to achieve x.99
:
32.99
44.99
58.99