df is the name of a function in base R. You have not provided a definition
of sample data resembling your real data. In this case I suspect that the
source of your problems is that df may not be what you think it is.
Learning to use the "str" function may help you.
If df is a data frame containing a column called "city", then df$city
is a
vector. You don't need to convert it to a vector. Nor do you need to
concatenate it with anything.
Note that hash tables may not be the best or only way to accomplish this.
The data.table package offers data frames with binary search indexing that
can be quite fast, particularly if you plan to do these lookups on large
amounts of data.
Try reading
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
for ideas on how to communicate your problems with R more clearly.
On Fri, 19 Dec 2014, email wrote:
> Hi:
>
> I have one million names of city and their population and want to make
> a hash so that by giving key = city, the hash function will return its
> population.
>
> I use the hash package in R as follows:
> h <- hash(c(as.vector(df$city)), c(as.vector(df$population)))
>
> But getting the following error:
> Error in assign(keys[[i]], values[[i]], envir = hash at .Data) :
> variable names are limited to 10000 bytes
>
> How can it be solved?
>
> Thanks:
>
> John
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k