Save comma separated value files, if file exists, backup original file.
Examples
f <- tempfile()
x <- data.frame(a = 1:10)
# File not exists, same as write file, returns normalized `f`
safe_write_csv(x, f)
#> [1] "/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/RtmpH77NPa/file1506221b4f01"
# Check whether file exists
file.exists(f)
#> [1] TRUE
# write again, and the old file will be copied
safe_write_csv(x, f)
#> [1] "/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/RtmpH77NPa/file1506221b4f01"