Aimee Jones wrote: > > Hi all, > My apologies if this message is incredibly inept but I am very new to both > computer programming and to R. > > I am working with the odesolve add-on and have the following function > defined > > RVF_Single <- function(t, x, p) > within the script I also have the following functions defined: > > T1<-function(t) {T1<-27.5-12.5*cos(2*pi*t/365)} > and > > B1<-function(T1,t) {B1<-dnorm(T1(t),mean=22.5,sd=3.3)} > > When the script is run it doesn't return an error message but the graphs > returned are "wrong". When I input "plot(T1,0,3650)" it returns the plot > of > T1 as expected---a series of waves between 15 and 40, BUT when I input > "plot(B1,0,3650)" I get an error message of "Error in 2 * pi * t : 't' is > missing". > > Can anyone advise as to why t registers for function T1 but disappears for > function B1? >
Because B1 is a function with 2 arguments. plot calls B1 with 1 argument, which will be argument T1. So t is missing since it hasn't received a value. Redefine B1 as B1<-function(t) {B1<-dnorm(T1(t),mean=22.5,sd=3.3)} and you will get your plot. Berend -- View this message in context: http://r.789695.n4.nabble.com/Trouble-with-compound-functions-differential-equations-tp3601070p3601403.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.