Message-ID: <E41AF724-E41F-45F3-8ED9-7B13C3420C3F@comcast.net>
Date: 2009-05-02T14:33:23Z
From: David Winsemius
Subject: print value of variable to screen or alert box?
In-Reply-To: <23345523.post@talk.nabble.com>
On May 2, 2009, at 7:59 AM, onyourmark wrote:
>
> I am trying to debug a loop. Is there a way to print the value of a
> variable
> that is inside a loop? I have a vector v and inside a loop I have
> v[i] where
> i is the index of the loop. Is there a way to see v[i] per loop so
> that I
> can see what is going on?
> Thanks
> --
> v <- vector()
> for (i in 1:5) { v[i] <- i^2; print(v[i])}
[1] 1
[1] 4
[1] 9
[1] 16
[1] 25
> for (i in 1:5) { v[i] <- i^2; print(paste(i, " squared = ", v[i]))}
[1] "1 squared = 1"
[1] "2 squared = 4"
[1] "3 squared = 9"
[1] "4 squared = 16"
[1] "5 squared = 25"
David Winsemius, MD
Heritage Laboratories
West Hartford, CT