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.