francogrex wrote:
Hi, 2 questions:
Question 1: example of what I currently do:
for(i in 1:6){sink(temp.txt,append=TRUE)
dput(i+0)
sink()}
x=scan(file=temp.txt)
print(prod(x))
file.remove(C:/R-2.5.0/temp.txt)
But how to convert the output of the loop to a vector that I can manipulate
Hi, 2 questions:
Question 1: example of what I currently do:
for(i in 1:6){sink(temp.txt,append=TRUE)
dput(i+0)
sink()}
x=scan(file=temp.txt)
print(prod(x))
file.remove(C:/R-2.5.0/temp.txt)
But how to convert the output of the loop to a vector that I can manipulate
(by prod or sum etc),
for question 1, is this what you want (BTW allocate 'result' to the
size you want - the example keeps extending it which is OK for small
numbers, but for larger size preallocate):
result - numeric(0)
for (i in 1:6) result[i] - i
result
[1] 1 2 3 4 5 6
prod(result)
[1] 720
On 7/29/07,