I have the following dataframe -
ID Name Distance Time Base Height
1 A 10 2 12 2
2 A 20 4 14 3
3 B 30 6 16 4
4 B 40 8 18 5
5 C 50 10 20 6
6 C 60 12 22 8
I want to create new columns Speed, Tarea, Speed_ratio, Tarea_ratio whose values are derived from the values in rows with Names A,B,C as follows -
ID Name Distance Time Base Height Speed Tarea Speed_ratio Tarea_ratio
1 A 10 2 12 2 5 12 1 0.5714
2 A 20 4 14 3 5 21 NA NA
3 B 30 6 16 4 5 32 1 0.7111
4 B 40 8 18 5 5 45 NA NA
5 C 50 10 20 6 5 60 1 0.6818
6 C 60 12 22 8 5 88 NA NA
Can this be done? Thanks.