2
I started using R recently. I would like to subtract corresponding lines from a Dataframe:
The numbers in the ID column are fixed, but the data in the VALUE column is not. The idea would be to subtract the values linked to Ids 1 and 4, 2 and 5, 3 and 6 as shown in the table image. In this case, a table of N rows would result in a new column of N/2 rows.
If there’s any way to do it for Dplyr it would be fantastic.
Following are data that can be used to reproduce the problem.
set.seed(37)
dados <- tibble::tibble(id = 1:6, valor = rnorm(6, 100, 20))
Thank you
Fantastic. It worked fine. My DF has more than 20k lines. The proposed structure will help me fine tune other codes I have. Thank you so much for your help!
– Marcelo RP