Thanks for those who replied!
I found out the problem. I don't need the nested loop at all. The
following code would've worked (for those who're interested to know):
#
## Testing CLT. pp 281 of Chance Encounters
x - round(runif(1000, 1, 6))
clt - function(x, samp.no = 5, n = 5) {
samp -
Hi,
Apologies for such a trivial question, but it has been over two years since
I last used nested loops and I'm ashamed to say that I forgot how they work
*_*
Suppose I've the following codes:
#
x - round(runif(1000, 1, 6))
samp5 - vector(mode = list, length = 5)
for(i in 1:5) {
Here is an example:
for(i in 1:10) if (i %% 2) print(i) else print(even)
[1] 1
[1] even
[1] 3
[1] even
[1] 5
[1] even
[1] 7
[1] even
[1] 9
[1] even
Date: Sat, 21 Feb 2004 23:23:45 -0600
From: Sebastian Luque [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [R] nested loop
Hi all
On Sat, 21 Feb 2004 23:23:45 -0600, you wrote:
Hi all,
Does anybody know whether one can nest an 'if' statement in a 'for'
loop. According to the results of my code, the for loop is performed
first, but I'm not sure I got something else wrong with my code. I'm
trying to perform the if
Hi all,
Does anybody know whether one can nest an 'if' statement in a 'for'
loop. According to the results of my code, the for loop is performed
first, but I'm not sure I got something else wrong with my code. I'm
trying to perform the if statement for each step of the for loop. Thanks
in