0

Possible Duplicate:
Parsing command line arguments in R scripts

This is my first post in here, please be nice if I am asking some noob question or which has been already answered.

I have written a R script which takes a file as an input and calculates difference between consecutive data points of second column and plots histogram of the calculated difference points.

Everything is fine but I want that script to take input as a command line argument. I tried --args and --slave but it doesn't work ! How do I achieve it?? and also the script is very slow since I have written it using 2 for loops which takes like 10 mins to process 50k line file where as awk does this in like 30 secs. Any tricks to speed this up??

data looks like this:

CHROM   POS
chr01   925
chr01   929
chr01   981
chr01   1008
chr01   1012
chr01   1042
chr01   1065
chr01   1255
chr01   1260

Thank you.

Community
  • 1
  • 1
PoisonAlien
  • 431
  • 4
  • 13

1 Answers1

1

You can access the commandline arguments passed to R through the commandArgs() function. This returns a list that you can access in the usual way. See ?commandArgs for more details.

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204