Skip to content
Prev 313056 / 398503 Next

What is "print print print" ?

On 12/06/2012 12:03 AM, Vladimir eremeev wrote:
Hi Vladimir,
Your problem is twofold. First, the print command simply tries to 
display whatever is passed as the first argument to it. Invoking:

print()

prints nothing, as there is nothing passed to display. Second, the print 
command is often used in R scripts because most functions will display 
their return values when invoked directly in the R console, but not when 
invoked within a "for" loop. The problem that you mentioned was due to 
the chisq.test function displaying its return value on its own, but not 
within the loop. The "print print print" comment was intended to mean:

print(rownames(cl.vs.Onerall)[i])
print(chisq.test(observed, p=expected.fr))
print("------------------------------")

in the loop so that the successive return values would be displayed. Try 
it for yourself with this simple example:

x<-1:5
length(x)
for(i in 1:3) length(x)
for(i in 1:3) print(length(x))

Jim