r - Binding Replicate Rows to a Dataframe -
can improve on following code?
a <- b <- c <- c(-1,1) # factorial design design <- expand.grid(a=a, b=b,c=c) # factorial design design <- rbind(design, c(0,0,0),c(0,0,0),c(0,0,0)) # centre points added design i want last line more succinct.
when tried rbind(design, matrix(0,3,3)) code crashed. col names matrix , design different causing problems. when tried rbind(design, rep(c(0,0,0),3)) got 1 row appended rather three.
this question kindly answered @lyzander above
rbind(design, 0, 0, 0) which works recycling each of values each of rows.
hence,
a <- b <- c <- c(-1,1) # factorial design design <- expand.grid(a=a, b=b,c=c) # factorial design design <- rbind(design,0,0,0) # centre points added design
Comments
Post a Comment