[R] Ordered factors and DBMS

F. Tusell etptupaf at bs.ehu.es
Thu Oct 4 17:38:43 CEST 2001

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.

Fernando TUSELL                                e-mail:
Departamento de Econometría y Estadística           etptupaf at bs.ehu.es 
Facultad de CC.EE. y Empresariales             Tel:   (+34)94.601.3733
Avenida Lendakari Aguirre, 83                  Fax:   (+34)94.601.3754
E-48015 BILBAO  (Spain)                        Secr:  (+34)94.601.3740
PGP: finger etptupaf at bsdx01.bs.ehu.es          http://etdx01.bs.ehu.es

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 mailing list