[R] Need hep for converting date data in POSIXct

arun smartpink111 at yahoo.com
Thu Jul 11 04:27:32 CEST 2013



Hi,
I guess the error message:
> vmask(lat,lon,time,vmax=25)
Error en vmask(lat, lon,
time, vmax = 25) : objeto 'lat' no encontrado

says that you have not defined the object 'lat'.

time<-subset(Geo, select =date)
time[,1]<-  as.POSIXct(time[,1],format="%d/%m/%Y %H:%M")
location<- subset(Geo,select=c(lat.comp,long))
 time1<- time[,1]
 lat<- location[,1]
 long<- location[,2]
library(argosfilter)
 vmask(lat,long,time1,25)
#[1] "end_location" "end_location" "not"          "not"          "end_location"
#[6] "end_location"

A.K.
________________________________
From: laila Aranda Romero <laila_zgz at hotmail.com>
To: arun <smartpink111 at yahoo.com> 
Sent: Wednesday, July 10, 2013 6:21 PM
Subject: RE: [R] Need hep for converting date data in POSIXct





Hi,

The code: 

library(argosfilter)
setwd("C:/Users/Usuario/Dropbox/Laila Aranda/PUFGRA")
Geo = 
read.table("2370001_PUFGRA_2009_Gough_000_retarded10_both.trj",header=FALSE,sep
= ",", col.names= c("type", "date",
"secs", "Trans1",  "Trans2",
"lat.sta",  "lat.comp", "long", 
"dist", "rumbo", "velocidad", 
"confianza"))
View(Geo)
location=subset(Geo, select= c(lat.comp,long))
time=subset(Geo, select =c(date))
time[,1]<-as.POSIXct(time[,1],format="%d/%m/%Y
%H:%M")   
vmask(lat,lon,time,vmax=25)




The example: library(argosfilter)
> setwd("C:/Users/Usuario/Dropbox/LailaAranda/PUFGRA")
> Geo = read.table("2370001_PUFGRA_2009_Gough_000_retarded10_both.trj",header=FALSE,sep
= ",", col.names= c("type", "date","secs", "Trans1", "Trans2", "lat.sta", "lat.comp", "long", "dist", "rumbo", "velocidad",  "confianza"))
> str(Geo)

'data.frame':  582
obs. of  12 variables: $
type     : Factor w/ 2 levels
"midnight","noon": 2 1 2 1 2 1 2 1 2 1 ...
 $
date     : Factor w/ 582 levels
"01/01/2009 01:58",..: 370 389 390 409 410 429 430 450 451 471 ...

 $
secs     : num  39773 39773 39774 39774 39775 ... $
Trans1   : Factor w/ 186 levels
"04:06","04:08",..: 14 17 17 16 16 28 28 19 19 15 ...
 $
Trans2   : Factor w/ 159 levels
"00:01","00:03",..: 30 30 28 28 34 34 35 35 36 36 ...
 $
lat.sta  : num  -42.7 -39.1 -37.8 -37.9 -41.2 ...
 $
lat.comp : num  -42.7 -40.6 -38.6 -37.9
-39 ...

 $
long     : num  9.31 11.66 10.88 10.72 13.06 ...
 $ dist     : num 
0 0 127 45 131 ...
 $ rumbo   
: num  0 0 -16.49 -9.64 -57.22 ...
 $ velocidad: num  0 0 10.64 3.75 10.75 ... $ confianza: int  3 9 9 9 9 6 6 9 9 9
...
> head(Geo)
type             date     secs Trans1 Trans2 lat.sta lat.comp  long  
dist
1 noon 20/11/2008 12:23 39772.52 
04:59  19:47  -42.72  
-42.72  9.31   0.00
2 midnight 21/11/2008 00:33 39773.02  05:18 
19:47  -39.14   -40.63 11.66   0.00
3 noon 21/11/2008 12:29 39773.52 
05:18  19:41  -37.82  
-38.60 10.88 127.02
4 midnight 22/11/2008 00:29 39774.02  05:17 
19:41  -37.86   -37.86 10.72 
45.04
5 noon 22/11/2008 12:39 39774.53 
05:17  20:00  -41.21  
-39.04 13.06 130.78
6 midnight 23/11/2008 00:50 39775.03  05:41 
20:00  -36.56   -38.51 16.02 142.06
   rumbo
velocidad confianza
1  
0.00      0.00         3
2  
0.00      0.00         9
3 -16.49    
10.64         9
4 
-9.64      3.75         9
5 -57.22    
10.75         9
6 
77.07     11.66         6
> location=subset(Geo, select=
c(lat.comp,long))

> str(location)
'data.frame':  582
obs. of  2 variables:
 $lat.comp: num  -42.7 -40.6 -38.6 -37.9 -39 ...
 $long    : num  9.31 11.66 10.88 10.72 13.06 ...
> head(location)

lat.comp  long
1  
-42.72  9.31
2  
-40.63 11.66
3  
-38.60 10.88
4  
-37.86 10.72
5  
-39.04 13.06
6  
-38.51 16.02

> time=subset(Geo, select =c(date))
> time[,1]<-as.POSIXct(time[,1],format="%d/%m/%Y
%H:%M")
> str(time)
'data.frame':  582
obs. of  1 variable:
 $ date:
POSIXct, format: "2008-11-20 12:23:00" "2008-11-21
00:33:00" ...
> head(time)
                 date
1 2008-11-20 12:23:00
2 2008-11-21 00:33:00
3 2008-11-21 12:29:00
4 2008-11-22 00:29:00
5 2008-11-22 12:39:00
6 2008-11-23 00:50:00
> vmask(lat,lon,time,vmax=25)
Error en vmask(lat, lon,
time, vmax = 25) : objeto 'lat' no encontrado



More information about the R-help mailing list