On 15/07/2011 1:44 PM, Bert Gunter wrote:
Below.
-- Bert
On Fri, Jul 15, 2011 at 10:31 AM, andrewH wrote:
> Thanks, everybody, this has been very edifying. One last question:
>
> It seems that sometimes when a function returns something and you don't
> assign it, it prints to the console, an
Below.
-- Bert
On Fri, Jul 15, 2011 at 10:31 AM, andrewH wrote:
> Thanks, everybody, this has been very edifying. One last question:
>
> It seems that sometimes when a function returns something and you don't
> assign it, it prints to the console, and sometimes it doesn't. I'm not sure
> I unders
On Jul 15, 2011, at 1:31 PM, andrewH wrote:
Thanks, everybody, this has been very edifying. One last question:
It seems that sometimes when a function returns something and you
don't
assign it, it prints to the console, and sometimes it doesn't. I'm
not sure
I understand which is which. My
Thanks, everybody, this has been very edifying. One last question:
It seems that sometimes when a function returns something and you don't
assign it, it prints to the console, and sometimes it doesn't. I'm not sure
I understand which is which. My best current theory is that, if the function
return
Folks: To thrash the dead horse a little more ...
> So, what about this one:
> GG<-c(1:4)
> testX3 <- function(X) {summary(X); return(str(X))}
> testX3(GG)
>
> int [1:4] 1 2 3 4
>
> I thought this was ignoring the summary() because it evaluates the return()
> first. If it does the return(str(X))
As long as you just want to display it, use print()
GG<- c(1,2,3)
print(summary(GG),str(GG))
Output:
num [1:3] 1 2 3
Min. 1st Qu. MedianMean 3rd Qu.Max.
1.0 1.5 2.0 2.0 2.5 3.0
HTH,
Daniel
andrewH wrote:
>
> Using str() in a function.
>
> I am in th
Dear Peter--
You write:
>>Andrew is being seriously confused. The return(ans) is of course executed
when you get to it, returning the value of `ans` and terminating the
function. Anything after that is _ignored_. There is no such thing as a
"previous return()" affecting what str() does -- that woul
On Jul 13, 2011, at 10:54 PM, andrewH wrote:
David -- Ah! Excellent. OK, that explains Dennis's function's output.
Print(str(X)) evaluates str(X), sending the usual str() output to the
console as a side effect, and then prints what str() returns, which
is NULL.
And invisible() prints NULL a
David -- Ah! Excellent. OK, that explains Dennis's function's output.
Print(str(X)) evaluates str(X), sending the usual str() output to the
console as a side effect, and then prints what str() returns, which is NULL.
And invisible() prints NULL again, but we don't see NULL NULL, because the
secon
On Jul 14, 2011, at 01:48 , David Winsemius wrote:
>
> On Jul 13, 2011, at 7:31 PM, andrewH wrote:
>
>> Thanks, David & Dennis, that is very helpful.
>>
>> Let me state what I think I have learned, to see if I understand it
>> correctly. Then I have two remaining questions.
>>
>> If a functio
On Jul 13, 2011, at 7:31 PM, andrewH wrote:
Thanks, David & Dennis, that is very helpful.
Let me state what I think I have learned, to see if I understand it
correctly. Then I have two remaining questions.
If a function contains more than one expression in its {}, it always
returns
the valu
Thanks, David & Dennis, that is very helpful.
Let me state what I think I have learned, to see if I understand it
correctly. Then I have two remaining questions.
If a function contains more than one expression in its {}, it always returns
the value of the last evaluated expression in its definiti
Hi:
Is this what you're after?
testX <- function(X) {
print(summary(X))
print(str(X))
invisible() # returns nothing
}
testX(1:10)
Min. 1st Qu. MedianMean 3rd Qu.Max.
1.003.255.505.507.75 10.00
int [1:10] 1 2 3 4 5 6 7 8 9 10
NULL
See inline..
On Jul 9, 2011, at 4:20 AM, andrewH wrote:
Using str() in a function.
I am in the early phase of learning R, and I find I spend a lot of
time
trying to figure out what is actually in objects I have created or
read in
from a file. I'm trying to make a simple little function to display a
c
Using str() in a function.
I am in the early phase of learning R, and I find I spend a lot of time
trying to figure out what is actually in objects I have created or read in
from a file. I'm trying to make a simple little function to display a
couple of things about a object, let's say the summar
15 matches
Mail list logo