Revisiting this post. Can we condition the command to say,
go through first two columns in each of the three files and if it matches (assuming the files are not in the same order) or even present in a single file (out of three), print the average of the 8th columns in the first file ?
Hi,
I have a space delimited text file that looks like the following:
Aa 100 200
Bb 300 100
Cc X 500
Dd 600 X
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... (11 Replies)
Hi, I need help with the awk command.
I have a folder with aprox 500 files each one with two columns and I want to print in a new file, the average of column 1 and average of column 2 and the name of each file.
Input files are:
File-1:
100 99
20 99
50 99
50 99
File-2:
200 85... (3 Replies)
I have a dataset with 120 columns. I would like to write a script, that takes the average of every two columns, starting from columns 2 and 3, and moving consecutively in frames of 3 columns, all the way until the last column.
The first column in the output file would be the averages of columns... (1 Reply)
Hi experts,
I want to group by average, for multiple columns starting column $7 until NF,
group by ($1-$5), please help
For just 7th column, I can do
awk '
NR>1{
arr += $7
count += 1
}
END{
for (a in arr) {
print a, arr/count
... (10 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)
I have the following format of input from multiple files
File 1
24.01 -81.01 1.0
24.02 -81.02 5.0
24.03 -81.03 0.0
File 2
24.01 -81.01 2.0
24.02 -81.02 -5.0
24.03 -81.03 10.0
I need to scan through the files and when the first 2 columns match I... (18 Replies)
Hi Friends,
I have files with columns like this. This sample input below is partial.
Please check below for main file link. Each file will have only two rows.
... (8 Replies)
Hi forum members,
I'm trying to get an average of multiple columns in a csv file using awk. A small example of my input data is as follows:
cu,u3o8,au,ag
-9,20,-9,3.6
0.005,30,-9,-9
0.005,50,10,3.44
0.021,-9,8,3.35
The following code seems to do most of what I want
gawk -F","... (6 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 DEBIAN
minmax
MINMAX(l) MINMAX(l)
NAME
minmax - Find extreme values in data tables
SYNOPSIS
minmax [ files] [ -C ] [ -D ] [ -H[nrec] ] [ -Idx[/dy] ] [ -L ] [ -M[flag] ] [ -: ] [ -bi[s][n] ]
DESCRIPTION
minmax reads its standard input [or from files] and finds the extreme values in each of the columns. It recognizes NaNs and will print
warnings if the number of columns vary from record to record. As an option, minmax will find the extent of the first two columns rounded
up and down to the nearest multiple of dx/dy. This output will be in the form -Rw/e/s/n which can be used directly in the command line for
other programs, or simply in column form.
xyzfile
ASCII [or binary, see -b] file(s) holding a fixed number of data columns.
OPTIONS -C Report the min/max values per column in separate columns [Default uses <min/max> format]
-D Sets longitude discontinuity to the Dateline (-180/+180) [Default is Greenwich (0-360)]. Requires -L.
-H Input file(s) has Header record(s). Number of header records can be changed by editing your .gmtdefaults file. If used, GMT default
is 1 header record.
-I Report the min/max of the first two columns to the nearest multiple of dx and dy, and output this in the form -Rw/e/s/n (unless -C
is set).
-L Indicates that the x column contains longitudes, which may be periodic in 360 degrees [Default assumes no periodicity].
-M Multiple segment file(s). Segments are separated by a special record. For ASCII files the first character must be flag [Default is
'>']. For binary files all fields must be NaN.
-: Toggles between (longitude,latitude) and (latitude,longitude) input/output. [Default is (longitude,latitude)]. Applies to geo-
graphic coordinates only. Only works when -I is selected.
-bi Selects binary input. Append s for single precision [Default is double]. Append n for the number of columns in the binary file(s).
[Default is 2 input columns].
EXAMPLES
To find the extreme values in the file ship_gravity.xygd, try
minmax ship_gravity.xygd
Output should look like
ship_gravity.xygd: N = 6992 <326.125/334.684> <-28.0711/-8.6837> <-47.7/177.6> <0.6/3544.9>
To find the extreme values in the file track.xy to the nearest 5 units and use this region to draw a line using psxy, try
psxy `minmax -I5 track.xy` track.xy -Jx1 -B5 -P > track.ps
To find the min and max values for each column, but rounded to integers, try
minmax junkfile -C -I1
SEE ALSO gmt(1gmt)
1 Jan 2004 MINMAX(l)