[R] Converting factor data into Date-time format
tandi perkins
idnat at hotmail.com
Tue Sep 30 19:54:35 CEST 2014
Hello R help:
I am
new to this forum so I apologize in advance for any protocol missteps. I
have a data set that is comprised of eight birds with GPS; each of which
transmit everyday at 8:00 am, 4:00 pm, and midnight for 1 year (although I have
some missing relocation's). I am trying to format my data to be run in
adehabitatLT but I am unsuccessful. I have a "csv" file with
the following header: "Craneid, Date, Time, Long, Lat, Habitat,
BurstID". R creates factor levels in the all of the data except Lat,
Long. I have attempted the following to correctly format my date and time
factors (data=l10):
First
attempt:
1.
datetime=as.POSIXct(paste(l10$Date, l10$Time), format="%m/%d/%Y
%H:%M:%S", "America/Chicago")
2.
coord=data.frame((l10$Longitude), (l10$Latitude))
3.
test=as.ltraj(coord, datetime, l10$Craneid, burst=l10$ID, typeII=TRUE)
Results:Error
in as.ltraj(coord, datetime, l10$Craneid, burst = l10$ID, typeII = TRUE) :
non unique dates for a given burst
I
researched this error on the list serve and found that I could have duplicates
so I checked for duplicates in datetime and the return was NULL (I also check
for duplicates in Excel as I am in the learning stages in R). Next I read
a thread posted on the R help in 2012 with a similar problem so I attempted
what was suggested as follows:
1.
datetime=as.POSIXct(strptime(as.character(l10$Date, l10$Time),
format="%m/%d/%Y %H:%M:%S"))
2.test=as.ltraj(coord,
datetime, l10$Craneid, burst=l10$ID, typeII=TRUE)
Results:
Same error.
Finally,
I have tried:
1.
datetime=as.POSIXct(as.character(levels(l10$Date)(l10$Time)),
format="%m/%d/%Y %H:%M:%S")[l10$Date][l10$Time]
Results:Error
in as.POSIXct(as.character(levels(l10$Date)(l10$Time)), format = "%m/%d/%Y
%H:%M:%S") :
attempt to apply non-function
Can
someone please explain what I am doing wrong? My goal is to obtain
trajectories for all birds using each bird as a burst as is detailed in the
adehabitatLT manual and then to create Bias Random Bridges for each bird.
I did not include my data but I can if that will be helpful.
Thank
you in advance for your help,
TLP
[[alternative HTML version deleted]]
More information about the R-help
mailing list