Thursday, January 13, 2011

Median of a column in a .tab file from command line

To find the median of a certain column from the command line, first put the path of the file into a
shell variable:


specify the column you want to use:


and then call the R interpreter from the command line to calculate the median of the wanted column:

MEDIAN=`echo "r=read.table('$PATH');cat(median(r[,$COLUMN]))" | R --slave`

No comments:

Post a Comment