Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SPSS date format when imported into R

Tags:

time

r

spss

I have not worked with SPSS (.sav) files before and am trying to work with some data files provided to me by importing them into R. I did not receive any explanation of the files, and because communication is difficult I am trying to figure out as much as I can on my own.

Here's my first question. This is what the Date field looks like in an R data frame after import:

> dataset2$Date[1:4]
[1] 13608172800 13608259200 13608345600 13608345600

I don't know what dates the data is supposed to be for, but I found that if I divide the above numbers by 10, that seems to give a reasonable date (in February 2013). Can anyone confirm this is indeed what the above represents?

My second question is regarding another column called Begin_time. Here's what that looks like:

> dataset2$Begin_time[1:4]
[1] 29520 61800 21480 55080

Any idea what this is representing? I want to believe this is some representation of time of day because the records are for wildlife observations, but I haven't got more info than that to try to guess. I noticed that if I take the difference between End_Time and Begin_time I get numbers like 120 and 180, which seems like minutes to me (3 hours seems reasonable to observe a wild animal), but the absolute numbers are far greater than the number of minutes in a day (1440), so that leaves me puzzled. Is this some time keeping format from SPSS? If so, what's the logic?

Unfortunately, I don't have access to SPSS, so any help would be much appreciated.

like image 555
helloB Avatar asked Dec 10 '22 16:12

helloB


1 Answers

I had the same problem and this function is a good solution:

pss2date <- function(x) as.Date(x/86400, origin = "1582-10-14")

This is where I found the answer:

http://scs.math.yorku.ca/index.php/R:_Importing_dates_from_SPSS

like image 83
Diaa Al mohamad Avatar answered Dec 28 '22 23:12

Diaa Al mohamad