Hello,
This is not directly related to any particular analysis. I have been doing my own analysis for rna seq data for the last one year, completely learning from here and there. Until now, I am confident and can do my own analysis. I always use Rstudio to write and run the scripts for my data analysis. But one thing I feel lacking is, not being able to make the r script automatized. Like, just to be able to run Rscript my_script.R
in bash to execute and get the results. For every data sets, I have to manually change i.e. some variable names, or change some simple data table subsetting parameters or change the figure output names or change the working directory path etc. Etc. I am kind of frustrated and it drives the motivation down that everytime I have to make a copy of my old script, manually change stuffs inside, then run it. Is this always the case everywhere? I am sure it's not! The place where I come from, there's nobody to help me or teach me effective R programming to make it really automatized. I would really appreciate if you can give me some tips and tricks or some resources online to follow through to make Automatized scripts that will run seamlessly.
In addition to the answer by Yean, you might consider looking into the optparse and argparse packages. These make handling command line arguments easier. I have a template R-script that uses optparse here: rscript-template gist
You can also add docopt to that list: https://github.com/docopt/docopt.R