Aimee Jones
2011-Jul-22 22:50 UTC
[R] Plotting compound functions--help with defining x-axis as f(x)
Hi all, I'm having trouble locating a script that will allow to me to create graphs that show compound functions as a function of the simple function, rather than just x (or time as it is in my case). Currently I have the following functions defined in my script:> > > T1<-function(t) {27.5-12.5*cos(2*pi*t/365)**} > and > > B1<-function(T1,t) {dnorm(T1(t),mean=22.5,sd=**3.3)} >plot(function(t) {B1(T1,t)}, 0, 365) plots B1 as a function of time, whereas I am looking for a code that allows me to plot B1 as a function of T1. I tried plot(function(T1(t) {B1(T1,t)}, 0, 365) and also plot(function(T1,t) {B1(T1,t)}, 0, 365), neither of which worked. My coding skills are very limited, and I'm somewhat out of ideas.. Thank you for any assistance you are able to give, yours sincerely, Aimee ps: If it's relevant I'm using R64 (R 2.11.1) on a Mac [[alternative HTML version deleted]]
Uwe Ligges
2011-Jul-24 15:52 UTC
[R] Plotting compound functions--help with defining x-axis as f(x)
On 23.07.2011 00:50, Aimee Jones wrote:> Hi all, > I'm having trouble locating a script that will allow to me to create graphs > that show compound functions as a function of the simple function, rather > than just x (or time as it is in my case). > > Currently I have the following functions defined in my script: > >> >> >> T1<-function(t) {27.5-12.5*cos(2*pi*t/365)**}This is not syntactically correct. Perhaps some leftovers of your html message. The posting guide asks you *not* to send html mail!>> and >> >> B1<-function(T1,t) {dnorm(T1(t),mean=22.5,sd=**3.3)} >> > > > > plot(function(t) {B1(T1,t)}, 0, 365) plots B1 as a function of time, whereas > I am looking for a code that allows me to plot B1 as a function of T1. I > tried plot(function(T1(t) {B1(T1,t)}, 0, 365) and also plot(function(T1,t) > {B1(T1,t)}, 0, 365), neither of which worked. My coding skills are very > limited, and I'm somewhat out of ideas..So you probably want something along the lines: t <- seq(0, 365, length=1000) plot(T1(t), B1(T1, t), type="l") Uwe Ligges> > Thank you for any assistance you are able to give, > yours sincerely, > Aimee > > ps: If it's relevant I'm using R64 (R 2.11.1) on a Mac > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.