Hi All, I have the data like this :>sample <- read.csv(file="sample.csv",sep=",",header=TRUE) > samplestdate Domain sex age Login 1 01/11/09 xxx FeMale 25 2 2 01/11/09 xxx FeMale 35 4 3 01/11/09 xxx Male 18 30 4 01/11/09 xxx Male 31 3 5 02/11/09 xxx Male 32 11 6 02/11/09 xxx Male 31 1 7 02/11/09 xxx FeMale 29 1 8 02/11/09 xxx FeMale 23 5 9 03/11/09 xxx FeMale 25 9 10 03/11/09 xxx FeMale 35 6 11 03/11/09 xxx Male 18 3 12 03/11/09 xxx Male 31 0 13 04/11/09 xxx Male 32 25 14 04/11/09 xxx Male 31 1 15 04/11/09 xxx FeMale 29 0 16 01/11/09 yyy FeMale 25 2 17 01/11/09 yyy FeMale 35 4 18 01/11/09 yyy Male 18 30 19 01/11/09 yyy Male 31 3 20 02/11/09 yyy Male 32 11 21 02/11/09 yyy Male 31 1 22 02/11/09 yyy FeMale 29 1 23 02/11/09 yyy FeMale 23 5 24 03/11/09 yyy FeMale 25 9 25 03/11/09 yyy FeMale 35 6 26 03/11/09 yyy Male 18 3 27 03/11/09 yyy Male 31 0 28 04/11/09 yyy Male 32 25 29 04/11/09 yyy Male 31 1 30 04/11/09 yyy FeMale 29 0 I need to fine the average login on 01/11/09 and 02/11/09 etc... like below stdate AverageLogin 01/11/09 9.75 02/11/09 ..... 03/11/09 ....... How do I find the average Login based on date? Thanks for your time. Mohan L [[alternative HTML version deleted]]
try this:> x <- read.table(textConnection(" stdate Domain sex age Login+ 1 01/11/09 xxx FeMale 25 2 + 2 01/11/09 xxx FeMale 35 4 + 3 01/11/09 xxx Male 18 30 + 4 01/11/09 xxx Male 31 3 + 5 02/11/09 xxx Male 32 11 + 6 02/11/09 xxx Male 31 1 + 7 02/11/09 xxx FeMale 29 1 + 8 02/11/09 xxx FeMale 23 5 + 9 03/11/09 xxx FeMale 25 9 + 10 03/11/09 xxx FeMale 35 6 + 11 03/11/09 xxx Male 18 3 + 12 03/11/09 xxx Male 31 0 + 13 04/11/09 xxx Male 32 25 + 14 04/11/09 xxx Male 31 1 + 15 04/11/09 xxx FeMale 29 0 + 16 01/11/09 yyy FeMale 25 2 + 17 01/11/09 yyy FeMale 35 4 + 18 01/11/09 yyy Male 18 30 + 19 01/11/09 yyy Male 31 3 + 20 02/11/09 yyy Male 32 11 + 21 02/11/09 yyy Male 31 1 + 22 02/11/09 yyy FeMale 29 1 + 23 02/11/09 yyy FeMale 23 5 + 24 03/11/09 yyy FeMale 25 9 + 25 03/11/09 yyy FeMale 35 6 + 26 03/11/09 yyy Male 18 3 + 27 03/11/09 yyy Male 31 0 + 28 04/11/09 yyy Male 32 25 + 29 04/11/09 yyy Male 31 1 + 30 04/11/09 yyy FeMale 29 0"), header=TRUE)> closeAllConnections() > aggregate(x$Login, list(x$stdate), mean)Group.1 x 1 01/11/09 9.750000 2 02/11/09 4.500000 3 03/11/09 4.500000 4 04/11/09 8.666667 On Sat, May 1, 2010 at 2:07 PM, Mohan L <l.mohanphy@gmail.com> wrote:> Hi All, > > I have the data like this : > > >sample <- read.csv(file="sample.csv",sep=",",header=TRUE) > > sample > > stdate Domain sex age Login > 1 01/11/09 xxx FeMale 25 2 > 2 01/11/09 xxx FeMale 35 4 > 3 01/11/09 xxx Male 18 30 > 4 01/11/09 xxx Male 31 3 > 5 02/11/09 xxx Male 32 11 > 6 02/11/09 xxx Male 31 1 > 7 02/11/09 xxx FeMale 29 1 > 8 02/11/09 xxx FeMale 23 5 > 9 03/11/09 xxx FeMale 25 9 > 10 03/11/09 xxx FeMale 35 6 > 11 03/11/09 xxx Male 18 3 > 12 03/11/09 xxx Male 31 0 > 13 04/11/09 xxx Male 32 25 > 14 04/11/09 xxx Male 31 1 > 15 04/11/09 xxx FeMale 29 0 > 16 01/11/09 yyy FeMale 25 2 > 17 01/11/09 yyy FeMale 35 4 > 18 01/11/09 yyy Male 18 30 > 19 01/11/09 yyy Male 31 3 > 20 02/11/09 yyy Male 32 11 > 21 02/11/09 yyy Male 31 1 > 22 02/11/09 yyy FeMale 29 1 > 23 02/11/09 yyy FeMale 23 5 > 24 03/11/09 yyy FeMale 25 9 > 25 03/11/09 yyy FeMale 35 6 > 26 03/11/09 yyy Male 18 3 > 27 03/11/09 yyy Male 31 0 > 28 04/11/09 yyy Male 32 25 > 29 04/11/09 yyy Male 31 1 > 30 04/11/09 yyy FeMale 29 0 > > I need to fine the average login on 01/11/09 and 02/11/09 etc... like below > > stdate AverageLogin > 01/11/09 9.75 > 02/11/09 ..... > 03/11/09 ....... > > How do I find the average Login based on date? > > Thanks for your time. > Mohan L > > [[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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
On May 1, 2010, at 2:07 PM, Mohan L wrote:> Hi All, > > I have the data like this : > >> sample <- read.csv(file="sample.csv",sep=",",header=TRUE) >> sample > > stdate Domain sex age Login > 1 01/11/09 xxx FeMale 25 2 > 2 01/11/09 xxx FeMale 35 4 > 3 01/11/09 xxx Male 18 30 > 4 01/11/09 xxx Male 31 3 > 5 02/11/09 xxx Male 32 11 > 6 02/11/09 xxx Male 31 1 > 7 02/11/09 xxx FeMale 29 1 > 8 02/11/09 xxx FeMale 23 5 > 9 03/11/09 xxx FeMale 25 9 > 10 03/11/09 xxx FeMale 35 6 > 11 03/11/09 xxx Male 18 3 > 12 03/11/09 xxx Male 31 0 > 13 04/11/09 xxx Male 32 25 > 14 04/11/09 xxx Male 31 1 > 15 04/11/09 xxx FeMale 29 0 > 16 01/11/09 yyy FeMale 25 2 > 17 01/11/09 yyy FeMale 35 4 > 18 01/11/09 yyy Male 18 30 > 19 01/11/09 yyy Male 31 3 > 20 02/11/09 yyy Male 32 11 > 21 02/11/09 yyy Male 31 1 > 22 02/11/09 yyy FeMale 29 1 > 23 02/11/09 yyy FeMale 23 5 > 24 03/11/09 yyy FeMale 25 9 > 25 03/11/09 yyy FeMale 35 6 > 26 03/11/09 yyy Male 18 3 > 27 03/11/09 yyy Male 31 0 > 28 04/11/09 yyy Male 32 25 > 29 04/11/09 yyy Male 31 1 > 30 04/11/09 yyy FeMale 29 0 > > I need to fine the average login on 01/11/09 and 02/11/09 etc... > like belowavglog <- with(sample, tapply(Login, stdate, mean) )> > stdate AverageLogin > 01/11/09 9.75 > 02/11/09 ..... > 03/11/09 ....... > > How do I find the average Login based on date? > > Thanks for your time. > Mohan L > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT