[R] Speeding up time conversion

Fisher Dennis fisher at plessthan.com
Thu Sep 27 19:24:02 CEST 2012


R 2.15.1
OS X.7.4

Colleagues,

I have a large dataset (27773536 records, the file is several GB) that contains a column of date / time entries in the format:
	"2/1/2011 13:25:01"	
I need to convert these to numeric values (ideally in seconds; the origin [e.g., 1970-01-01] is not important).  

I am using:
	 as.numeric(strptime(DATA$DATADTM, "%m/%d/%Y %H:%M:%S"))
It takes 21 minutes to execute this step on a dual quad-core Mac with 12 GB RAM (it is appreciably slower on other Mac's including a new i5 iMac).

Are there other time formatting functions or strategies that would be faster?

Sample data:
	TIMECOL	<- rep("2/1/2011 13:25:01", 100)

Any tips would be appreciated.

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com



More information about the R-help mailing list