Sponsored Content
Top Forums UNIX for Dummies Questions & Answers average of a column in a table Post 302386194 by Scott on Monday 11th of January 2010 04:07:42 PM
Old 01-11-2010
Hi.

Yes. But some more information would be useful.

For example, to average the first column of a file:
Code:
awk '
 { TOTAL += $1 }
  END { print TOTAL / NR }
' input_file

but it doesn't account for headers, footers, etc...

Last edited by Scott; 01-11-2010 at 05:16 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

calculate average of column 2

Hi I have fakebook.csv as following: F1(current date) F2(popularity) F3(name of book) F4(release date of book) 2006-06-21,6860,"Harry Potter",2006-12-31 2006-06-22,,"Harry Potter",2006-12-31 2006-06-23,7120,"Harry Potter",2006-12-31 2006-06-24,,"Harry Potter",2006-12-31... (0 Replies)
Discussion started by: onthetopo
0 Replies

2. Shell Programming and Scripting

Construct 3 column table from one column list

Hi all! trying my best to parse a public site for information (ie fiscal year and turnover) about corporations. Doing this by having a file with business name and registration number (search key) the file bolag.txt currently looks like this Burgundy 556732-7217 AcademicSearch 556406-9879... (11 Replies)
Discussion started by: martindebruin
11 Replies

3. Shell Programming and Scripting

average each column in a file

Hi, I tried to do this in excel but there is a limit to how many rows it can handle. All I need to do is average each column in a file and get the final value. My file looks something like this (obviously a lot larger): Joe HHR + 1 2 3 4 5 6 7 8 Jor HHR - 1 2 3 4 5 6 7 8 the output... (1 Reply)
Discussion started by: kylle345
1 Replies

4. Shell Programming and Scripting

average of rows with same value in the first column

Dear All, I have this file tab delimited A 1 12 22 B 3 34 33 C 55 9 32 A 12 81 71 D 11 1 66 E 455 4 2 B 89 4 3 I would like to make the average every column where the first column is the same, for example, A 6,5 46,5 46,5 B 46,0 19,0 18,0 C 55,0 9,0 32,0 D 11,0 1,0 66,0... (8 Replies)
Discussion started by: paolo.kunder
8 Replies

5. Shell Programming and Scripting

Calculate the average of a column based on the value of another column

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)
Discussion started by: jackken007
2 Replies

6. Shell Programming and Scripting

Get column average using ID

I have a file that looks like this: id window BV 1 1 0.5 1 2 0.2 1 3 0.1 2 1 0.5 2 2 0.1 2 3 0.2 3 1 0.4 3 2 0.6 3 3 0.8 Using awk, how would I get the average BV for window 1? Output like this: window avgBV 1 0.47 2 0.23 (10 Replies)
Discussion started by: jwbucha
10 Replies

7. Shell Programming and Scripting

Check first column - average second column based on a condition

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)
Discussion started by: jacobs.smith
5 Replies

8. Shell Programming and Scripting

Split column data if the table has n number of column's

please write a shell script Table -------------------------- 1 2 3 a b c 3 4 5 c d e 7 8 9 f g h Output should be like this --------------- 1 2 3 3 4 5 7 8 9 a b c c d e f g h (1 Reply)
Discussion started by: Priti2277
1 Replies

9. Shell Programming and Scripting

Split column data if the table has n number of column's with some record

Split column data if the table has n number of column's with some record then how to split n number of colmn's line by line with records Table --------- Col1 col2 col3 col4 ....................col20 1 2 3 4 .................... 20 a b c d .................... v ... (11 Replies)
Discussion started by: Priti2277
11 Replies

10. Shell Programming and Scripting

Average each numeric column

Hi all, Does anyone know of an efficient unix script to average each numeric column of a multi-column tab delimited file (with header) with some character columns. Here is an example input file: CHR RS_ID ALLELE POP1 POP2 POP3 POP4 POP5 POP6 POP7 POP8... (7 Replies)
Discussion started by: Geneanalyst
7 Replies
MINTEGRATE(1)							   User Commands						     MINTEGRATE(1)

NAME
mintegrate - evaluate average/sum/integral/derivative of 1-d numerical data SYNOPSIS
mintegrate [OPTION]... [FILE] DESCRIPTION
mintegrate is a program to compute averages, sums, integrals or derivatives of numerical 1-d data in situations where ultimate numerical precision is not needed. OPTIONS
-a compute mean value (arithmetic average) and standard deviation -c compute integral on closed x-data interval; In case that dx is not specified by the '-d' flag, the data are supposed to be from an irregular x-grid, and dx is computed separately for every x-interval. The integral is computed by the trapezoidal rule. -d <float> compute integral on open x-data interval with the specified dx; Can be used also in combination with '-D' and '-c'. -D compute difference btw. numbers or derivative of the y-data; In the default scenario where x- and y-data column are same, the dif- ference btw. the current and the previous data value will be output. In this case when '-d' is defined as 0, the x-data value will be print out in front of the calculated difference. If x-and the y-column are different and if the x-data resolution is not defined or it is !=0, then the derivative of the y-data is calculated. When the x-data resolution is constant, specify it explicitly by '-d' to achieve a higher numerical precision by a 'leapfrog' algorithm. -x <int> x-data column (default is 1). If 0, the x-range is an index; -y <int> y-data column, where y=f(x) (default is 1) -r x_0:x_1 x-data range to consider -s print out accumulated y_i sums: x_i versus accumulated f(x_i); In the case of a closed integral you have to specify also the x-data resolution dx (see '-d' above). -S compute the accumulated y_i-sums and add it to the output -p <str> print format of the result ("%.10g" is default) -t <str> output text in front of the result (invalid with '-s' or '-S'); A blank can be printed by using a double underscore character '__'. -T run a self-test that the program is working correctly -V print version number --version output version and license message --help|-H display help -h display short help (options summary) If none of the options '-a', '-D', '-d', or '-c' is used, then the sum of the provided data will be computed. Empty lines or lines starting with '#' are skipped. This program is perfectly suitable as a basic tool for initial data analysis and will meet the expected accuracy of a numerical solution for the most demanding computer users and professionals. Yet be aware that, although the computations are carried with double floating pre- cision, the computational techniques used for evaluating an integral or a standard deviation are analytically low-order approximations, and thus not intended to be used for numerical computations in engineering or mathematical sciences for cases where an ultimate numerical pre- cision is a must. For deeper understanding of the topic see http://en.wikipedia.org/wiki/Numerical_analysis. COPYRIGHT
Copyright (C) 1997, 2001, 2006-2007, 2009, 2011-2012 Dimitar Ivanov License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. mintegrate 2.2.1 February 2012 MINTEGRATE(1)
All times are GMT -4. The time now is 04:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy