Expand grid with an ordered pair and a third variable in R -
i have been trying generate combinations of ordered pair of variables third variable, combine every pair (z1, z2) below z3.
theta <- seq(0, 2*pi, length = 5) z1 <- cos(theta) ;z2 <- sin(theta) z3 <- seq(-3, 3, length = 5)
i use expand.grid
function here not appropriate generate combinations of 3 variables destroying ordering. wondering, there function in r can this? appreciated, thank you.
we paste
'z1' , 'z2' , expand.grid
'z3'. output ('d1'), split 'var1' i.e. paste
d vectors 2 columns.
d1 <- expand.grid(paste(z1,z2), z3) transform(read.table(text=as.character(d1$var1), header=false), v3= d1$var2)
Comments
Post a Comment