Re: [R] Function output

2009-09-20 Thread David Winsemius
I think these examples will show what one can and cannot do with the invisible function. > f2 <- function(x,y) return(c(x, invisible(x^y)) ) > f2(2,2) [1] 2 4 #so that not the right way to keep tree hidden > f2 <- function(x,y) invisible(c(print(x),(x^y)) ) > f2(2,2) [1] 2 # success x^y

Re: [R] Function output

2009-09-20 Thread David Winsemius
On Sep 20, 2009, at 10:59 AM, manta wrote: Good afternoon, I know it is a simple question but I cannot figure out how to solve this issue. I have a function that calculate two objects. I would like to choose everytime about the tree object, with default to not show it. I cannot understand

[R] Function output

2009-09-20 Thread manta
Good afternoon, I know it is a simple question but I cannot figure out how to solve this issue. I have a function that calculate two objects. I would like to choose everytime about the tree object, with default to not show it. OP<-function(S=100,X,sigma,mu=0,r=0,time=1,n) { value=(S)

Re: [R] function output with for loop and if statement

2009-04-23 Thread Richard M. Heiberger
tmp.out.sort <- tmp.out[, order(names(tmp.out))] tmp.out.sort <- tmp.out[, order(names(tmp.out)), drop=FALSE] >From your description of misbehavior with a single column, I think the drop=FALSE argument will provide the protection you need. Then you will not need the if clause. See ?`[.data.fram

Re: [R] function output with for loop and if statement

2009-04-23 Thread aaron wells
Sedges Vascular > Subject: Re: [R] function output with for loop and if statement > From: gavin.simp...@ucl.ac.uk > To: awell...@hotmail.com > CC: r-help@r-project.org > Date: Thu, 23 Apr 2009 09:18:17 +0100 > > On Wed, 2009-04-22 at 15:51 -0400, aaron wells wrote: >>

Re: [R] function output with for loop and if statement

2009-04-23 Thread Gavin Simpson
: markle...@verizon.net > To: awell...@hotmail.com > Subject: Re: [R] function output with for loop and if statement > > Hi Aaron: i just looked quickly because I have to go but try wrapping braces > around the last if else like > below and see if that helps. if you have multiple st

Re: [R] function output with for loop and if statement

2009-04-23 Thread Gavin Simpson
On Wed, 2009-04-22 at 15:51 -0400, aaron wells wrote: > Hello all, turns out i'm having a bad R week. I am at my wits end > with a function that I am trying to write. When I run the lines of > code outside of a function, I get the desired output. When I wrap the > lines of code into a function i

Re: [R] function output with for loop and if statement

2009-04-22 Thread aaron wells
2009 15:24:24 -0500 From: markle...@verizon.net To: awell...@hotmail.com Subject: Re: [R] function output with for loop and if statement Hi Aaron: i just looked quickly because I have to go but try wrapping braces around the last if else like below and see if that helps. if you have multiple

[R] function output with for loop and if statement

2009-04-22 Thread aaron wells
Hello all, turns out i'm having a bad R week. I am at my wits end with a function that I am trying to write. When I run the lines of code outside of a function, I get the desired output. When I wrap the lines of code into a function it doesn't work as expected. Not sure what is going on her

Re: [R] Function output difficulties

2008-12-03 Thread Ted Harding
On 03-Dec-08 13:41:53, emj83 wrote: > is there anyway for some parts of the function output to not be > returned, even if the output has been used to calculate a further > part of the function? i have tried invisible() to no avail. > > Thanks Emma It's not clear what you mean by "some parts of th

[R] Function output difficulties

2008-12-03 Thread emj83
is there anyway for some parts of the function output to not be returned, even if the output has been used to calculate a further part of the function? i have tried invisible() to no avail. Thanks Emma -- View this message in context: http://www.nabble.com/Function-output-difficulties-tp2081311