s-news
[Top] [All Lists]

Re: Changing a read-only data frame to read/write

To: S-News <s-news@lists.biostat.wustl.edu>
Subject: Re: Changing a read-only data frame to read/write
From: TzamouranisY@LouisDreyfus.com
Date: Mon, 12 Sep 2005 08:52:38 -0400
Cc: "Jordan, Paul" <paul.jordan@roche.com>, SmithSJ@mar.dfo-mpo.gc.ca, BBiggerstaff@cdc.gov

Thank you all for your suggestions (listed below).

First off, the problem with creating the read-only frame was an unexpected "named" class for one of the columns of my data frame, as I noted before.  I am not clear why "named" and not "double", given that all the items that rowMeans, colMeans, min, max and mean operated on to create the additional columns in the original frame were doubles.  Wrapping the results of these functions with an "as.double" resolved the issue and the data frame was now read/write.

Steve Smith (and others) suggested writing a function to check that none of the columns were of class named
One such function, contributed by Brad Biggerstaff, would be:
if (any(nmd <- sapply(db, class) == "named"))
db <- convert.col.type(db, which(nmd),"numeric")

Thanks to all for their suggestions (I hope that I have not skipped any names but some email glitch has cost me some loss of communications which I tried to fill through notes I had).

Yannis Tzamouranis
--------------------
Paul's suggestion:

attach(X,pos=2)

database.status(where=2) <- "readwrite"
--------------
Brad Biggerstaff:
It's not clear (to me) that a particular data frame is read-only or read-write.  But this is true for databases (in particular, folders attached in the search path).  To change the "status" of a database named db to read-write, use
 
database.status("db") <- "readwrite"
 
This should permit writing to objects in db.  Now, should there be a read-only file in there, as restricted by the system, not S-Plus, you might need, it seems, to execute a system command to change that; but I suspect that this change might not be visible to the current S-Plus session.  (I'm only guessing on this part.)
 
Other utilities for databases can be found on the (common) help page for database.status.  There are also some other database functions for manipulating databases: see the help page for dbread, for example.
--------------------
Wim Kimmerer:
The "named" data class has been a thorn in my side (and probably everybody
else's) since it was introduced in V.6.  I was disappointed that it has not
changed in v.7.  That, coupled with several extra bugs and the lack of
response by Insightful to my request to lighten up on the licensing rules,
led me to go back to V. 6.

You have to use "as.numeric" to get rid of the named class before you can
put it in a data frame if you want to avoid that "read-only"
problem.  Sure, it is a small thing, but it is very annoying and a frequent
source of error (since nowhere are  the rules written about what produces a
named class and what doesn't).  Plus it is not mentioned in the
documentation as far as I know.

----------------

-----Original Message-----
From:
TzamouranisY@LouisDreyfus.com [mailto:TzamouranisY@LouisDreyfus.com]
Sent:
Wednesday, September 07, 2005 4:00 PM
To:
s-news@lists.biostat.wustl.edu
Subject:
Changing a read-only data frame to read/write


I need to change a data frame from read-only to read-write.

Doing this through the GUI will not do it in my case - it has to be done through code.


Any ideas how to do this?


I tried simple things such as "as.data.frame" and reassigning it to a new name but failed.


Thanks,


Yannis Tzamouranis


<Prev in Thread] Current Thread [Next in Thread>