Taking the average of two columns and printing it on a new column
Hi,
I have a space delimited text file that looks like the following:
Basically, I want to take the average of columns 2 and 3 and print it in column 4. However if there is an X in either column 2 or 3, I want to print the non-X value. Therefore the output will look like this:
Hi,
I have 20 files which have respective 50 lines with different values.
I would like to process each line of the 50 lines in these 20 files one at a time and do an average of 3rd field ($3) of these 20 files. This will be output to an output file.
Instead of using join to generate whole... (8 Replies)
Dear Gurus,
I am very new to UNIX. I appreciate your help to manage my files.
I have 16 files with equal number of columns in it. Each file has 9 columns separated by space. I need to compare the values in the second column of first file and obtain the corresponding value in the 9th column... (12 Replies)
Hey all, I am relatively poor at programming and unfortunately don't have time to read about programming at this current moment.
I wanted to be able to run a simple command to read a column of numbers in a file and give me the average of those numbers. In addition if I could specify the... (2 Replies)
Hi,
I would like to calculate the average of column 'y' based on the value of column 'pos'.
For example, here is file1
id pos y c
11 1 220 aa
11 4333 207 f
11 5333 112 ee
11 11116 305 e
11 11117 310 r
11 22228 781 gg
11 ... (2 Replies)
Hi all,
I think so I’m getting the result is wrong, while using following awk commend,
colval=$(awk 'FNR>1 && NR==FNR{a=$4;next;} FNR>1 {a+=$4; print $2"\t"a/3}'
filename_f.tsv filename_f2.tsv filename_f3.tsv)
echo $colval >> Result.tsv
it’s doing the condition 2 times, first result... (5 Replies)
Hi,
My input file
Gene1 1
Gene1 2
Gene1 3
Gene1 0
Gene2 0
Gene2 0
Gene2 4
Gene2 8
Gene3 9
Gene3 9
Gene4 0
Condition:
If the first column matches, then look in the second column. If there is a value of zero in the second column, then don't consider that record while averaging.
... (5 Replies)
I have the need to match the first two columns and when they match, calculate the percent of average for the third columns. The following awk script does not give me the expected results.
awk 'NR==FNR {T=$3; next} $1,$2 in T {P=T/$3*100; printf "%s %s %.0f\n", $1, $2, (P>=0)?P:-P}' diff.file... (1 Reply)
Hello Members,
Need your expert opinion how to tackle below.
I have an input file that looks like below:
USS|AWCC|AFGAW|93|70
USSAA|Roshan TDCA|AFGTD|93|72,79
ALB|Vodafone|ALBVF|355|69
ALGEE|Wataniya (Nedjma)|DZAWT|213|50,550
I like output file in below format:
... (7 Replies)
I have files that have the following columns
chr pos ref alt sample 1 sample 2 sample 3
chr2 179644035 G A 1,107 0,1 58,67
chr7 151945167 G T 142,101 100,200 500,700
chr13 31789169 CTT CT,C 6,37,8 0,0,0 15,46,89
chr22 ... (3 Replies)
Discussion started by: nans
3 Replies
LEARN ABOUT FREEBSD
ministat
MINISTAT(1) BSD General Commands Manual MINISTAT(1)NAME
ministat -- statistics utility
SYNOPSIS
ministat [-Ans] [-C column] [-c confidence_level] [-d delimiter] [-w [width]] [file ...]
DESCRIPTION
The ministat command calculates fundamental statistical properties of numeric data in the specified files or, if no file is specified, stan-
dard input.
The options are as follows:
-A Just report the statistics of the input and relative comparisons, suppress the ASCII-art plot.
-n Just report the raw statistics of the input, suppress the ASCII-art plot and the relative comparisons.
-s Print the average/median/stddev bars on separate lines in the ASCII-art plot, to avoid overlap.
-C column Specify which column of data to use. By default the first column in the input file(s) are used.
-c confidence_level
Specify desired confidence level for Student's T analysis. Possible values are 80, 90, 95, 98, 99 and 99.5 %
-d delimiter
Specifies the column delimiter characters, default is SPACE and TAB. See strtok(3) for details.
-w width Width of ASCII-art plot in characters, default is 74.
A sample output could look like this:
$ ministat -s -w 60 iguana chameleon
x iguana
+ chameleon
+------------------------------------------------------------+
|x * x * + + x +|
| |________M______A_______________| |
| |________________M__A___________________| |
+------------------------------------------------------------+
N Min Max Median Avg Stddev
x 7 50 750 200 300 238.04761
+ 5 150 930 500 540 299.08193
No difference proven at 95.0% confidence
If ministat tells you, as in the example above, that there is no difference proven at 95% confidence, the two data sets you gave it are for
all statistical purposes identical.
You have the option of lowering your standards by specifying a lower confidence level:
$ ministat -s -w 60 -c 80 iguana chameleon
x iguana
+ chameleon
+------------------------------------------------------------+
|x * x * + + x +|
| |________M______A_______________| |
| |________________M__A___________________| |
+------------------------------------------------------------+
N Min Max Median Avg Stddev
x 7 50 750 200 300 238.04761
+ 5 150 930 500 540 299.08193
Difference at 80.0% confidence
240 +/- 212.215
80% +/- 70.7384%
(Student's t, pooled s = 264.159)
But a lower standard does not make your data any better, and the example is only included here to show the format of the output when a sta-
tistical difference is proven according to Student's T method.
SEE ALSO
Any mathematics text on basic statistics, for instances Larry Gonicks excellent "Cartoon Guide to Statistics" which supplied the above exam-
ple.
HISTORY
The ministat command was written by Poul-Henning Kamp out of frustration over all the bogus benchmark claims made by people with no under-
standing of the importance of uncertainty and statistics.
From FreeBSD 5.2 it has lived in the source tree as a developer tool, graduating to the installed system from FreeBSD 8.0.
BSD November 10, 2012 BSD