[R] Item analysis

John Kane jrkrideau at yahoo.ca
Fri Jun 10 20:12:10 CEST 2011


Here are two different ways with your data as the data.frame xx

# Basic R 
aggregate(xx$Tip, list(xx$Time), sum)

# Using the rshape package
library(reshape2)
yy <- melt(xx, id=c("Time"), measure.vars=c("Tip"))
dcast(yy , Time ~ variable , sum)


--- On Thu, 6/9/11, Trying To learn again <tryingtolearnagain at gmail.com> wrote:

> From: Trying To learn again <tryingtolearnagain at gmail.com>
> Subject: [R] Item analysis
> To: r-help at r-project.org
> Received: Thursday, June 9, 2011, 4:41 PM
> Hi all,
> 
> For several reasons I have no used CARN R in months....I
> have an idea and I
> want to retry to learn CRAN R.
> 
> I know I need to formulate more "intelligent" questions but
> I will expose
> and if someone can help me I would be very gratefull I
> promise to try to
> learn again....
> 
> The question I have a data file like this:
> 
> Date, Time, Tip
> 13/11/2008,23:16:00,432
> 13/01/2009,23:17:00,633
> 13/11/2009,23:16:00,134
> 13/12/2009,23:17:00,234
> 13/01/2010,23:16:00,111
> 
> I want to make an statistic (the sum of tip) but to extract
> one sum by each
> different minute in Time, so you see, in this easy example
> I will have a
> final table with two items:
> 
> Item Sum
> 16 (432+134+111)
> 17 (633+234)
> 
> Of course in my file (is bigger) I have minutes from 0 to
> 59.
> 
> Would it be too much difficult if I want this analysis but
> on table for each
> day (indentified in the column Date) of the week. So you
> see on
> 13/11/2008  was thursday so you go each day and sum if
> this day is thrusday
> from 0 to 59 minutes...
> 
> MAny thanks for all, each tip you give me I will send
> thousands of
> thanks¡¡¡¡¡
> 
>     [[alternative HTML version deleted]]
> 
> 
> -----Inline Attachment Follows-----
> 
> ______________________________________________
> 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.
>



More information about the R-help mailing list