2
0

ankle.R 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. library(dplyr)
  2. WD <- getwd()
  3. CSV <- file.choose()
  4. CSV <- read.csv(CSV)
  5. # CONVERT
  6. converted_ <- NULL
  7. for(i in 1:(nrow(CSV) / 3)) {
  8. x <- NULL
  9. y <- NULL
  10. z <- NULL
  11. if(i > 1) { i <- i * 3 - 2 }
  12. x <- CSV[i,]
  13. y <- CSV[i+1,]
  14. z <- CSV[i+2,]
  15. #print(i)
  16. cnv_ <- merge(x, y, all = TRUE, suffixes = c(".x", ".y"), by = "Time")
  17. cnv_ <- merge(cnv_, z, all = TRUE, suffixes = c("", ".z"), by = "Time")
  18. if(i == 1) {
  19. #print("CREATE")
  20. converted_ <- cnv_
  21. }
  22. else {
  23. #print("BIND")
  24. converted_ <- bind_rows(converted_, cnv_)
  25. }
  26. }
  27. # For loop to add 1.1m to all the data of AnkleLeft.y to determine real height.
  28. #for (j in 1:(nrow(converted_))) {
  29. # converted_$AnkleLeft.y + 1.1
  30. #}
  31. lowestLeft <- min(converted_$AnkleLeft.y)
  32. lowestRight <- min(converted_$AnkleRight.y)
  33. highestLeft <- max(converted_$AnkleLeft.y)
  34. highestRight <- max(converted_$AnkleRight.y)
  35. VerschilLeft <- (lowestLeft - highestLeft)
  36. VerschilRight <- (lowestRight - highestRight)
  37. plot(converted_$AnkleLeft.y,
  38. type = "l",
  39. ylab = "Hoogte...",
  40. col = ifelse(converted_$AnkleLeft.y > -1.1, "green", "red"),
  41. ylim = c(-1.20, -0.8)
  42. )
  43. par(new=TRUE)
  44. plot(converted_$AnkleRight.y,
  45. type = "l",
  46. ylab = "Hoogte",
  47. col = ifelse(converted_$AnkleRight.y > -1.1, "orange", "purple"),
  48. ylim = c(-1.20, -0.8)
  49. )
  50. par(new=TRUE)
  51. plot(converted_$Head.y,
  52. type = "l",
  53. ylab = "Hoogte in M",
  54. col = "blue",
  55. ylim = c(-1.20, 0.70)
  56. )