Message-ID: <alpine.DEB.2.00.1012221851330.9437@springer.Berkeley.EDU>
Date: 2010-12-23T02:54:45Z
From: Phil Spector
Subject: python-like dictionary for R
In-Reply-To: <AANLkTikjNcpgkuvOh=pXhMG9J30iFVqBm9Ly1apGFcZ4@mail.gmail.com>
Paul -
You can also use named vectors as something similar to
a python dictionary:
> nvec = c('one'=20,'two'=30,'three'=40)
> nvec['four'] = 50
> nvec['one']
one
20
> nvec['four']
four
50
Although the result is named, it can be used as a regular R
value:
> 20 + nvec['three']
three
60
If the names annoy you (as they seem to annoy many R users),
you can unname the object:
> unname(20 + nvec['three'])
[1] 60
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Wed, 22 Dec 2010, Paul Rigor wrote:
> Hi,
>
> I was wondering if anyone has played around this this package called
> "rdict"? It attempts to implement a hash table in R using skip lists. Just
> came across it while trying to look for simpler text manipulation methods:
>
> http://userprimary.net/posts/2010/05/29/rdict-skip-list-hash-table-for-R/
>
> Cheers,
> Paul
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>