s-news
[Top] [All Lists]

Re: Subsetting a dataframe in SPlus 8

To: Samer Mouksassi <smouksassi@Pharsight.com>
Subject: Re: Subsetting a dataframe in SPlus 8
From: Madeline Bauer <mbauer@usc.edu>
Date: Tue, 16 Jun 2009 20:12:56 -0700
Cc: s-news@wubios.wustl.edu
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]
<Prev in Thread] Current Thread [Next in Thread>