[R] Help with syntax error
Gavin Simpson
gavin.simpson at ucl.ac.uk
Mon Jun 15 20:08:36 CEST 2009
On Mon, 2009-06-15 at 10:54 -0700, Payam Minoofar wrote:
> Hi,
>
> I have written boxplot commands of this form before, but I don't quite
> understand why the function call is reporting a syntax error in this
> instance. All parameters passed to the function are strings.
You're not seeing the wood for the trees. You get a syntax while
defining the function. Hence there is an error in there and the function
definition fails, R then treats the next line (boxplot(.....) ) as being
a new statement and it complains about 'tframe' not being found -
presumably because there is no object in your global environment with
this name.
>
> Thanks in advance.
>
> Payam
>
> > simplevar <- function(wframe,column1,column2) {
> + tframe <- get(wframe)
> + x1 <- which(names(wframe)==column1)
> + x2 <- which(names(wframe)==column2)
> + print(tframe[x1])
> + print(tframe[x2])
> + gtitle <- paste(names(tframe[x2])," vs. ", names(tframe[x1])
^^^^^^^^
Look like you are missing a ")" at the end of the line above. You
haven't closed the call to paste()
> + quartz(width=7,height=5,dpi=200)
> Error: syntax error
> > boxplot(tframe[x2] ~ tframe[x1])
> Error in eval(expr, envir, enclos) : object 'tframe' not found
> >
> > }
I think you need to get a better R-aware editor that does bracket
matching as the above is easy to spot in such an environment.
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list