Forráskód Böngészése

Revert "Bug fixes"

This reverts commit 3cb49640503ebd741ae94e9369bda2b64422bda2.
Rens Zuurbier 9 éve
szülő
commit
ec71ecdaa3
3 módosított fájl, 7 hozzáadás és 21 törlés
  1. 1 0
      code/functions.R
  2. 1 3
      code/head.R
  3. 5 18
      code/state.R

+ 1 - 0
code/functions.R

@@ -46,6 +46,7 @@ group <- function(a, n=1){
       }
       cur_ <- cur_ + 1
     }
+    #for(i in 1:length(l_))
     names(l_) <- LETTERS[1:length(l_)]
     remove(cur_)
     return(l_)

+ 1 - 3
code/head.R

@@ -10,7 +10,7 @@ plot(DATA$Head.y,
 for(i in 1:nrow(DATA)){
   points(i, DATA[i,]$Head.y, col = color[DATA[i,]$state])
 }
-remove(i)
+
 
 #Check if patient is walking fast enough
 differ_ <- 0.5
@@ -29,8 +29,6 @@ for(i in patient$WALKING){
    prob_ <- 1 - abs((abs(DATA[i,]$Head.y - f(i))) / differ_)
    WALK[WALK$index==i,]$probability <- if(prob_ > 1) 1 else if(prob_ < 0) 0 else prob_
 }
-remove(i)
-remove(prob_)
 
 # Print out possible fall chance
 print(paste("FALL CHANCE BASED ON STEPS: ", as.character(specify_decimal(100-(mean(WALK$probability)*100), 2)), "%", sep = ""))

+ 5 - 18
code/state.R

@@ -41,7 +41,6 @@ for(i in size_:(nrow(DATA)-size_)){
     POINTS[i-j,LETTERS[j+1]] <- state_
   }
   POINTS[i,]$index <- DATA[i,]$Time
-  remove(j)
 
   if(i>size_*2 && i<=((nrow(DATA) - size_))){
     tmp_ <- (
@@ -60,32 +59,25 @@ for(i in size_:(nrow(DATA)-size_)){
   }
   DATA[i,]$state = state_
 }
+print("STATE CALCULATION DONE")
 remove(tmp_)
-remove(state_)
-remove(i)
-remove(start)
-remove(end)
-
 DATA <- DATA[complete.cases(DATA),]
 rownames(DATA) <- 1:nrow(DATA)
 DATA$index = as.integer(rownames(DATA))
 
-print("STATE CALCULATION DONE")
-
 # USE PATIENT ENVIRONMENT
 source("code/patient.R")
 
-patient$WALKING <- group(strtoi(rownames(DATA[DATA$state==1,])), 10)
+patient$WALKING <- strtoi(rownames(DATA[DATA$state==1,]))
 patient$SITTING <- group(strtoi(rownames(DATA[DATA$state==4,])), 10)
-patient$UP <- group(strtoi(rownames(DATA[DATA$state==2,])), 5)
-patient$DOWN <- group(strtoi(rownames(DATA[DATA$state==3,])), 5)
+patient$UP <- strtoi(rownames(DATA[DATA$state==2,]))
+patient$DOWN <- strtoi(rownames(DATA[DATA$state==3,]))
 
 patient$SITBASE <- mean(c(DATA[as.integer(unlist(patient$SITTING)),]$FootLeft.y, DATA[as.integer(unlist(patient$SITTING)),]$FootRight.y))
 
-if(!consistent(as.integer(unlist(patient$WALKING)))){
+if(!consistent(patient$WALKING)){
   stop("Patient not consistently walking, (Maybe he/she fell). Anyway, we can't analyse this data", call. = FALSE)
 }
-patient$WALKING <- as.integer(unlist(patient$WALKING))
 
 # CALCULATE STRAIGHT WALKING PATH
 yPrediction <-lm(Head.y ~ I(index^2)+index, data=DATA[min(patient$WALKING):max(patient$WALKING),])
@@ -99,10 +91,5 @@ for(i in patient$WALKING[1]:(length(patient$WALKING) + patient$WALKING[1] - 1)){
 
 plot(POINTS$probability, type = "l")
 
-remove(yPrediction)
-remove(yPredicted)
-
-print("FILLING PATIENT CLASS DONE")
-
 # http://stats.stackexchange.com/questions/30975/how-to-add-non-linear-trend-line-to-a-scatter-plot-in-r
 # http://www.mathsisfun.com/geometry/parabola.html