0
我試圖從以前估計的位置繪製的速度矢量中均衡加速度。問題是,我不知道這是否與函數中的另一種函數內部爲以下形式:如何調用其他函數內部的函數
SpeedReckon <- function(trip)
{
speed=3.6*sqrt(diff(trip$x,1,1)^2+diff(trip$y,1,1)^2)
return(speed)
}
Acceleration <- function(speed){
acceleration = cbind(positive,negative) #separation between positive acceleration and negative I want to create a variable with two features (positive and negative -> like a list
acc = diff(speed) # vector with accelerations
i=1
while (i<=length(acc)) #classify positive and negative
{
j=1
if(acc[i]<0)
{
while(positive[j]!=NULL){ # I do this in order to add the values in the last space, I don't know if it is necessary
j=j+1
}
positive[j] <- acc[i]
}
else{
while(negative[j]!=NULL){
j=j+1
}
negative[j] <- acc[i]
}
i=i+1
}
return (acceleration)
}
從上面的代碼沒有找到acceleration
功能,所以我想我不會調用function
正常。這裏是function
電話:
trip = read.csv(paste0(dirPath,i,".csv"))
speed = c(SpeedReckon(trip))
feature2 = c(driver,i, Acceleration(speed))
acceleration = rbind(acceleration, feature2)
根據您發佈的代碼,'加速'不*在另一個功能內。 – 2015-04-02 09:32:35