The Rookie
The Rookie

Reputation: 939

How do I append new functions and update existing functions in a .R file without duplicating

In my R project folder I have an R script where I create custom functions. I then use the dump() function to add those functions to a separate script. For example if I have 2 functions, here is the code I'll use to add them to a separate file called list_of_functions.R -

dump(c("function_1", "function_2"), 
    append = TRUE,
    file = "list_of_functions.R")

The issue I have is that when I create a new function, say function_3 or make edits to function_1 or function_2, when I run dump() again, it duplicates existing functions in list_of_functions.R. Is there away to append new functions and just update existing functions without duplicating them.

Upvotes: 0

Views: 35

Answers (1)

All Downhill From Here
All Downhill From Here

Reputation: 872

Setting the argument append = FALSE will overwrite the existing file, rather than append to it.

See code reference for a detailed explanation.

Upvotes: 1

Related Questions