How can I read command line parameters from an R script?

Dirk’s answer here is everything you need. Here’s a minimal reproducible example. I made two files: exmpl.bat and exmpl.R. exmpl.bat: set R_Script=”C:\Program Files\R-3.0.2\bin\RScript.exe” %R_Script% exmpl.R 2010-01-28 example 100 > exmpl.batch 2>&1 Alternatively, using Rterm.exe: set R_TERM=”C:\Program Files\R-3.0.2\bin\i386\Rterm.exe” %R_TERM% –no-restore –no-save –args 2010-01-28 example 100 < exmpl.R > exmpl.batch 2>&1 exmpl.R: options(echo=TRUE) # if you want … Read more

What is a faster alternative to Python’s http.server (or SimpleHTTPServer)?

http-server for node.js is very convenient, and is a lot faster than Python’s SimpleHTTPServer. This is primarily because it uses asynchronous IO for concurrent handling of requests, instead of serialising requests. Installation Install node.js if you haven’t already. Then use the node package manager (npm) to install the package, using the -g option to install … Read more

How to use sed to replace only the first occurrence in a file?

A sed script that will only replace the first occurrence of “Apple” by “Banana” Example Input: Output: Apple Banana Apple Apple Orange Orange Apple Apple This is the simple script: Editor’s note: works with GNU sed only. sed ‘0,/Apple/{s/Apple/Banana/}’ input_filename The first two parameters 0 and /Apple/ are the range specifier. The s/Apple/Banana/ is what … Read more