Skip to content
Prev 4914 / 7419 Next

loss of infolocs data when using redisltraj

This solution works. However I am running it on over 30 scripts and in a few of the csv files setting the NAs adds an extra row of data into the ltraj object which creates problems when appending the infolocs back again. The code below seems to solve the issue. Though I can't figure out why the extra row is being added in some files....

#convert to dataframe
tr1.nas<-ld(tr1.na)#na infolocs dataframe
#convert to dataframe
tr1.I<-ld(tr1.interp)#interpolated dataframe
#find row added
tail(tr1.I)
tail(tr1.nas)
#remove row
tr1.nas<-tr1.nas[-132798,]
#turn back to itraj object
tr1.na<-dl(tr1.nas)
#then...re run infolocs saving and append ***

Regards,
Liz

-----Original Message-----
From: basille.web at ase-research.org [mailto:basille.web at ase-research.org] 
Sent: 10 February 2015 19:03
To: Elizabeth Morgan; 'r-sig-ecology at r-project.org'
Subject: Re: [R-sig-eco] loss of infolocs data when using redisltraj

Dear Liz,

I guess the problem is both technical (the dimensions of the data frames, as you pointed out) and biological (how does information associated to given steps make sense after interpolation?). You're suggesting to put in NAs for the newly interpolated points, which is probably a safe approach if the data is considered at the location level, and not at the step level.

Anyway, one issue with 'redisltraj' is that it is written in C, which makes editing not very easy... One way to achieve what you want, I think (not tested, you'll have to try it by yourself), would be to:

1) Put missing locations back in the trajectory using setNA:

tr1 <- setNA(tr1, tr1[[1]][1, "date"], 60, units = "sec")

This way, you will have the correct dimensions for the main df and the infolocs for each ltraj element, but NAs for the coordinates of the missing locs.

2) Storing the infolocs somewhere:

info <- infolocs(tr1)

3) Removing the missing locations (!) with na.omit, and interpolate the trajectory, as you did before:

tr1.interp <- redisltraj(na.omit(tr1), 60, type = "time"))

4) Now you should be able to transfer the infolocs:

infolocs(tr1.interp) <- info

Let me know if that works!
Mathieu.


Le 10/02/2015 11:52, Elizabeth Morgan a ?crit :