Procházet zdrojové kódy

Worked on the mean high and the low mean of the left ankle height + created smooth lines for both of the ankles

Rens Zuurbier před 9 roky
rodič
revize
1e7aa55472
1 změnil soubory, kde provedl 49 přidání a 22 odebrání
  1. 49 22
      code/ankle.R

+ 49 - 22
code/ankle.R

@@ -3,32 +3,24 @@
 #  DATA$AnkleLeft.y + 1.1
 #}
 
-lowestLeft <- min(DATA$AnkleLeft.y)
-lowestRight <- min(DATA$AnkleRight.y)
-
-highestLeft <- max(DATA$AnkleLeft.y)
-highestRight <- max(DATA$AnkleRight.y)
-
-VerschilLeft <- (lowestLeft - highestLeft)
-VerschilRight <- (lowestRight - highestRight)
-
-plot(DATA$AnkleLeft.y,
+plot(DATA[patient$WALKING,]$AnkleLeft.y,
      type = "l",
-     ylab = "Hoogte...",
+     ylab = "Hoogte",
      col = ifelse(DATA$AnkleLeft.y > -1.1, "green", "red"),
      ylim = c(-1.15, -0.9)
 )
 par(new=TRUE)
-plot(DATA$AnkleRight.y,
-     type = "p",
+plot(DATA[patient$WALKING,]$AnkleRight.y,
+     type = "l",
      ylab = "Hoogte",
      col = ifelse(DATA$AnkleRight.y > -1.1, "orange", "purple"),
-     ylim = c(-1.15, 0)
+     ylim = c(-1.15, -0.9)
 )
 
 #Calculates the mean height of AnkleLeft.y
 meanLine <- mean(DATA[patient$WALKING,]$AnkleLeft.y)
 
+##-LEFT-##
 #Creates vector which contains the values above the mean height (1e quarter)
 Q1 <- c()
 for(i in patient$WALKING){
@@ -41,22 +33,57 @@ for(i in patient$WALKING){
 meanQ1 <- mean(Q1)
 
 #Creates vector which containts the values under the mean height value (3e quarter)
-Q2 <- c()
+Q3 <- c()
 for(i in patient$WALKING){
   if(DATA[i,]$AnkleLeft.y < meanLine){
-    Q2 <- c(Q2, DATA[i,]$AnkleLeft.y)
+    Q3 <- c(Q3, DATA[i,]$AnkleLeft.y)
   }
 }
 
 #Gives the mean value of the third quarter
-meanQ2 <- mean(Q2)
+meanQ3 <- mean(Q3)
 
-meanQ1
-meanQ2
-DifferenceAnkleLeft <- meanQ2 - meanQ1
-remove(i)
+DiffAnkleLeft <- abs(meanQ3 - meanQ1)
 
 
+##-RIGHT-##
+#Creates vector which contains the values above the mean height (1e quarter)
+Q1 <- C()
+for(i in patient$WALKING){
+  if(DATA[i,]$AnkleRight.y > meanLine){
+    Q1 <- c(Q1, DATA[i,]$AnkleRight.y)
+  }
+}
+
+#Gives the mean value of the first quarter
+meanQ1 <- mean(Q1)
+
+#Creates vector which contains the values above the mean height (3e quarter)
+Q3 <- c()
+for(i in patient$WALKING){
+  if(DATA[i,]$AnkleRight.y < meanLine){
+    Q3 <- c(Q3, DATA[i,]$AnkleRight.y)
+  }
+}
+
+#Gives the mean value of the third quarter, And the difference
+meanQ3 <- mean(Q3)
+
+DiffAnkleRight <- abs(meanQ3 - meanQ1)
+
+DiffAnkleLeft
+DiffAnkleRight
+
+if(DiffAnkleLeft < 0.05 || DiffAnkleRight < 0.05){
+  print("The patient barely lift his foot up, there is a potentional falling risk")
+}
+else {
+  print("The patient walks just fine according his ankles")
+  }
+
 #Creates Smoothline of the left ankle
 SmoothAnkleLeft <- smooth.spline(DATA[patient$WALKING,]$AnkleLeft.y, spar=0.35)
-lines(SmoothAnkleLeft)
+lines(SmoothAnkleLeft, col = "green")
+
+SmoothAnkleRight <- smooth.spline(DATA[patient$WALKING,]$AnkleRight.y, spar=0.35)
+lines(SmoothAnkleRight, col = "purple")