[R] Extracting subsets by factor level?
Peter Dalgaard
P.Dalgaard at biostat.ku.dk
Wed Sep 17 13:07:05 CEST 2008
Rory.WINSTON at rbs.com wrote:
> Hi
>
> I have a data frame which looks like the following (it is a table of commit logs to a source repo). The Author column
> is treated as a factor, by virtue of stringsAsFactors being set to TRUE, so I can extract the number of commits
> per author by using table(logs$Author).
>
> Is there an elegant way to extract all subsets of this frame by the Author column - i.e. that returns say a list of
> data frames, each containing just the records for a specific value of Author?
>
Yup:
split(logs, logs$Author)
> Thanks
> Rory
>
>
>> head(logs)
>>
>
> Revision Author Date LinesChanged
> 1 6 user1 13/11/2007 15:41:53 488
> 2 11 user1 14/11/2007 09:04:43 3
> 3 12 user2 16/11/2007 12:26:04 522
> 4 13 user1 16/11/2007 12:27:55 90
> 5 14 user3 19/11/2007 09:32:54 159
> 6 15 user1 21/11/2007 13:38:41 1986
>
>
>
> ***********************************************************************************
> The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
> Authorised and regulated by the Financial Services Authority
>
> This e-mail message is confidential and for use by the...{{dropped:20}}
More information about the R-help
mailing list