Re: [R] update search path for attached data

2008-07-05 Thread Ulrich Leopold
On Fri, 2008-07-04 at 15:13 +0100, Prof Brian Ripley wrote:
> On Fri, 4 Jul 2008, Ulrich Leopold wrote:
>
> > Dear list,
> >
> > is there a way of updating the search path when using attach() for a data
set.
> >
> > I am overwriting a variable in a data frame. To update teh search path I do
> > the follwoing:
> >
> >> attach(dataset)
> >> some data manipulation of dataset
> >> detach(dataset)
> >> attach(dataset) # to update the search path
> >
> > Is there a way to avoid the numerous detach() and attach() commands?
>
> Not if 'dataset' is that data frame (you didn't actually say).  From the
> help page:
>
>   The database is not actually attached.  Rather, a new environment
>   is created on the search path and the elements of a list
>   (including columns of a data frame) or objects in a save file or
>   an environment are _copied_ into the new environment.  If you use
>   '<<-' or 'assign' to assign to an attached database, you only
>   alter the attached copy, not the original object.
>
> So you can both change the data frame and assign the column to pos=2 to
> get the effect of what you appear to want.

How can I update directly the search path without using detach()
attach() or '<<-' assign()?
Maybe using attach() or assign methods is not so convenient anyway in my
case as it creates always a copy of each data set?

Is there a good practise in programming in R by using search paths but
keep memory as well as updating of the search path to a minimum?

Ulrich

-- 
__

Ulrich Leopold

Resource Centre for Environmental Technologies, Public Research Centre
Henri Tudor, Technoport Schlassgoart, 66 rue de Luxembourg, P.O. BOX
144, L-4002 Esch-sur-Alzette, Luxembourg

tel: +352 425991 618
fax: +352 425991 601
mobile: +352 691 304813
http://www.crte.lu


Computational Bio- and Physical Geography, Institute for Biodiversity
and Ecosystem Dynamics, University of Amsterdam, Nieuwe Achtergracht
166, NL-1018WV Amsterdam, The Netherlands

http://www.science.uva.nl/ibed

__
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.


[R] update search path for attached data

2008-07-04 Thread Ulrich Leopold
Dear list,

is there a way of updating the search path when using attach() for a data set.

I am overwriting a variable in a data frame. To update teh search path I do
the follwoing:

> attach(dataset)
> some data manipulation of dataset
> detach(dataset)
> attach(dataset) # to update the search path

Is there a way to avoid the numerous detach() and attach() commands?

Thanks in advance,
Ulrich Leopold

__
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.


[R] Error RODBC: Random termination of R

2008-02-15 Thread Ulrich Leopold
Dear list,

I get random terminations of R-2.6.2 when using RODBC-1.2_3 and a remote
PostgreSQL-8.2.6 database, unixodbc-2.2.11-16,
odbc-postgresql-1:08.01.0200-2.1 on Ubuntu Linux 7.10.

The exact messages can be seen below. It seems that there is some memory
corruption going on. But it seems random to me and can neither be related to
addPK=T/F or fast=T/F. It happens for all possible combinations. Besides I do
not really understand what these messages mean.

Any idea to what it might be related exactly?

Thanks in advance,
Ulrich Leopold

Session details:

>sessionInfo()
R version 2.6.2 (2008-02-08)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] RODBC_1.2-3

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17

> library(RODBC)
> channel = odbcConnect("crtedb", uid = "uleopold")
> channel
RODB Connection 1
Details:
  case=tolower
  DSN=crtedb
  DATABASE=valid
  SERVER=10.3.1.91
  PORT=5432
  SSLMODE=prefer
  UID=uleopold
  PWD=**
  ReadOnly=Yes
  FakeOidIndex=No
  ShowOidColumn=No
  RowVersioning=No
  ShowSystemTables=No
  ConnSettings=
  Fetch=100
  Socket=8192
  UnknownSizes=0
  MaxVarcharSize=254
  MaxLongVarcharSize=8190
  Debug=0
  CommLog=0
  Optimizer=1
  Ksqo=1
  UseDeclareFetch=0
  TextAsLongVarchar=1
  UnknownsAsLongVarchar=0
  BoolsAsChar=1
  Parse=0
  CancelAsFreeStmt=0
  ExtraSysTablePrefixes=dd_

  LFConversion=0
  UpdatableCursors=0
  DisallowPremature=0
  TrueIsMinus1=0
  BI=0
  ByteaAsLongVarBinary=0
  UseServerSidePrepare=0
  LowerCaseIdentifier=0

> sqlDrop(channel, "clx_test")
character(0)
> sqlSave(channel, clx_test, varTypes=varspec, addPK=TRUE, fast=TRUE) >
odbcClose(channel)
*** glibc detected *** /usr/lib/R/bin/exec/R: corrupted double-linked list:
0x082dd498 ***
=== Backtrace: =
/lib/tls/i686/cmov/libc.so.6[0xb7b8c3f9]
/lib/tls/i686/cmov/libc.so.6[0xb7b8db6e]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7b91800]
/usr/lib/R/lib/libR.so(R_chk_free+0x21)[0xb7d687c1]
/usr/local/lib/R/site-library/RODBC/libs/RODBC.so[0xb742db8d]
/usr/local/lib/R/site-library/RODBC/libs/RODBC.so(RODBCClose+0x2a)[0xb742dd5a]
/usr/lib/R/lib/libR.so[0xb7d13ea2]
/usr/lib/R/lib/libR.so(Rf_eval+0x707)[0xb7d406a7]
/usr/lib/R/lib/libR.so[0xb7d43037]
/usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4]
/usr/lib/R/lib/libR.so[0xb7d41967]
/usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4]
/usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0xb7d439b7]
/usr/lib/R/lib/libR.so(Rf_eval+0x2e2)[0xb7d40282]
/usr/lib/R/lib/libR.so(Rf_ReplIteration+0x19b)[0xb7d6632b]
/usr/lib/R/lib/libR.so(run_Rmainloop+0x107)[0xb7d666f7]
/usr/lib/R/lib/libR.so(Rf_mainloop+0x1c)[0xb7d6674c]
/usr/lib/R/bin/exec/R(main+0x46)[0x8048776]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7b3a050]
/usr/lib/R/bin/exec/R[0x8048691]
=== Memory map: 
08048000-08049000 r-xp  08:03 422045 /usr/lib/R/bin/exec/R
08049000-0804a000 rw-p  08:03 422045 /usr/lib/R/bin/exec/R
0804a000-09941000 rw-p 0804a000 00:00 0  [heap]
a770-a7721000 rw-p a770 00:00 0
a7721000-a780 ---p a7721000 00:00 0
a78ef000-a793e000 r-xp  08:03 259109 /usr/lib/libgcrypt.so.11.2.3
a793e000-a794 rw-p 0004e000 08:03 259109 /usr/lib/libgcrypt.so.11.2.3
a794-a7943000 r-xp  08:03 259082
/usr/lib/libgpg-error.so.0.3.0 a7943000-a7944000 rw-p 2000 08:03 259082   
 /usr/lib/libgpg-error.so.0.3.0 a7944000-a7953000 r-xp  08:03 266851  
  /usr/lib/libtasn1.so.3.0.9 a7953000-a7954000 rw-p e000 08:03 266851
/usr/lib/libtasn1.so.3.0.9 a7954000-a79be000 r-xp  08:03 730108
/usr/lib/libgnutls.so.13.3.0 a79be000-a79c4000 rw-p 0006a000 08:03 730108
/usr/lib/libgnutls.so.13.3.0 a79c4000-a79da000 r-xp  08:03 732700
/usr/lib/libsasl2.so.2.0.22 a79da000-a79db000 rw-p 00015000 08:03 732700
/usr/lib/libsasl2.so.2.0.22 a79db000-a79e6000 r-xp  08:03 732704
/usr/lib/liblber.so.2.0.130 a79e6000-a79e7000 rw-p b000 08:03 732704
/usr/lib/liblber.so.2.0.130 a79e7000-a79f6000 r-xp  08:03 712558
/lib/tls/i686/cmov/libresolv-2.6.1.so
a79f6000-a79f8000 rw-p f000 08:03 712558
/lib/tls/i686/cmov/libresolv-2.6.1.so
a79f8000-a79fa000 rw-p a79f8000 00:00 0
a79fa000-a7a01000 r-xp  08:03 259121
/usr/lib/libkrb5support.so.0.1 a7a01000-a7a02000 rw-p 6000 08:03 259121   
 /usr/lib/libkrb5support.so.0.1 a7a02000-a7a26000 r-xp  08:03 259108  
  /usr/lib/libk5crypto.so.3.1 a7a26000-a7a27000 rw-p 00024000 08:03 259108
/usr/lib/libk5crypto.so.3.1 a7a27000-a7a5b000 r-xp  08:03 732705
/usr/lib/libldap_r.so.2.0.130 a7a5b0

[R] Random termination of R with RODBC and PostgreSQL 8.2.6

2008-02-14 Thread Ulrich Leopold
Dear list,

I get random terminations of R when using RODBC with a remote PostgreSQL 8.2.6
database under Ubuntu Linux 7.10 32bit client.

The exact messages can be seen below. It seems that there is some memory
corruption going on. But it seems random to me and can neither be related to
addPK=T/F or fast=T/F. It can happend for all possible combinations. Besides I
do not really understand what these messages mean.

Any idea to what it is related exactly?

Thanks in advance,
Ulrich Leopold

Session details:

> library(RODBC)
> channel = odbcConnect("crtedb", uid = "uleopold")
> channel
RODB Connection 1
Details:
  case=tolower
  DSN=crtedb
  DATABASE=valid
  SERVER=10.3.1.91
  PORT=5432
  SSLMODE=prefer
  UID=uleopold
  PWD=**
  ReadOnly=Yes
  FakeOidIndex=No
  ShowOidColumn=No
  RowVersioning=No
  ShowSystemTables=No
  ConnSettings=
  Fetch=100
  Socket=8192
  UnknownSizes=0
  MaxVarcharSize=254
  MaxLongVarcharSize=8190
  Debug=0
  CommLog=0
  Optimizer=1
  Ksqo=1
  UseDeclareFetch=0
  TextAsLongVarchar=1
  UnknownsAsLongVarchar=0
  BoolsAsChar=1
  Parse=0
  CancelAsFreeStmt=0
  ExtraSysTablePrefixes=dd_

  LFConversion=0
  UpdatableCursors=0
  DisallowPremature=0
  TrueIsMinus1=0
  BI=0
  ByteaAsLongVarBinary=0
  UseServerSidePrepare=0
  LowerCaseIdentifier=0

> sqlDrop(channel, "clx_test")
character(0)
> sqlSave(channel, clx_test, varTypes=varspec, addPK=TRUE, fast=TRUE)
> sessionInfo()
R version 2.6.2 (2008-02-08)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] RODBC_1.2-3

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17
> odbcClose(channel)
*** glibc detected *** /usr/lib/R/bin/exec/R: corrupted double-linked list:
0x082dd498 ***
=== Backtrace: =
/lib/tls/i686/cmov/libc.so.6[0xb7b8c3f9]
/lib/tls/i686/cmov/libc.so.6[0xb7b8db6e]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7b91800]
/usr/lib/R/lib/libR.so(R_chk_free+0x21)[0xb7d687c1]
/usr/local/lib/R/site-library/RODBC/libs/RODBC.so[0xb742db8d]
/usr/local/lib/R/site-library/RODBC/libs/RODBC.so(RODBCClose+0x2a)[0xb742dd5a]
/usr/lib/R/lib/libR.so[0xb7d13ea2]
/usr/lib/R/lib/libR.so(Rf_eval+0x707)[0xb7d406a7]
/usr/lib/R/lib/libR.so[0xb7d43037]
/usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4]
/usr/lib/R/lib/libR.so[0xb7d41967]
/usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4]
/usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0xb7d439b7]
/usr/lib/R/lib/libR.so(Rf_eval+0x2e2)[0xb7d40282]
/usr/lib/R/lib/libR.so(Rf_ReplIteration+0x19b)[0xb7d6632b]
/usr/lib/R/lib/libR.so(run_Rmainloop+0x107)[0xb7d666f7]
/usr/lib/R/lib/libR.so(Rf_mainloop+0x1c)[0xb7d6674c]
/usr/lib/R/bin/exec/R(main+0x46)[0x8048776]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7b3a050]
/usr/lib/R/bin/exec/R[0x8048691]
=== Memory map: 
08048000-08049000 r-xp  08:03 422045 /usr/lib/R/bin/exec/R
08049000-0804a000 rw-p  08:03 422045 /usr/lib/R/bin/exec/R
0804a000-09941000 rw-p 0804a000 00:00 0  [heap]
a770-a7721000 rw-p a770 00:00 0
a7721000-a780 ---p a7721000 00:00 0
a78ef000-a793e000 r-xp  08:03 259109 /usr/lib/libgcrypt.so.11.2.3
a793e000-a794 rw-p 0004e000 08:03 259109 /usr/lib/libgcrypt.so.11.2.3
a794-a7943000 r-xp  08:03 259082 /usr/lib/libgpg-error.so.0.3.0
a7943000-a7944000 rw-p 2000 08:03 259082 /usr/lib/libgpg-error.so.0.3.0
a7944000-a7953000 r-xp  08:03 266851 /usr/lib/libtasn1.so.3.0.9
a7953000-a7954000 rw-p e000 08:03 266851 /usr/lib/libtasn1.so.3.0.9
a7954000-a79be000 r-xp  08:03 730108 /usr/lib/libgnutls.so.13.3.0
a79be000-a79c4000 rw-p 0006a000 08:03 730108 /usr/lib/libgnutls.so.13.3.0
a79c4000-a79da000 r-xp  08:03 732700 /usr/lib/libsasl2.so.2.0.22
a79da000-a79db000 rw-p 00015000 08:03 732700 /usr/lib/libsasl2.so.2.0.22
a79db000-a79e6000 r-xp  08:03 732704 /usr/lib/liblber.so.2.0.130
a79e6000-a79e7000 rw-p b000 08:03 732704 /usr/lib/liblber.so.2.0.130
a79e7000-a79f6000 r-xp  08:03 712558
/lib/tls/i686/cmov/libresolv-2.6.1.so
a79f6000-a79f8000 rw-p f000 08:03 712558
/lib/tls/i686/cmov/libresolv-2.6.1.so
a79f8000-a79fa000 rw-p a79f8000 00:00 0
a79fa000-a7a01000 r-xp  08:03 259121 /usr/lib/libkrb5support.so.0.1
a7a01000-a7a02000 rw-p 6000 08:03 259121 /usr/lib/libkrb5support.so.0.1
a7a02000-a7a26000 r-xp  08:03 259108 /usr/lib/libk5crypto.so.3.1
a7a26000-a7a27000 rw-p 00024000 08:03 259108 /usr/lib/libk5crypto.so.3.1
a7a27000-a7a5b000 r-xp  08:03 732705 /usr/lib/libldap_r.so.2.0.130
a7a5b000-a7a5c000 rw-p 00034000 08:03 732705 /