Hello Samer,
Thank you again for taking the time to help.
I am curious about the possibility of masked objects/functions ... since
the subsetting problem disappeared when I did the following
steps:
First, in the "corrupt" project, I used data.dump (ls(),
"mydata.dat") to save all of the objects and functions in that
project.
Second, I created a new folder for a "new" project and copied
the file mydata.dat to it.
Third, I created a shortcut for S-Plus 8 with S_Proj pointing to the new
folder.
Fourth, I open S-Plus 8 using the new shortcut (which has the effect of
S-Plus creating new .Data and .Pref subdirectories.
5th, in the new project, I used data.restore ("mydata.dat").
This has the effect of restoring all the objects and functions that were
in the "corrupt" project.
Using this, my subsetting command works!
So, (at long last), my question is ... it doesn't seem as though my
problem with subsetting in the corrupt project was caused by masked
objects or functions ... since all of these are also present in the new
project. Furthermore, I have been working away madly all week using the
new project to complete analyses ... the problem has not
reoccured.
So, how did the old project get corrupted? Did something get
overwritten? Did I put too many commands in the history file? Did I
cause the problem by deleting objects using the object browser?
Any clues? Suggestions?
Thanks!
Madeline
At 08:30 PM 06/16/2009, Samer Mouksassi wrote:
Hello Madeline,
I am happy that it worked out for you.
Objects sometimes mask others and using the same name of a function or
the like can make things going off the expected track.
Attaching a data.frame may not be the best way to go as the variable
names may mask and or interfere with your environment.
You can investigate the objects that are in your project using:
objects()
Try to remove any unnecessary object that using:
rm(BADOBJECT)
Bests,
Samer
From: Madeline Bauer
[
mailto:mbauer@usc.edu]
Sent: 2009-06-16 23:13
To: Samer Mouksassi
Cc: s-news@wubios.wustl.edu
Subject: RE: [S] Subsetting a dataframe in SPlus 8
Hi Samer,
Thank you again for your example. That opened my eyes to the possibility
that my project was corrupted. I used data.dump to create a file with the
data sets and made a new folder for the project and made a new SPlus
shortcut pointing to that folder. All is well, but I'm puzzled how
the original project got corrupted.
Thanks!
Puzzled at USC,
Madeline
================
Here is my output for your example ... as you can see, the subset is
correct, but at least in my SPlus 8.1.1, the final not Subset produces
just a bunch of NAs.
So I got the idea to try SPlus 8.1.1 in a different project! That
works! (See output below.)
It looks like something happened to the specific SPlus 8.1.1
project!!
I will now see if I can reconstruct that project.
Thanks for your help!
Madeline
========= worked example ===============
attach (fuel.frame)
names(fuel.frame)
[1] "Weight" "Disp."
"Mileage" "Fuel"
"Type"
Subset <- I( (Weight == 2560 & Mileage == 33) |
(Weight == 2345 & Mileage== 33 ) )
mode(Subset)
# this gives logical
[1] "logical"
table (Weight [Subset], Mileage [Subset])
33
2345 1
2560 1
as.data.frame ( fuel.frame[!Subset,])
Weight Disp. Mileage Fuel Type
NA NA
NA NA NA NA
NA1 NA
NA NA NA NA
NA2 NA
NA NA NA NA
NA3 NA
NA NA NA NA
NA4 NA
NA NA NA NA
NA5 NA
NA NA NA NA
NA6 NA
NA NA NA NA
NA7 NA
NA NA NA NA
NA8 NA
NA NA NA NA
NA9 NA
NA NA NA NA
NA10 NA
NA NA NA NA
[snipped]
NA59 NA
NA NA NA NA
============ example output using a different SPlus project
==============
Weight Disp. Mileage Fuel Type
Ford Festiva 4
1845 81 37
2.702703 Small
Honda Civic
4 2260 91 32
3.125000 Small
Mazda Protege 4
2440 113 32
3.125000 Small
Mercury Tracer 4
2285 97 26
3.846154 Small
[snipped]
Nissan Van
4 3690 146 19
5.263158 Van
At 05:12 PM 06/16/2009, Samer Mouksassi wrote:
Can you please
provide a reproducible example?
How does your Subset look like before running the last line
This code works entirety in tibco S-plus 8.1.1
attach (fuel.frame)
names(fuel.frame)
Subset <- I( (Weight == 2560 & Mileage == 33) |
(Weight == 2345 & Mileage== 33 ) )
mode(Subset)
# this gives logical
table (Weight [Subset], Mileage [Subset])
as.data.frame ( fuel.frame[!Subset,])
Samer
Samer Mouksassi
Pharm.D.
Senior Associate
Scientist
Pharsight- A Certara?
Company
2000 Peel, Suite 570
Montreal, Quebec, Canada H3A 2W5
Phone: 514.789.2184
Mobile: 514.475.9339
Fax: 514.789.2192
Email:
smouksassi@pharsight.com
The information contained in this electronic mail message (including any
attachments) is intended only for the personal and confidential use of
the designated recipient(s) named above. If the reader of this message is
not the intended recipient or an agent responsible for delivering it to
the intended recipient, you are hereby notified that you have received
this message in error and that any review, dissemination, distribution,
or copying of this message is strictly prohibited. If you have
received this communication in error, please notify the sender
immediately by telephone and/or e-mail
(
smouksassi@pharsight.com
) and destroy any and all
copies of this message in your possession (whether hardcopies or
electronically stored copies). Thank you.
From:
s-news-owner@lists.biostat.wustl.edu [
mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of
Madeline Bauer
Sent: Tuesday, June 16, 2009 7:59 PM
To: s-news@wubios.wustl.edu
Subject: [S] Subsetting a dataframe in SPlus 8
attach (tmp.keep )
I'm using SPlus 8.1.1 in Windows XP Pro and I'd like to remove 5 records
from a dataframe. The following code works in SPlus 2000, but in SPlus 8,
the final line produces a dataframe with all NAs. Obviously there
is something new and wonderful in SPlus 8 that I need to know!
Sample code:
attach (tmp.keep )
Subset <- I( (Log.No == 5071 & Rep.ICCC2008 == 1) |
(Log.No == 5087
& Rep.ICCC2008 == 2) |
(Log.No == 5055
& Rep.ICCC2008 == 1) |
(Log.No == 5102
& Rep.ICCC2008 == 1) |
(Log.No == 5032
& Rep.ICCC2008 == 2) )
# this works in both SPlus 8 and 2000.
table (Log.No [Subset], Rep.ICCC2008 [Subset])
# this works in SPlus 2000, but not in SPlus 8:
as.data.frame ( tmp.keep [!Subset,])
All suggestions welcome!
Thanks in advance,
Madeline
===
Madeline Bauer, Ph.D.
University of Southern California
Keck School of Medicine (Infectious Diseases)
IRD Room 620 (MC9520), 2020 Zonal Ave, Los Angeles 90033
(323) 226-2775 [Voice] (FAX by appointment ;-)
mbauer@usc.edu [Fastest communication method]
|