I'm sure this is a simple one. I have two vectors 'd' and 'r'. I would like to calculate t=(d+r)/d for all combinations of d and r. Thus, I would like to end up with a matrix where t is calculated for each d using each value of r.
Output should look something like this: https://www.dropbox.com/s/hf74s4jz2qe3st7/table.jpg?dl=0
I've tried a for
loop and also looked at apply
but so far unsuccessfully.
I hope someone can help.
EDIT: This is the for
loop i tried:
t<-matrix(nrow=length(d), ncol=length(r))
for(i in 1:length(r)){
t[i]=(d+r[i])d
}
didn't work :(