[R] processing log file

Henrique Dallazuanna wwwhsd at gmail.com
Fri Nov 13 18:11:51 CET 2009


You can use aggregate to get this too:

aggregate(table.users[,c('UserName', 'Machine')], table.users['Date'],
function(x)length(unique(x)))

On Fri, Nov 13, 2009 at 3:01 PM, Jabez Wilson <jabezwuk at yahoo.co.uk> wrote:
> Thanks, that's helpful because I can see the individuals and how many times they accessed:
> The 'plyr' solution of Karl Ove Hufthammer gives me the exact summary statistics that I'm looking for.
>
> Jab
>
> --- On Fri, 13/11/09, markleeds at verizon.net <markleeds at verizon.net> wrote:
>
>
> From: markleeds at verizon.net <markleeds at verizon.net>
> Subject: Re: Re: [R] processing log file
> To: jabezwuk at yahoo.co.uk
> Date: Friday, 13 November, 2009, 16:36
>
>
> Hi: I think below does what you want but it doesn't come out formatted very nicely. Maybe someone can show you
> the formatting ? Good luck.
>
> table.users <- read.table(textConnection("Date UserName Machine
> 2008-11-25     John     641
> 2008-11-25    Clive     611
> 2008-11-25   Jeremy     641
> 2008-11-25     Walt     722
> 2008-11-25     Tony     645
> 2008-11-26     Tony     645
> 2008-11-26     Tony     641
> 2008-11-26     Tony     641
> 2008-11-26     Walt     641
> 2008-11-26     Walt     645
> 2008-11-30     John     641
> 2008-11-30    Clive     611
> 2008-11-30     Tony     641
> 2008-11-30     John     641
> 2008-11-30     John     641"),header=TRUE,as.is=TRUE)
>
> print(table.users)
> print(str(table.users))
>
> lapply(split(table.users,table.users$Date),function(.df) {
>     table(.df$Machine)
> })
>
> lapply(split(table.users,table.users$Date),function(.df) {
>     table(.df$UserName)
> })
>
>
>
>
>
>
> On Nov 13, 2009, Karl Ove Hufthammer <karl at huftis.org> wrote:
>
> On Fri, 13 Nov 2009 11:03:31 +0000 (GMT) Jabez Wilson
> <jabezwuk at yahoo.co.uk> wrote:
>> What I want to do is to find out how many unique users logged
>> on each day, and how many individual machines where accessed per day.
>
> Use the 'plyr' package:
>
> library(plyr)
> ddply(table.users, .(Date), summarise,
> users=length(unique(Username)),
> machines=length(unique(Machine)))
>
> --
> Karl Ove Hufthammer
>
> ______________________________________________
> 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.
>
>
>
>
>        [[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.
>
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list