[R] Apply() on columns

Rui Barradas ruipbarradas at sapo.pt
Mon Jun 25 13:53:02 CEST 2012


Hello, again.

Sorry, I've used 'sum' when it should be 'mean'.

Rui Barradas

Em 25-06-2012 12:49, Rui Barradas escreveu:
> Hello,
>
> It's not that complicated.
>
>
>
> f <- function(index, dat, offset=5){
>      x <- data.frame(Emp=dat[, index], Hours=dat[, index + offset])
>      aggregate(Hours~Emp, data=x, sum)
> }
>
> sp <- read.table("supermarkt.txt")
>
> lapply(1:5, f, sp)
>
>
> Also, please provide context. (Quote the post you are reffering to.)
>
> Hope this helps,
>
> Rui Barradas
>
> Em 25-06-2012 11:43, faelsendoorn escreveu:
>> I do now know how to navigate through the table.
>> But my question is, what kind of graphical and numerical summaries can I
>> make with keeping in mind that I am interested in the average working
>> hour
>> per employee?
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Apply-on-columns-tp4633468p4634411.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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.
>>
>
> ______________________________________________
> 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