2
0

ankle.R 2.2 KB

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