[R] DEfining and plotting the sum of two functions

arun smartpink111 at yahoo.com
Mon May 20 15:53:43 CEST 2013

H<-function(x) H1(x)+H2(x)
[#1] 4
#[1] 7
#[1] 11


----- Original Message -----
From: Honest Chipoyera <Honest.Chipoyera at wits.ac.za>
To: "r-help at r-project.org" <r-help at r-project.org>
Sent: Monday, May 20, 2013 8:09 AM
Subject: [R] DEfining and plotting the sum of two functions

I have two functions H1(x) and H2(x) defined separately and I wish to create a new function H(x)  which is the sum of the two functions. I also need to plot the three functions using the command "curve". With the aid of the example program below, can you please explain how I can do that in R.

H1<-function(x) x^2
H2<-function(x) x+5

HW Chipoyera
Cell: 0767190507

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100%;">
<td align="left" style="text-align:justify;"><font face="arial,sans-serif" size="1" color="#999999"><span style="font-size:11px;">This communication is intended for the addressee only. It is confidential. If you have received this communication in error, please notify us immediately and destroy the original message. You may not copy or disseminate this communication without the permission of the University. Only authorised signatories are competent to enter into agreements on behalf of the University and recipients are thus advised that the content of this message may not be legally binding on the University and may contain the personal views and opinions of the author, which are not necessarily the views and opinions of The University of the Witwatersrand, Johannesburg. All agreements between the University and outsiders are subject to South African Law unless the University agrees in writing to the contrary. </span></font></td>

    [[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list