Hi,

I am trying to plot multiple lines on a graph.

The function is particularly simple:

sigma<-function(lambda) atm-2*rr*(lambda-0.5)+16*str*(lambda-0.5)^2

which uses the variables atm, rr and str...

I define these as such:

atm<-0.4
rr<-0.2
str<-0.1


and this plots fine:

plot(seq(0.01,0.99,0.01),sigma(seq(0.01,0.99,0.01)),ylim=c(0,1))

Now, I want to plot the same function for different values of str, as follows:

sapply(seq(0,0.3,0.05),function(s) {str<-s; 
lines(seq(0.01,0.99,0.01),sigma(seq(0.01,0.99,0.01)))})

Hoping that sigma will lexically scope into str and that lines will appear on 
the same plot as the one I first drew above.

Instead, I just get this:
> sapply(seq(0,0.3,0.05),function(s) {str<-s; 
> lines(seq(0.01,0.99,0.01),sigma(seq(0.01,0.99,0.01)))})
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

[[4]]
NULL

[[5]]
NULL

[[6]]
NULL

[[7]]
NULL

and the plot does not change.

Any assistance appreciated.

Regards,
Tolga








This material is sales and trading commentary and does not constitute 
investment research.  Please follow the attached hyperlink to an important 
disclaimer http://www.csfb.com/legal_terms/disclaimer_europe.shtml



==============================================================================
Please access the attached hyperlink for an important electronic communications 
disclaimer: 

http://www.csfb.com/legal_terms/disclaimer_external_email.shtml

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to