Starting with a basic .R file with only one line to be replaced:
some(code)
date.updated = as.Date('2020-01-01')
date.updated = as.Date('2020/01/01')
list.files()
On a shell (e.g., bash), one can use sed -i -E "..." file.R to change all matching lines in-place. This is analogous to sed -E "..." < file.R > newfile.R. (Some file-systems don't do well with -i, so you might need the second option anyway.)
Using that, I'll demonstrate without replacing the file, for expediency.
$ sed -E "s/^(date\.updated\s*=\s*as\.Date)\('[-0-9]{10}'\)\s*$/\1('2020-01-02')/g" 62537920.R
some(code)
date.updated = as.Date('2020-01-02')
date.updated = as.Date('2020/01/01')
list.files()
If you want it to be changed programmatically to today's date, you can use
$ sed -E "s/^(date\.updated\s*=\s*as\.Date)\('[-0-9]{10}'\)\s*$/\1('$(date +%Y-%m-%d)')/g" 62537920.R
some(code)
date.updated = as.Date('2020-06-23')
date.updated = as.Date('2020/01/01')
list.files()
(I included a second date.updated line purely to demonstrate the specificity of the pattern.)
R typically has access to sed (either natively on unix/macos or via Rtools on windows), though on Windows you might need to specify its full path. If you really want to do this from R, then you can use system, system2, or processx::run.
date.updatedsupposed to be today's date? If so, you could simply usedate.updated = Sys.date().date.updatedremain as a previous date.