I suggest writing a simple formula-copying macro into your spreadsheet. You'd need to call it test.xlsm
instead of test.xlsx
, of course. If your spreadsheet looked like this:

then your macro might look like this:
Option Explicit
Sub MyMacro()
Dim BottomRowOfData As Integer, BottomRowOfFormula As Integer, rowDiff As Integer
With ThisWorkbook.Worksheets("expenses")
BottomRowOfData = .Range("B1").End(xlDown).Row
BottomRowOfFormula = .Range("C1").End(xlDown).Row
rowDiff = BottomRowOfData - BottomRowOfFormula
If (rowDiff > 0) Then
.Range("C" & BottomRowOfFormula).Copy
Call .Range(.Range("C" & BottomRowOfFormula + 1), .Range("C" & BottomRowOfData)).PasteSpecial
End If
End With
' Save your work
ThisWorkbook.Save
End Sub
You can invoke VBA macros from R, as per my answer to this question on so. For completeness, here's the code from that question:
library(RDCOMClient)
# Open a specific workbook in Excel:
xlApp <- COMCreate("Excel.Application")
xlWbk <- xlApp$Workbooks()$Open("C:\\TEMP\\test.xlsm")
# this line of code is only necessary if you want to see your spreadsheet getting updated:
xlApp[['Visible']] <- TRUE
# Run the macro called "MyMacro":
xlApp$Run("MyMacro")
# Close the workbook and quit the app:
xlWbk$Close(FALSE)
xlApp$Quit()
# Release resources:
rm(xlWbk, xlApp)
gc()