[R-sig-Geo] TimeStamp

Roger Bivand Roger.Bivand at nhh.no
Tue Sep 7 13:52:18 CEST 2010


On Sun, 5 Sep 2010, Roberto Badilla Fuentes wrote:

> Hi,
>
> I have a dataset in .dbf format.  It contains Coordinates and Time.
> The TIMESTAMP is as follows:
>
>  03/18/2006 13:30:37
> I am not working with the TIMESTAMP column, but when I print out my
> manipulated dataset using
> *write.dbf*  I get the value *390 *where the TIMESTAMP value should be.  Can
> Anyone help me out why R does this
> and how I can correct it.

Please quote all code verbatim. You have not said how you read the data, 
whether the class representation of the data in R was what you thought it 
was, not how you wrote it out (exactly). You probably used read.dbf() in 
the foreign package, and write.dbf() to write the data.frame object out 
again.

Try:

library(foreign)
x <- read.dbf(system.file("files/sids.dbf", package="foreign")[1])
str(x)
# check the class representations
summary(x)
attr(x, "data_types")
# should show "D" for any fields seen as date/time, none here yet
Dv <- seq(as.POSIXlt("1990-01-01"), as.POSIXlt("2000-01-01"),
   length.out=100)
x$Dv <- as.Date(Dv)
str(x)
summary(x)
tf <- paste(tempfile(), ".dbf", sep="")
write.dbf(x, tf)
xx <- read.dbf(tf)
str(xx)
summary(xx)
attr(xx, "data_types")

Note from ?write.dbf that all date/time representations must be coerced to 
Date. It is very possible that your *390* is the internal representation, 
and needs print()ing to show its human-readable version.

Hope this helps,

Roger


>
> Thanks
> -Roberto
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list