Re: [R] plotting a function with given formula in ggplot2

2011-11-10 Thread Dennis Murphy
Hi: Borrowing from this thread, courtesy of Brian Diggs: http://groups.google.com/group/ggplot2/browse_thread/thread/478f9e61d41b4678/ed323c497db61156?lnk=gst&q=stat_function#ed323c497db61156 ...here's a small reproducible example: ddf <- data.frame(x = 1:10, y = 0.4 + 0.6 * (1:10) + rnorm(10))

Re: [R] plotting a function with given formula in ggplot2

2011-11-10 Thread Curiouslearn
Thanks Rainer. I did not know about dput(). Here is the data. mom_hs <- c(1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,

Re: [R] Plotting a function that includes logical operators

2011-07-27 Thread Duncan Murdoch
On 27/07/2011 9:21 AM, dean123 wrote: Hi David, I am trying to define t as a single numeric value and not as a vector.. I want the function to realise that if I call test(t) and t is less than equal 10 return zero, if t greater than 10 return 2*t. Am i missing some code in which to define t a nu

Re: [R] Plotting a function that includes logical operators

2011-07-27 Thread dean123
Hi David, I am trying to define t as a single numeric value and not as a vector.. I want the function to realise that if I call test(t) and t is less than equal 10 return zero, if t greater than 10 return 2*t. Am i missing some code in which to define t a numeric value instead of a vector? Also,

Re: [R] Plotting a function that includes logical operators

2011-07-27 Thread David Winsemius
On Jul 27, 2011, at 3:01 AM, dean123 wrote: I am trying to plot the following function over the range 0-100 test <- function(t){{ if (t<=10) x<-t*0 else x<-2*t } x } Two problems I see. The first is the one described fairly clearly by the error message: Read: ?"if" It is not designed

Re: [R] plotting a function

2010-03-31 Thread Francisco J. Zagmutt
Take a look at the examples in ?curve. As suggested by Erik, in the future please read the posting guide so you can get a more accurate response. Regards, Francisco Dr. Francisco J. Zagmutt Vose Consulting 1643 Spruce St., Boulder Boulder, CO, 80302 USA www.voseconsulting.com Jin wrote: He

Re: [R] plotting a function

2010-03-31 Thread Erik Iverson
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Jin wrote: Hello Dear, I am trying to plot a function to see a minimum point (actually, using "optim"). For example, 1. y=f(x) 2. x has a range 3. pl

Re: [R] Plotting a function with a histogram

2008-05-09 Thread Amit Soni
Thank you for your replies. I figured out that curve has an option of add which adds it to a previously existing graph. Thank you, Amit On Fri, May 9, 2008 at 10:07 AM, Amit Soni <[EMAIL PROTECTED]> wrote: > Hi, > > I have a histogram of an array of numbers. > hist(v,10) > > How can I plot a fun