[R] Extracting elements of a particular slot from S4 object

Megh Dal megh700004 at yahoo.com
Sat Nov 6 14:41:54 CET 2010


Hi there, can anyone tell me how to extract to values of a particular slot for some S4 object? Let take following example:

> library(fOptions)
> val <-GBSOption(TypeFlag = "c", S = 60, X = 65, Time = 1/4, r = 0.08, b = 0.08, sigma = 0.30)
> val

Title:
 Black Scholes Option Valuation 

Call:
 GBSOption(TypeFlag = "c", S = 60, X = 65, Time = 1/4, r = 0.08, 
     b = 0.08, sigma = 0.3)

Parameters:
          Value:
 TypeFlag c     
 S        60    
 X        65    
 Time     0.25  
 r        0.08  
 b        0.08  
 sigma    0.3   

Option Price:
 2.133372 

Description:
 Sat Nov 06 19:25:39 2010 

Here I have tried with following however slapped with some error:


> val@"Option Price"
Error: no slot of name "Option Price" for this object of class "fOPTION"

What is the ideal way to do that?

Thanks,



More information about the R-help mailing list