Hello R users, I am trying to make a baricentric diagram like the ternary plot, but with 4 edges. I want to know how to calculate the centroid of the diamond. The 4 edges are A, B, C, D. If value of A=B=C=D, then the point should be at the centre of the diamond. If A>B and B=C=D=0, Then the point should be at the corner of A.
For diamond, how to convert the value of A,B,C,D into cartesian co-ordinates ?. if x1,x2,y1,y2 are A,B,C,D, then someone suggested: new_point <- function(x1, x2, y1, y2, grad=1.73206){ b1 <- y1-(grad*x1) b2 <- y2-(-grad*x2) M <- matrix(c(grad, -grad, -1,-1), ncol=2) intercepts <- as.matrix(c(b1,b2)) t_mat <- -solve(M) %*% intercepts data.frame(x=t_mat[1,1], y=t_mat[2,1]) } But this is not working. Please do suggest some help. thanks and best regards, Alaguraj.V [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.