Displaying 1 result from an estimated 1 matches for "ezample".
Did you mean:
example
2003 Aug 13
2
putting NAs at the end
...ave a matrix for which each row has 12 elements that represent the xyz coordinates of 4 points.
So each row of M is (x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4). Some points have NA as z values.
I want another matrix to be the same as M but with the coordinates of those points with z=NA placed last.
For ezample if z1=NA then the new matrix row should be (x2,y2,z2,x3,y3,z3,x4,y4,z4,x1,y1,z1)
I've tried writing a function that does the job for each row and then apply to the matrix
Put.NaN.last<-function(p) {
Index<-c(which(!is.na(p[c(3,6,9,12)]))*3,which(is.na(p[c(3,6,9,12)]))*3)
p<-c(p[Index...