## Averaging

# 1
11-09-2009
Averaging

Hello all,

I'm trying to perform an averaging procedure which selects a selection of rows, average the corresponding value, selects the next set of rows and average the corresponding values etc.

The data below illustrates what I want to do. Given two columns (day and value),
I want to perform an annual average. This means, average the first 365 rows, followed by the next 365 rows, and the next 365 rows.
i.e.
average line 1 to 365 (no. of lines = 365)
average line 366 to 730 (no. of lines = 365)
average line 731 to 1095 (no. of lines = 365)

But there is a problem. Every four years, the calendar has one additional day i.e. leap year. So instead of 365, we have 366. Eventually, the whole averaging pattern should look something like

average line 1 to 365 (no. of lines = 365)
average line 366 to 730 (no. of lines = 365)
average line 731 to 1095 (no. of lines = 365)
average line 1096 to 1461 (no. of lines = 366)
average line 1462 to 1827 (no. if lines = 365)
...

Any suggestions?

Thanks.

day value
1
2
3
...
365
1
2
3
...
365
1
2
3
...
366
1
2
3
365
# 2
11-11-2009
ok, you are explanations are clear.

Do total/366 only at every 4th time... What suggestion you want ?! or What is the doubt you have here ?
 thegeek View Public Profile for thegeek Find all posts by thegeek
# 3
11-12-2009
Hi i'm quite inexeperienced but my suggestion would be to use the modulus of 4 for your trigger to /366 instead of /365.

Hope this helps you out a bit
 skinnygav View Public Profile for skinnygav Find all posts by skinnygav

## Averaging 3 files with multiple rows

Hi, I am trying to average the values from 3 files with the same format. They are very large files so I will describe the file and show some it of. Basically the file has 83 columns (with nearly 7000 rows). The first three columns are the same for each file while the remaining 80 are values that...

## Averaging 3 files

Hi, I am trying to average the values from 3 files with the same format. They are very large files so I will describe the file and show some it of. Basically the file has 83 columns (with nearly 7000 rows). The first three columns are the same for each file while the remaining 80 are values...

## averaging columns

Hi, I have a file that has 201 columns (1 for the name of each row and the other 200 are values) I want to print the average for each column the file looks like this (as an example this only has 7 columns with values) 1 2 3 4 5 6 7 abr 5 6 7 1 2 4 5 hhr 2 1 3 4 ...

## Averaging help in awk

Hi all, I have a data file like below, where Time is in the second column DATE TIME FRAC_DAYS_SINCE_JAN1 2011-06-25 08:03:20.000 175.33564815 2011-06-25 08:03:25.000 175.33570602...

## Hourly averaging using Awk

Hey all, I have a set of 5-second data as shown below. I need to find an hourly average of this data. date co2 25/06/2011 08:04:00 8.30 25/06/2011 08:04:05 8.31 25/06/2011 08:04:10 8.32 25/06/2011 08:04:15 8.33 25/06/2011 08:04:20 ...

## Averaging the rows using 'awk'

Dear all, I have the data in the following format. I want to do average of each NR= 5 (rows) for all the 3 (\$1,\$2, \$3) columns and want to print average result in another file in the same format. I dont know how to write code for this in 'awk', can some one help me to write a code for this in...

## Averaging segments and including the name

Hello, I have a awk line that averages rows. So if my file looks like this: Jack 1 1 1 1 1 1 Joe 1 1 1 1 1 1 Jerry 0 0 0 0 0 0 John 1 1 1 0 0 0 The awk line below skips column 1 and then averaged the rows awk -F'\t' -v r=3...

## Averaging multiple columns

Hello, I am trying to average multiple columns simultaneously while skipping the first column. I am using this awk line to average one column awk '{sum+=\$3} END { print "Average = ",sum/NR}' But I want to be able to do it for multiple columns while skipping the first column. There...

## Averaging segments

Hi, I have a file that I want to average. So specifically I want to average every third column for each row. Here is an example of my file 2 2 2 3 3 3 1 1 1 5 5 5 Heres what I want it to look like after averaging every third column 2 3 1 5 thanks

## AWK - averaging \$3 by info in \$1

Hello, I have three columns of data of the format below: <name> <volume> <size> a 2 1.2 a 2 1.1 b 3 1.7 c 0.7 1.9 c 0.7 1.9 c 0.7 1.8 What I...