I'm new to R and struggling with the following combination of cumulative multiplication with the addition of extra constants. I'm looking to achieve the following in a dataframe:
Variable_X Variable_Y Variable_Z
X1 Y1 Y1*X1 = Z1
X2 Y2 (Z1+Y2)*X2 = Z2
X3 Y3 (Z2+Y3)*X3 = Z3
X4 Y4 (Z3+Y4)*X4 = Z4
Any help would be greatly appreciated.