head.R 769 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #color <- rainbow(length(STATE))
  2. color <- c("red", "blue", "blue", "green")
  3. #Plot graph
  4. plot(DATA$Head.y,
  5. type = "l",
  6. ylab = "Hoogte hoofd"
  7. )
  8. for(i in 1:nrow(DATA)){
  9. print(i)
  10. points(i, DATA[i,]$Head.y, col = color[DATA[i,]$state])
  11. }
  12. #Check if patient is walking straight enough
  13. differ_ <- 0.4
  14. WALKING <- strtoi(rownames(DATA[DATA$state==1,]))
  15. start <- min(WALKING)
  16. stop <- max(WALKING)
  17. segments(start, mean(c(DATA[start,]$Head.y, DATA[stop,]$Head.y)), stop, col = "black")
  18. base <- mean(c(DATA[start,]$Head.y, DATA[stop,]$Head.y))
  19. size_ <- 7
  20. for(i in seq(start, stop, size_)){
  21. step <- mean(DATA[i:(i+size_),]$Head.y) - base
  22. for(j in 0:(size_ -1)){
  23. if(DATA[i+j,]$state != 1) next
  24. points(i+j, DATA[i+j,]$Head.y - step, p = "*")
  25. }
  26. }