From patrick.mccormick at alum.mit.edu  Sun Sep 18 01:50:54 2011
From: patrick.mccormick at alum.mit.edu (Patrick McCormick)
Date: Sat, 17 Sep 2011 19:50:54 -0400
Subject: [Rd] [patch] writeForeignSAS writes invalid SASdata for logical
	columns
Message-ID: <CAEut_u7aWz=QA-UbOshL1wZt5kL8D2WCe6i7zUfrTgpY2-M06A@mail.gmail.com>

Hi,

The patch attachment did not make it in my previous mail.  I have
pasted it below.

Thanks,
Patrick McCormick

diff -U3 -r foreign_0.8-45/R/writeForeignSAS.R foreign/R/writeForeignSAS.R
--- foreign_0.8-45/R/writeForeignSAS.R	2010-12-17 07:17:32.000000000 -0500
+++ foreign/R/writeForeignSAS.R	2011-09-16 14:57:46.518814100 -0400
@@ -50,6 +50,7 @@
     ## FIXME: re-write this to hold a connection open
     factors <- sapply(df, is.factor)
     strings <- sapply(df, is.character)
+    logicals <- sapply(df, is.logical)
     dates <- sapply(df, FUN = function(x) inherits(x, "Date") ||
inherits(x, "dates") || inherits(x, "date"))
     xdates <- sapply(df, FUN = function(x)  inherits(x, "dates") ||
inherits(x, "date"))
     datetimes <- sapply(df, FUN = function(x) inherits(x, "POSIXt"))
@@ -63,6 +64,8 @@
     dfn <- df
     if (any(factors))
         dfn[factors] <- lapply(dfn[factors], as.numeric)
+    if (any(logicals))
+        dfn[logicals] <- lapply(dfn[logicals], as.numeric)
     if (any(datetimes))
         dfn[datetimes] <- lapply(dfn[datetimes],
                                  function(x) format(x, "%d%b%Y %H:%M:%S"))



[Rd] [patch] writeForeignSAS writes invalid SASdata for logical columns
Patrick McCormick