[R] Data Frame as Hash Table

Patrick Burns pburns at pburns.seanet.com
Sun May 30 10:24:22 CEST 2010


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 guide http://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