[R] plot a function with a vector as argument

From: chaij <azraelchai_at_hotmail.com>
Date: Sat, 17 May 2008 20:54:31 -0700 (PDT)

I tried to define a function using another function I defined before, and the previous function has a vector as an argument, when I tried to get the graph of the new function, there was something going wrong. Here is a simple example to explain how it happend:

 fr1 <- function(x,y){

 fr2 <- function(x){


In this case, it worked just fine. But when I changed it to the following form:

Fr1 <- function(x){
 x1 <- x[1]
 x2 <- x[2]


 Fr2 <- function(x){

it gives:
Error in xy.coords(x, y, xlabel, ylabel, log) :   'x' and 'y' lengths differ

Could anyone help me with this problem? Thanks.

View this message in context: http://www.nabble.com/plot-a-function-with-a-vector-as-argument-tp17299015p17299015.html
Sent from the R help mailing list archive at Nabble.com.

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.
Received on Sun 18 May 2008 - 07:36:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 18 May 2008 - 14:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive