Re: [R] Summary of data for each year

2013-02-01 Thread Felipe Carrillo
 Here is another option using plyr:
 
library(plyr)
creek - read.csv(creek.csv)
 library(ggplot2)
 creek[1:10,]
 colnames(creek) - c(date,flow)
 creek$date - as.Date(creek$date, %m/%d/%Y)
 
ddply(creek,year,summarise,MED=median(flow),MEAN=mean(flow),SD=sd(flow),MIN=min(flow))

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Pascal Oettli kri...@ymail.com
To: Janesh Devkota janesh.devk...@gmail.com 
Cc: r-help@r-project.org 
Sent: Thursday, January 31, 2013 11:52 PM
Subject: Re: [R] Summary of data for each year

Hello,

One possibility is:

 creek - read.csv(creek.csv)
 colnames(creek) - c(date,flow)
 creek$date - as.Date(creek$date, %m/%d/%Y)
 creek - within(creek, year - format(date, '%Y'))

 with(creek, aggregate(flow, by=list(year=year), summary))

HTH,
Pascal


Le 01/02/2013 16:32, Janesh Devkota a écrit :
 Hello All,

 I have a data with two columns. In one column it is date and in another
 column it is flow data.

 I was able to read the data as date and flow data. I used the following
 code:

 creek - read.csv(creek.csv)
 library(ggplot2)
 creek[1:10,]
 colnames(creek) - c(date,flow)
 creek$date - as.Date(creek$date, %m/%d/%Y)

 The link to my data is https://www.dropbox.com/s/eqpena3nk82x67e/creek.csv

 Now, I want to find the summary of each year. I want to especially know
 mean, median, maximum etc.

 Thanks.

 Janesh

     [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Summary of data for each year

2013-02-01 Thread arun


Hi,

You could use:
creek - read.csv(creek.csv,sep=\t)
 colnames(creek) - c(date,flow)
creek$date - as.Date(creek$date, %m/%d/%Y)
creek1 - within(creek, year - format(date, '%Y'))
library(data.table)
 creek2- data.table(creek1)
 
creek2[,list(MEAN=.Internal(mean(flow)),MEDIAN=median(flow),MAX=max(flow),MIN=min(flow)),by=list(year)]
  #  year  MEAN  MEDIAN    MAX    MIN
 #1: 1999 0.6365604 0.47695  7.256 0.3187
 #2: 2000 0.2819057 0.20810  2.380 0.1370
 #3: 2001 0.2950348 0.22260  2.922 0.1769
 #4: 2002 0.5345666 0.21190 14.390 0.1279
 #5: 2003 1.0351742 0.71730 10.150 0.3492
 #6: 2004 0.9691180 0.65240 11.710 0.4178
 #7: 2005 1.2338066 0.72790 17.720 0.4722
 #8: 2006 0.5458652 0.42820  3.351 0.2651
 #9: 2007 0.6331271 0.40410  9.629 0.2784
#10: 2008 0.8792396 0.64770  4.596 0.4131
#11: 2009 0.8465300 0.59450  6.383 0.3877
A.K.

- Original Message -
From: Janesh Devkota janesh.devk...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Friday, February 1, 2013 2:32 AM
Subject: [R] Summary of data for each year

Hello All,

I have a data with two columns. In one column it is date and in another
column it is flow data.

I was able to read the data as date and flow data. I used the following
code:

creek - read.csv(creek.csv)
library(ggplot2)
creek[1:10,]
colnames(creek) - c(date,flow)
creek$date - as.Date(creek$date, %m/%d/%Y)

The link to my data is https://www.dropbox.com/s/eqpena3nk82x67e/creek.csv

Now, I want to find the summary of each year. I want to especially know
mean, median, maximum etc.

Thanks.

Janesh

    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Summary of data for each year

2013-01-31 Thread Janesh Devkota
Hello All,

I have a data with two columns. In one column it is date and in another
column it is flow data.

I was able to read the data as date and flow data. I used the following
code:

creek - read.csv(creek.csv)
library(ggplot2)
creek[1:10,]
colnames(creek) - c(date,flow)
creek$date - as.Date(creek$date, %m/%d/%Y)

The link to my data is https://www.dropbox.com/s/eqpena3nk82x67e/creek.csv

Now, I want to find the summary of each year. I want to especially know
mean, median, maximum etc.

Thanks.

Janesh

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Summary of data for each year

2013-01-31 Thread Pascal Oettli

Hello,

One possibility is:

 creek - read.csv(creek.csv)
 colnames(creek) - c(date,flow)
 creek$date - as.Date(creek$date, %m/%d/%Y)
 creek - within(creek, year - format(date, '%Y'))

 with(creek, aggregate(flow, by=list(year=year), summary))

HTH,
Pascal


Le 01/02/2013 16:32, Janesh Devkota a écrit :

Hello All,

I have a data with two columns. In one column it is date and in another
column it is flow data.

I was able to read the data as date and flow data. I used the following
code:

creek - read.csv(creek.csv)
library(ggplot2)
creek[1:10,]
colnames(creek) - c(date,flow)
creek$date - as.Date(creek$date, %m/%d/%Y)

The link to my data is https://www.dropbox.com/s/eqpena3nk82x67e/creek.csv

Now, I want to find the summary of each year. I want to especially know
mean, median, maximum etc.

Thanks.

Janesh

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.