Hi everyone! I am having trouble with something I guess must be easy, but somehow is getting tricky
I post my idea I believe this is a matter of concept (if a some data is necessary I will provide it). I am trying to create a variable from one vector operating and raising a number to a negative vector
A25_3end <- A25_3end %>% mutate(RQ = 2^.$-ddct))
where ddct is numeric
What I am getting is the minus symbol is not working and e.g. 2^ -9.705333 = 0.001197853
instead I am getting 834.826932
Thanks in advance
your choice to use the dollar sign $ seems strange to me ...
Can you make a reprex ?
I think the issue is with your syntax. You can't just write -vec like its algebra, you have to write -1 * vec, as below:
dplyr::tibble(power = c(9.5, 9.6, 9.7)) |>
dplyr::mutate(out1 = 2 ^ power,
out2 = 2 ^ (-1 * power))
#> # A tibble: 3 × 3
#> power out1 out2
#> <dbl> <dbl> <dbl>
#> 1 9.5 724. 0.00138
#> 2 9.6 776. 0.00129
#> 3 9.7 832. 0.00120
Created on 2022-06-30 by the reprex package (v2.0.1)
I guess I was dragging a minus symbol or sthg because seems to be working. I must admit that I prefer the option
A25_3end <- A25_3end %>% mutate(RQ = 2^-ddct))
prefer the option, I'm sorry I dont understand what you mean by this?