2
We’re trying to use the command for
to run a y function (say y=5+3x+4z
) varying the values of z (let’s say z is a combination of 5 values z=c(1,2,3,4,5)
) and that x is a normal distribution of size 1000. After printing the values, which we use through indexing, how could we turn these results into an array of 1000 rows and 5 columns (1000 observations for each z value)?
After using the command for
:
z=c(1,2,3,4,5)
for(i in c(1,2,3,4,5)) print(y<-5+3x+4z[i]))
We tried to define a y matrix that does not work because it printed the first column in the other 4 remaining.
post the code you are using, and the expected result so we can help.
– djas
z=c(1,2,3,4,5)
y<-5+3x+4z
for(i in c(1,2,3,4,5)) print(matrix(5+3x+4z[i],100,5))
– felipe_Milla
x=c(1,2,3,4,5) z=c(1,2,3,4,5) for(i in 1:5) print(Matrix(5+3x+4z[i],100,5)) the expected result has to be a five-column matrix (each column for the 5 z’s) and 5 rows (each row for the 5 x’s).
– felipe_Milla