Skip to content

Instantly share code, notes, and snippets.

View noahhl's full-sized avatar

Noah Lorang noahhl

  • Basecamp
  • Pittsburgh, PA
View GitHub Profile
@noahhl
noahhl / R_write.table_with_dates
Created March 22, 2011 18:53
The problem that makes write.table() not symmetric
#Create a data frame that includes a POSIXlt or POSIXct, write.table() to a file, and then read.table() of that file
> a <- data.frame(col1 = 1:10, col2 = as.POSIXlt(Sys.time()), stringsAsFactors=F)
> write.table(a, "test")
> read.table("test")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 1 did not have 4 elements
#Now, do the same with that data as a character instead: