# Loops in R programming, [closed]

I want to update this Remaining column in this table below:

How do I do this in R programming?

I tried

while (n.Remaining>0)

{ n.remaining <- n.total-n.expense}

Desired Output:

in R you just need to do 10-cumsum(expense). This will give you the Remaining column
More complicated than a cumsum, but for loop could look something like:
for (j in 3:5){

If your answer needs to be strictly positive, think about including a while or if statement.