[chronojump] Added Force / Velocity fitted formula



commit a6821d00eaf43a9c8f0143309c33094a27d01167
Author: Xavier Padullés <x padulles gmail com>
Date:   Tue Sep 4 12:43:43 2018 +0200

    Added Force / Velocity fitted formula

 encoder/graph.R | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index f05955e7..9b14987a 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -1939,8 +1939,8 @@ paintCrossVariables <- function (paf, varX, varY, option,
                                                 round.scientific(coef.b), " · ", varXplot, " ", 
plotSign(coef.c), " ", 
                                                 round.scientific(coef.c), sep=""), side=3, line=1, 
at=functionAt, adj=functionAdj, cex = .9)
                                         mtext(paste(
-                                                "R² = ", round(summary(fit)$r.squared,4),
-                                                "; R² (adjusted) = ", round(summary(fit)$adj.r.squared,4),
+                                                "R^2 = ", round(summary(fit)$r.squared,4),
+                                                "; R^2 (adjusted) = ", round(summary(fit)$adj.r.squared,4),
                                                 "; p = ", getModelPValueWithStars(fit)
                                                 , sep=""), side =3, line=0, at=functionAt, adj=functionAdj, 
cex=.9)
                                         #end of plot the function expression, R^2 and p
@@ -2010,6 +2010,21 @@ paintCrossVariables <- function (paf, varX, varY, option,
                                         
                                         fitLine(x,y, "black", 1, 1)
                                         
+                                        #Display formula of the Force / Load fitted line
+                                        if((varX == "Load" || varX == "Inertia") && varY == "Force")
+                                        {
+                                                fit = lm(y ~ x)
+                                                mtext(side = 3, line = 1,
+                                                      text = paste("Force = ", round(fit$coefficients[2], 
digits = 3),
+                                                                   "·Load +  " , round(fit$coefficients[1], 
digits = 3), sep = ""),
+                                                      at = max(x), adj = 1, cex = 1.2)
+                                                mtext(paste(
+                                                        "R^2 = ", round(summary(fit)$r.squared,4),
+                                                        "; R^2 (adjusted) = ", 
round(summary(fit)$adj.r.squared,4),
+                                                        "; p = ", getModelPValueWithStars(fit)
+                                                        , sep=""), side =3, line=0, at = max(x), adj = 1, 
cex=.9)
+                                        }
+                                        
                                         #Draw the power parabole
                                         if(varX == "Speed" && varY == "Force") #is "Force,Power" but using 
Force to have less problems
                                         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]