#title Angle {{{ 기준치 z = (값 - 평균) / 표준편차 편차치 t = 10z +50 -> 편차치로 Slope를 구한다음 각도 = ATan(Slope) * 180/Pie; }}} x의 길이가 36, y 길이가 3이라면 {{{ angle <- atan(3/36) * (180/pi) }}} --https://stackoverflow.com/questions/1897704/angle-between-two-vectors-in-r 두 백터 {{{ angle <- function(x,y){ dot.prod <- x%*%y norm.x <- norm(x,type="2") norm.y <- norm(y,type="2") theta <- acos(dot.prod / (norm.x * norm.y)) as.numeric(theta) } x <- as.matrix(c(2,1)) y <- as.matrix(c(1,2)) angle(t(x),y) # Use of transpose to make vectors (matrices) conformable. [1] 0.6435011 }}} ==== slope to angle ==== regression 결과가 이렇다면.. {{{ x <- (1:length(y)) * (max(y) - min(y)) / length(y) m <- lm(y~x) pred <- predict(m, newdata=data.frame(x,y), interval = "predict", level=.9) agl <- atan(coef(m)[2]) * (180/pi) }}} {{{ A <- c(1,2,3,4,5) B <- c(6,7,8,9,10) acos(sum(A*B) / (sqrt(sum(A^2)) * sqrt(sum(B^2)))) * (180/pi) }}}