I want to recreate in R the following table :

I have been provided with only these three parameters:
initial_deposit = 15000
contract_value = 250
closing_stock_indices = c(1000, 1002, 994, 998, 997)
My effort in R is this:
cl =c(1000,1002,994,998,997) # The closing stock indices.
re = c(0,diff(cl))
t = time(cl)
mtm = re*250 # The contract value of 250.
mb = 15000+mtm # The initial deposit of 15000.
vm = ifelse(mb>0,0,mtm)
d = data.frame(t,cl,re,mtm,mb,vm);d
but I cannot do the last two columns.Any help ?