Hi I've got a table (data1) and a numeric vector(quantile) and trying to append calculated columns using the existing data (data1) and the vector(quantile).
such that:
newcol_20% = col1 + col2 + 20%,
newcol_50% = col2 + col3 + 50%,
newcol_70% = col3 + col4 + 70%
data1 and quantile and the desired output (out) are as below
>data1
ID col1 col2 col3 col4
ABC124 10 15 6 15
ABC445 8 8 25 34
ABC550 10 15 5 12
---
ZZZ980 12 21 26 11
ZZZ999 22 19 11 8
> quantile
20% 50% 70%
10 21 35
> out
ID col1 col2 col3 col4 newcol_20% newcol_50% newcol_70%
ABC124 10 15 6 15 35 42 56
ABC445 8 8 25 34 26 54 94
ABC550 10 15 5 12 35 41 52
---
ZZZ980 12 21 26 11 43 68 72
ZZZ999 22 19 11 8 51 51 54
How could I perform above using base R? Any help, suggestions would be appreciated, thanks!