Megh Dal
2010-Nov-06 13:41 UTC
[R] Extracting elements of a particular slot from S4 object
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) > valTitle: 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,
Henrique Dallazuanna
2010-Nov-06 13:48 UTC
[R] Extracting elements of a particular slot from S4 object
Try this: val@price On Sat, Nov 6, 2010 at 11:41 AM, Megh Dal <megh700004@yahoo.com> wrote:> 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, > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]