[R] Data Frame as Hash Table

Marshall Feldman marsh at uri.edu
Sun May 30 14:35:09 CEST 2010


Besides data.table, there's the hash package. It does not use data.frame 
type structures but is a bit more flexible.

Marsh Feldman

On 5/30/10 [May 30, 10] 6:00 AM, r-help-request at r-project.org wrote:
> Message: 40
> Date: Sun, 30 May 2010 09:24:22 +0100
> From: Patrick Burns<pburns at pburns.seanet.com>
> To:r-help at r-project.org,alan.lue at gmail.com
> Subject: Re: [R] Data Frame as Hash Table
> Message-ID:<4C0220B6.7090006 at pburns.seanet.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> You might want to investigate the 'data.table'
> package.
>
> On 30/05/2010 09:03, Alan Lue wrote:
>    
>> >  I'm interested in using a data frame as if it were a hash table.  For
>> >  instance if I had the following,
>> >
>>      
>>> >>  (d<- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))
>>>        
>> >      key        value
>> >  1 0.5 -1.118665122
>> >  2 1.0  0.465122921
>> >  3 1.5 -0.529239211
>> >  4 2.0 -0.147324638
>> >  5 2.5 -1.531503795
>> >  6 3.0 -0.002720434
>> >
>> >  Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
>> >  to get -0.53.  How would one go about doing this?
>> >
>> >  Yours,
>> >  Alan Lue
>> >
>> >  ______________________________________________
>> >  R-help at r-project.org  mailing list
>> >  https://stat.ethz.ch/mailman/listinfo/r-help
>> >  PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>> >  and provide commented, minimal, self-contained, reproducible code.
>> >
>>      
> -- Patrick Burns pburns at pburns.seanet.com http://www.burns-stat.com 
> (home of 'Some hints for the R beginner' and 'The R Inferno')



More information about the R-help mailing list