[R] Ordered factors and DBMS
Timothy H. Keitt
tklistaddr at keittlab.bio.sunysb.edu
Thu Oct 4 19:28:43 CEST 2001
Doug's suggestions of joining two tables or defining a new type are a
good ones, although you would have to do some manual manipulations in
raw SQL. There is a general need to be able to split compound R types
across more than one SQL column. It may be possible with RPgSQL if you
redefind rpgsql.format.values.factor and friends, but I haven't tried
this myself. It is something to think about as we develop a more general
F. Tusell wrote:
>Is there any way of preserving order of ordered factors when storing a
>table in PostgreSQL?
>I have been using PostgreSQL and the RPgSQL package to store a large
>table with answers such as "Strong disagreement", "Strong agreement",
>"Mild disagreement". "Mild agreement". When reading the table, such
>answers are turned into factors, apparently in reverse alphabetical
>order. If I reorder them using ordered(factor, levels=the order I
>want), everything is fine for the session, but saving the table and
>re-reading it reverts to the original order.
>I have a vague feeling of having seen this asked, but I could not
>locate any references. I looked also B.D. Ripley's "Using Databases
>with R", but this problem is not discussed.
Timothy H. Keitt
Department of Ecology and Evolution
State University of New York at Stony Brook
Stony Brook, New York 11794 USA
Phone: 631-632-1101, FAX: 631-632-7626
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help