[R] for loop not working
mnw
maw90 at aber.ac.uk
Tue Oct 13 11:35:16 CEST 2015
Thank you for your comments. I guess what I need is to store movements and
then loop through that matrix. Here is a snippet of the 'movement' code. I
am trying to fill the matrix below with data from this loop. Is there
something else my matrix (bottom) requires? Or its positioning?
Many thanks,
# determine whether movement is occurring and if so what type
# if there are insufficient history items then just record movement types
discretely
if (i < historyLength) movement <- movementType(relAngle, angleThreshold)
else if (i > historyLength-1) {
# Array to store speeds
speedHistory <- array(historyLength)
n = historyLength-1
# get the speeds from the previous n (hisoryLength) "Movements"
for (j in seq(1, length(historyLength))){
speedHistory [n] = R[i-j, 6]
n-1
}
if (!bayesFilter(speedHistory, minSpeed, GPS_accy)) movement <-
"non-moving"
else if(bayesFilter(speedHistory, minSpeed, GPS_accy)) movement <-
movementType(relAngle, angleThreshold)
holder <- matrix(data = movement, nrow = nrow(R), ncol = 1)
}
--
View this message in context: http://r.789695.n4.nabble.com/for-loop-not-working-tp4713392p4713525.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list