[R] print(cat(bleh)) shows up strange NULL
Dan Bolser
dmb at mrc-dunn.cam.ac.uk
Tue Jan 4 23:44:30 CET 2005
On 4 Jan 2005, Peter Dalgaard wrote:
>Dan Bolser <dmb at mrc-dunn.cam.ac.uk> writes:
>
>> I am trying the following code...
>>
>> for(i in 1:bins){
>> print(cat(c(i, length(var1[var1==i]))))
>> }
>>
>> Where var1 is a vector with zero or more values = {1, 2, ..., bins} (or
>> something like that).
>>
>> The result I get is...
>>
>> 1 33NULL
>> 2 28NULL
>............
>> 19 0NULL
>> 20 3NULL
>>
>> I don't know what I am doing to get those stray NULL characters printed.
>
>You're printing them, will you believe it...?
>
>Consider this:
>
>> x <- cat("abc")
>abc> print(x)
>NULL
>> x
>NULL
>> print(cat("abc"))
>abcNULL
>
>I.e. cat() always returns NULL, invisibly unless you force it to be
>printed.
never trust a cat!
>
>
>
More information about the R-help
mailing list