2
0

ankle.R 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. plot(DATA[patient$WALKING,]$AnkleLeft.y,
  2. type = "l",
  3. ylab = "Hoogte",
  4. col = ifelse(DATA$AnkleLeft.y > -1.1, "green", "red"),
  5. ylim = c(-1.15, -0.9)
  6. )
  7. par(new=TRUE)
  8. plot(DATA[patient$WALKING,]$AnkleRight.y,
  9. type = "l",
  10. ylab = "Hoogte",
  11. col = ifelse(DATA$AnkleRight.y > -1.1, "blue", "purple"),
  12. ylim = c(-1.15, -0.9)
  13. )
  14. #Calculates the mean height of AnkleLeft.y
  15. meanLine <- mean(DATA[patient$WALKING,]$AnkleLeft.y)
  16. ##-LEFT-##
  17. #Creates vector which contains the values above the mean height (1e quarter)
  18. Q1 <- NULL
  19. for(i in patient$WALKING){
  20. if (DATA[i,]$AnkleLeft.y > meanLine){
  21. Q1 <- c(Q1, DATA[i,]$AnkleLeft.y)
  22. }
  23. }
  24. #Gives the mean value of the first quarter
  25. meanQ1 <- mean(Q1)
  26. #Creates vector which containts the values under the mean height value (3e quarter)
  27. Q3 <- NULL
  28. for(i in patient$WALKING){
  29. if(DATA[i,]$AnkleLeft.y < meanLine){
  30. Q3 <- c(Q3, DATA[i,]$AnkleLeft.y)
  31. }
  32. }
  33. #Gives the mean value of the third quarter
  34. meanQ3 <- mean(Q3)
  35. DiffAnkleLeft <- abs(meanQ3 - meanQ1)
  36. ##-RIGHT-##
  37. #Creates vector which contains the values above the mean height (1e quarter)
  38. Q1 <- NULL
  39. for(i in patient$WALKING){
  40. if(DATA[i,]$AnkleRight.y > meanLine){
  41. Q1 <- c(Q1, DATA[i,]$AnkleRight.y)
  42. }
  43. }
  44. #Gives the mean value of the first quarter
  45. meanQ1 <- mean(Q1)
  46. #Creates vector which contains the values above the mean height (3e quarter)
  47. Q3 <- NULL
  48. for(i in patient$WALKING){
  49. if(DATA[i,]$AnkleRight.y < meanLine){
  50. Q3 <- c(Q3, DATA[i,]$AnkleRight.y)
  51. }
  52. }
  53. #Gives the mean value of the third quarter, And the difference
  54. meanQ3 <- mean(Q3)
  55. DiffAnkleRight <- abs(meanQ3 - meanQ1)
  56. DiffAnkleLeft
  57. DiffAnkleRight
  58. if(DiffAnkleLeft < 0.05 || DiffAnkleRight < 0.05){
  59. print("The patient barely lift his foot up, there is a potentional falling risk")
  60. }else {
  61. print("The patient walks just fine according his ankles")
  62. }
  63. #Creates Smoothline of the left ankle
  64. SmoothAnkleLeft <- smooth.spline(DATA[patient$WALKING,]$AnkleLeft.y, spar=0.35)
  65. plot(SmoothAnkleLeft, col = "green",
  66. type = "l",
  67. ylim = c(-1.17, -0.9),
  68. ylab = "Hoogte",
  69. xlab = "Index")
  70. par(new=TRUE)
  71. SmoothAnkleRight <- smooth.spline(DATA[patient$WALKING,]$AnkleRight.y, spar=0.35)
  72. plot(SmoothAnkleRight, col = "blue",
  73. type = "l",
  74. ylim = c(-1.17, -0.9),
  75. ylab = "Hoogte",
  76. xlab = "Index")