Hi:

Convert the location to factor and you should be OK:

x <- factor(sample(LETTERS[1:3], 10, replace = TRUE))
storage.mode(x)
[1] "integer"

BTW, data.table has its own mailing list:

Send datatable-help mailing list submissions to
       datatable-h...@lists.r-forge.r-project.org

To subscribe or unsubscribe via the World Wide Web, visit

https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help



You need to be subscribed first before posting.

HTH,
Dennis


On Sun, Sep 12, 2010 at 10:35 AM, Anyi Zhu <anyi....@gmail.com> wrote:

> Hi all,
>
> Say if I have a data table which consists of 4 column: itemID, location and
> price, which location is a text field and itemID and location together
> forms
> the primary keys.
>
> when I tried to run setkey (DT, itemID, location), I got the following
> message:
>
> Error in setkey (DT, itemID, location) :
>  All keyed columns must be storage mode integer
>
> Is there any way I could define a non-numerical field (in this case
> location) to be the key?
>
> Also, if I do not use the location as a key, will I still able to merge 2
> data tables based on itemID and location using the "merge" method in
> data.table?
>
> Thanks a lot!
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to