I believe this may be straightforward, but I have been trying to figure this out for hours. The printed output is how I would like my vector. It is doing exactly what I want.
x1<-c(1,2,3,4)
x2<-c(1,0)
len<- length(filename)
output <- vector("numeric", 8)
for (i in x1){
for(j in x2){
print(sum(i+j))
output[i]<- i
}
}
output
But, I am confused as to why I get these two different results:
[1] 2
[1] 1
[1] 3
[1] 2
[1] 4
[1] 3
[1] 5
[1] 4
> output
[1] 1 2 3 4 0 0 0 0
How do I store the print results as a vector? Thanks.