Skip to content
Prev 4917 / 7420 Next

loss of data from ltrj infolocs when using redisltraj

This solution works. However I am running it on over 30 files 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

-----Reply----------------------------

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.

------------------original message-----------------------------------
--
View this message in context: http://r-sig-ecology.471788.n2.nabble.com/loss-of-data-from-ltrj-infolocs-when-using-redisltraj-tp7579304p7579319.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.