[R-gregmisc-commits] r2145 - / branches/GenerateFORMATSfromFactorObjects/SASxport/R pkg pkg/SASxport pkg/SASxport/R pkg/SASxport/inst pkg/SASxport/man pkg/SASxport/src pkg/SASxport/tests pkg/gtools/R tags/gtools_2.3.0/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 23 17:55:38 CEST 2017


Author: warnes
Date: 2017-05-23 17:55:37 +0200 (Tue, 23 May 2017)
New Revision: 2145

Added:
   pkg/SASxport/.Rbuildignore
   pkg/SASxport/.gitignore
   pkg/SASxport/.travis.yml
   pkg/SASxport/NEWS.md
   pkg/SASxport/R/package.R
   pkg/SASxport/README.md
   pkg/SASxport/appveyor.yml
   pkg/SASxport/inst/NEWS.md
Removed:
   pkg/SASxport/.Rproj.user/
   pkg/SASxport/R/AFirst.lib.s
   pkg/SASxport/R/all.is.numeric.R
   pkg/SASxport/R/blanks.R
   pkg/SASxport/R/importConvertDateTime.R
   pkg/SASxport/R/in.opererator.R
   pkg/SASxport/R/makeNames.R
   pkg/SASxport/R/testDateTime.R
Modified:
   /
   branches/GenerateFORMATSfromFactorObjects/SASxport/R/fromSASDate.R
   pkg/
   pkg/SASxport/
   pkg/SASxport/DESCRIPTION
   pkg/SASxport/NAMESPACE
   pkg/SASxport/R/SASformat.R
   pkg/SASxport/R/SASiformat.R
   pkg/SASxport/R/SAStype.R
   pkg/SASxport/R/fromSASDate.R
   pkg/SASxport/R/fstr.R
   pkg/SASxport/R/lookup.xport.R
   pkg/SASxport/R/makeSASNames.R
   pkg/SASxport/R/parseFormat.R
   pkg/SASxport/R/process.formats.R
   pkg/SASxport/R/read.xport.R
   pkg/SASxport/R/scat.R
   pkg/SASxport/R/toSAS.R
   pkg/SASxport/R/write.xport.R
   pkg/SASxport/R/xport.NA.R
   pkg/SASxport/R/xport.R
   pkg/SASxport/R/xport.dateFMT.R
   pkg/SASxport/R/xport.file.header.R
   pkg/SASxport/R/xport.fill.R
   pkg/SASxport/R/xport.member.header.R
   pkg/SASxport/R/xport.namestr.R
   pkg/SASxport/R/zzz.R
   pkg/SASxport/inst/ChangeLog
   pkg/SASxport/man/SASformat.Rd
   pkg/SASxport/man/read.xport.Rd
   pkg/SASxport/man/write.xport.Rd
   pkg/SASxport/src/SASxport.c
   pkg/SASxport/src/SASxport.h
   pkg/SASxport/src/to_bigend.h
   pkg/SASxport/tests/Alfalfa_Test.R
   pkg/SASxport/tests/Alfalfa_Test.Rout.save
   pkg/SASxport/tests/Theoph.Rout.save
   pkg/SASxport/tests/cars.Rout.save
   pkg/SASxport/tests/datetime.xpt
   pkg/SASxport/tests/dfAttributes.R
   pkg/SASxport/tests/testDates.Rout.save
   pkg/SASxport/tests/testDuplicateNames.Rout.save
   pkg/SASxport/tests/testEmpty.Rout.save
   pkg/SASxport/tests/testExamples.R
   pkg/SASxport/tests/testExamples.Rout.save
   pkg/SASxport/tests/testManyNames.Rout.save
   pkg/SASxport/tests/testNegative.Rout.save
   pkg/SASxport/tests/testNumeric.Rout.save
   pkg/SASxport/tests/test_as_is.Rout.save
   pkg/SASxport/tests/test_fields.Rout.save
   pkg/SASxport/tests/xport.R
   pkg/SASxport/tests/xport.Rout.save
   pkg/SASxport/tests/xxx.R
   pkg/SASxport/tests/xxx.Rout.save
   pkg/gtools/R/ask.R
   pkg/gtools/R/quantcut.R
   pkg/gtools/R/smartbind.R
   tags/gtools_2.3.0/R/scat.R
Log:
- Integrate changes made by Mango Solutions at https://github.com/MangoTheCat/SASxport.
- Remove functions duplicated from the Hmisc package.
- Minor code cleanup.


Property changes on: 
___________________________________________________________________
Added: svn:ignore
   + *.Rproj*
.Rproj.user


Modified: branches/GenerateFORMATSfromFactorObjects/SASxport/R/fromSASDate.R
===================================================================
--- branches/GenerateFORMATSfromFactorObjects/SASxport/R/fromSASDate.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ branches/GenerateFORMATSfromFactorObjects/SASxport/R/fromSASDate.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,3 +1,4 @@
+# Convert SAS date to R date
 fromSASDate <- function( sDate )
   {
     sasBase <- as.Date(strptime("01/01/1960 0:00:00", "%m/%d/%Y %H:%M:%S", tz="GMT")) # days
@@ -4,7 +5,7 @@
     sasBase + sDate
   }
 
-
+# Convert SAS datetime to R date
 fromSASDateTime <- function( sDateTime )
   {
     sasBaseSeconds <- as.numeric(ISOdatetime(1960,1,1,0,0,0) - 0)


Property changes on: pkg
___________________________________________________________________
Modified: svn:ignore
   - *.Rcheck
*.tar.gz

   + *.Rcheck
*.tar.gz
.Rproj.user



Property changes on: pkg/SASxport
___________________________________________________________________
Added: svn:ignore
   + *.Rproj*


Added: pkg/SASxport/.Rbuildignore
===================================================================
--- pkg/SASxport/.Rbuildignore	                        (rev 0)
+++ pkg/SASxport/.Rbuildignore	2017-05-23 15:55:37 UTC (rev 2145)
@@ -0,0 +1,4 @@
+^.travis.yml$
+^appveyor.yml$
+^README.md$
+^NEWS.md$

Added: pkg/SASxport/.gitignore
===================================================================
--- pkg/SASxport/.gitignore	                        (rev 0)
+++ pkg/SASxport/.gitignore	2017-05-23 15:55:37 UTC (rev 2145)
@@ -0,0 +1,2 @@
+/src/*.o
+/src/SASxport.so

Added: pkg/SASxport/.travis.yml
===================================================================
--- pkg/SASxport/.travis.yml	                        (rev 0)
+++ pkg/SASxport/.travis.yml	2017-05-23 15:55:37 UTC (rev 2145)
@@ -0,0 +1,34 @@
+## Sample .travis.yml file for use with metacran/r-builder
+## See https://github.com/metacran/r-builder for details.
+
+language: c
+sudo: required
+
+before_install:
+  - curl -OL https://raw.githubusercontent.com/metacran/r-builder/master/pkg-build.sh
+  - chmod 755 pkg-build.sh
+  - ./pkg-build.sh bootstrap
+
+install:
+  - ./pkg-build.sh install_deps
+  - ./pkg-build.sh install_r covr
+
+script:
+  - ./pkg-build.sh run_tests
+
+after_failure:
+  - ./pkg-build.sh dump_logs
+
+after_success:
+  - if [[ ! -z "$COVERAGE" ]];then ./pkg-build.sh run_script -e 'covr::codecov()'; fi
+
+notifications:
+  email:
+    on_success: change
+    on_failure: change
+
+env:
+  matrix:
+    - RVERSION=oldrel
+    - RVERSION=release
+    - RVERSION=devel COVERAGE=true

Modified: pkg/SASxport/DESCRIPTION
===================================================================
--- pkg/SASxport/DESCRIPTION	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/DESCRIPTION	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,42 +1,73 @@
 Package: SASxport
-Type: Package
-Title: Read and Write SAS XPORT Files
+Title: Read and Write 'SAS' 'XPORT' Files
 Version: 1.5.4
-Date: 2016-03-25
+Date: 2017-05-22
 Description: Functions for reading, listing
-    the contents of, and writing SAS xport format files.
-  The functions support reading and writing of either
-  individual data frames or sets of data frames.  Further,
-  a mechanism has been provided for customizing how
-  variables of different data types are stored.
-Author:
-  Unless otherwise noted, the contents of this package were written by
-  Gregory R. Warnes <greg at warnes.net> and are provided under the
-  terms of the GNU General Public License, version 2.0 or later.
-  --
-  The files 'src/ieee2ibm.c' and 'src/ibm2ieee.c' were extracted from
-  BRL-CAD file /brlcad/src/libbu/htond.c written by Michael John
-  Muuss, Copyright (c) 2004-2007 United States Government as
-  represented by the U.S. Army Research Laboratory, and is utilized
-  and redistributed under the terms of the GNU Lesser General Public
-  License, version 2.1.
-  --
-  The files 'R/AFirst.lib.s', 'R/all.is.numeric.R',
-  'R/importConvertDateTime.R', 'R/in.opererator.R', 'R/makeNames.R',
-  'R/read.xport.R', and 'R/testDateTime.R' are copied or adapted from the
-  'Hmisc' package created by Frank E. Harrell, Jr.
-  <f.harrell at vanderbilt.edu>, and are utilized and redistributed under
-  the terms of the GNU General Public License, version 2.0 or later.
-  --
-  The files 'R/xport.R', 'src/SASxport.c', 'src/SASxport.h', and
-  'src/foreign.h' are copied or adapted from the R 'foreign' package
-  created by Douglas M. Bates <bates at stat.wisc.edu> and Saikat DebRoy
-  <saikat at stat.wisc.edu>, and are utilized and redistributed under the
-  terms of the GNU General Public License, version 2.0 or later.
-  --
-  The creation of this package was partially funded by Metrum Institute
-  <http://metruminstitute.org>.
+    the contents of, and writing 'SAS' 'xport' format files.
+    The functions support reading and writing of either
+    individual data frames or sets of data frames.  Further,
+    a mechanism has been provided for customizing how
+    variables of different data types are stored.
+Author: Unless otherwise noted, the contents of this package were written by
+    Gregory R. Warnes <greg at warnes.net> and are provided under the
+    terms of the GNU General Public License, version 2.0 or later.
+    --
+    The files 'src/ieee2ibm.c' and 'src/ibm2ieee.c' were extracted from
+    BRL-CAD file /brlcad/src/libbu/htond.c written by Michael John
+    Muuss, Copyright (c) 2004-2007 United States Government as
+    represented by the U.S. Army Research Laboratory, and is utilized
+    and redistributed under the terms of the GNU Lesser General Public
+    License, version 2.1.
+    --
+    The file 'R/read.xport.R' is adapted from the 'Hmisc' package created
+    by Frank E. Harrell, Jr. <f.harrell at vanderbilt.edu>, and is utilized 
+    and redistributed under the terms of the GNU General Public License, 
+    version 2.0 or later.
+    --
+    The files 'R/xport.R', 'src/SASxport.c', 'src/SASxport.h', and
+    'src/foreign.h' are copied or adapted from the 'R' 'foreign' package
+    created by Douglas M. Bates <bates at stat.wisc.edu> and Saikat DebRoy
+    <saikat at stat.wisc.edu>, and are utilized and redistributed under the
+    terms of the GNU General Public License, version 2.0 or later.
+    --
+    The creation of this package was partially funded by Metrum Institute
+    <http://metruminstitute.org>.
 Maintainer: Gregory R. Warnes <greg at warnes.net>
 License: GPL-2
-Depends: R (>= 2.4.0), chron, Hmisc
-URL: http://www.warnes.net, http://metruminstitute.org
+Depends:
+    R (>= 2.4.0)
+Imports:
+    Hmisc,
+    utils
+URL: https://github.com/mangothecat/SASxport
+BugReports: https://github.com/mangothecat/SASxport/issues
+RoxygenNote: 5.0.1
+Collate:
+    'SASformat.R'
+    'SASiformat.R'
+    'SAStype.R'
+    'fromSASDate.R'
+    'fstr.R'
+    'lookup.xport.R'
+    'make.formats.R'
+    'makeSASNames.R'
+    'package.R'
+    'parseFormat.R'
+    'process.formats.R'
+    'rawToDisplay.R'
+    'read.xport.R'
+    'scat.R'
+    'toSAS.R'
+    'write.xport.R'
+    'xport.NA.R'
+    'xport.R'
+    'xport.character.R'
+    'xport.dateFMT.R'
+    'xport.file.header.R'
+    'xport.fill.R'
+    'xport.member.header.R'
+    'xport.namestr.R'
+    'xport.namestr.header.R'
+    'xport.numeric.R'
+    'xport.obs.header.R'
+    'zzz.R'

Modified: pkg/SASxport/NAMESPACE
===================================================================
--- pkg/SASxport/NAMESPACE	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/NAMESPACE	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,60 +1,40 @@
-useDynLib(SASxport, .registration=TRUE)
+# Generated by roxygen2: do not edit by hand
 
-importFrom(chron, chron, times)
-importFrom(utils, packageDescription)
-importFrom(Hmisc, label, label.default, "label<-", "label<-.default")
-importFrom(utils, download.file)
-
-export(
-       toSAS,
-       lookup.xport,
-       read.xport,
-       write.xport,
-       ## "label",
-       ## "label<-",
-
-       makeSASNames,
-
-       "SASformat",
-       "SASformat<-",
-
-       "SASiformat",
-       "SASiformat<-",
-
-       "SAStype",
-       "SAStype<-"
-)
-
-S3method(toSAS, numeric)
-S3method(toSAS, logical)
-S3method(toSAS, character)
-S3method(toSAS, factor)
-S3method(toSAS, chron)
-S3method(toSAS, POSIXt)
-S3method(toSAS, Date)
-S3method(toSAS, default)
-
-## S3method(label, default)
-S3method(SASformat,  default)
-S3method(SASiformat, default)
-S3method(SAStype,    default)
-
-## S3method(label,   data.frame)
-S3method(SASformat,  data.frame)
-S3method(SASiformat, data.frame)
-##S3method(SAStype,    data.frame)
-
-## S3method("label<-", default)
-S3method("SASformat<-",  default)
-S3method("SASiformat<-", default)
-S3method("SAStype<-",    default)
-
-## S3method("label<-", data.frame)
-S3method("SASformat<-",  data.frame)
-S3method("SASiformat<-", data.frame)
-##S3method("SAStype<-",    data.frame)
-
-S3method(print, lookup.xport)
-S3method(summary, lookup.xport)
-S3method(print, summary.lookup.xport)
-
+S3method("SASformat<-",data.frame)
+S3method("SASformat<-",default)
+S3method("SASiformat<-",data.frame)
+S3method("SASiformat<-",default)
+S3method("SAStype<-",default)
+S3method(SASformat,data.frame)
+S3method(SASformat,default)
+S3method(SASiformat,data.frame)
+S3method(SASiformat,default)
+S3method(SAStype,default)
+S3method(print,lookup.xport)
+S3method(print,summary.lookup.xport)
+S3method(summary,lookup.xport)
+S3method(toSAS,Date)
+S3method(toSAS,POSIXt)
+S3method(toSAS,character)
+S3method(toSAS,chron)
+S3method(toSAS,default)
+S3method(toSAS,factor)
+S3method(toSAS,logical)
+S3method(toSAS,numeric)
+export("SASformat<-")
+export("SASiformat<-")
+export("SAStype<-")
+export(SASformat)
+export(SASiformat)
+export(SAStype)
+export(lookup.xport)
+export(makeSASNames)
+export(read.xport)
+export(toSAS)
+export(write.xport)
+importFrom(Hmisc,"label<-")
+importFrom(Hmisc,"label<-.data.frame")
+importFrom(Hmisc,"label<-.default")
+importFrom(Hmisc,label)
+importFrom(utils,download.file)
+useDynLib(SASxport)

Added: pkg/SASxport/NEWS.md
===================================================================
--- pkg/SASxport/NEWS.md	                        (rev 0)
+++ pkg/SASxport/NEWS.md	2017-05-23 15:55:37 UTC (rev 2145)
@@ -0,0 +1 @@
+link inst/NEWS.md
\ No newline at end of file


Property changes on: pkg/SASxport/NEWS.md
___________________________________________________________________
Added: svn:special
   + *

Deleted: pkg/SASxport/R/AFirst.lib.s
===================================================================
--- pkg/SASxport/R/AFirst.lib.s	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/AFirst.lib.s	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,25 +0,0 @@
-##
-## Code originally from Frank Harrell's 'Hmisc' library:
-##   http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/Hmisc
-## Copied with permission on 2007-08-04
-##
-
-## $Id: AFirst.lib.s,v 1.6 2005/09/26 15:44:17 dupontct Exp $
-under.unix <- !(version$os=='Microsoft Windows' ||
-                version$os=='Win32' || version$os=='mingw32')
-
-# .R.   <- TRUE
-# .SV4. <- FALSE
-
-.noGenenerics <- TRUE  # faster loading as new methods not used
-
-if(!exists('existsFunction')) {
-  existsFunction <- function(...) exists(..., mode='function')
-}
-
-# if(.R.) {
-  ## create some function definitions just to avoid R CMD CHECK warnings
-  timeDate <- function(...) stop("Not Implemented")
-#  dates <- function(...) stop("Not Implemented")
-# }
-

Modified: pkg/SASxport/R/SASformat.R
===================================================================
--- pkg/SASxport/R/SASformat.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/SASformat.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,6 +1,9 @@
+#' @export
 SASformat <- function(x, default)
   UseMethod("SASformat")
 
+
+#' @export
 SASformat.default <- function(x, default=NULL)
 {
   lab <- attr(x,"SASformat")
@@ -10,14 +13,20 @@
   lab
 }
 
+
+#' @export
 SASformat.data.frame <- function(x, default=NULL)
 {
   sapply( x, SASformat)
 }
 
+
+#' @export
 "SASformat<-" <- function(x, value)
   UseMethod("SASformat<-")
 
+
+#' @export
 "SASformat<-.default" <- function(x, value)
 {
   attr(x,'SASformat') <- value
@@ -25,6 +34,7 @@
 }
 
 
+#' @export
 "SASformat<-.data.frame" <- function(x, value)
 {
   if( ncol(x) != length(value) )

Modified: pkg/SASxport/R/SASiformat.R
===================================================================
--- pkg/SASxport/R/SASiformat.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/SASiformat.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,6 +1,9 @@
+#' @export
 SASiformat <- function(x, default)
   UseMethod("SASiformat")
 
+
+#' @export
 SASiformat.default <- function(x, default=NULL)
 {
   lab <- attr(x,"SASiformat")
@@ -11,22 +14,26 @@
 }
 
 
+#' @export
 SASiformat.data.frame <- function(x, default=NULL)
 {
   sapply( x, SASiformat)
 }
 
 
-
+#' @export
 "SASiformat<-" <- function(x, value)
   UseMethod("SASiformat<-")
 
+#' @export
 "SASiformat<-.default" <- function(x, value)
 {
   attr(x,'SASiformat') <- value
   x
 }
 
+
+#' @export
 "SASiformat<-.data.frame" <- function(x, value)
 {
   if( ncol(x) != length(value) )

Modified: pkg/SASxport/R/SAStype.R
===================================================================
--- pkg/SASxport/R/SAStype.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/SAStype.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,6 +1,9 @@
+#' @export
 SAStype <- function(x, default)
   UseMethod("SAStype")
 
+
+#' @export
 SAStype.default <- function(x, default=NULL)
 {
   lab <- attr(x,"SAStype")
@@ -10,9 +13,13 @@
   lab
 }
 
+
+#' @export
 "SAStype<-" <- function(x, value)
   UseMethod("SAStype<-")
 
+
+#' @export
 "SAStype<-.default" <- function(x, value)
 {
   attr(x,'SAStype') <- makeSASNames(value)

Deleted: pkg/SASxport/R/all.is.numeric.R
===================================================================
--- pkg/SASxport/R/all.is.numeric.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/all.is.numeric.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,22 +0,0 @@
-##
-## Code originally from Frank Harrell's 'Hmisc' library: 
-##   http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/Hmisc
-## Copied with permission on 2007-08-04
-##
-
-all.is.numeric <- function(x, what=c('test','vector'), extras=c('.','NA'))
-{
-  what <- match.arg(what)
-  old <- options(warn=-1)
-  on.exit(options(old))
-  ##.Options$warn <- -1  6Aug00
-  x <- sub('[[:space:]]+$', '', x)
-  x <- sub('^[[:space:]]+', '', x)
-  xs <- x[x %nin% c('',extras)]
-  isnum <- !any(is.na(as.numeric(xs)))
-  if(what=='test')
-    isnum
-  else if(isnum)
-    as.numeric(x)
-  else x
-}

Deleted: pkg/SASxport/R/blanks.R
===================================================================
--- pkg/SASxport/R/blanks.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/blanks.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,5 +0,0 @@
-blanks <- 
-function(nchar)
-  {
-    sprintf( paste("%",nchar,".",nchar,"s",sep=""), "" )
-  }

Modified: pkg/SASxport/R/fromSASDate.R
===================================================================
--- pkg/SASxport/R/fromSASDate.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/fromSASDate.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,3 +1,4 @@
+# Convert SAS date values to R 'Date' objects
 fromSASDate <- function( sDate )
   {
     sasBase <- as.Date(strptime("01/01/1960 0:00:00", "%m/%d/%Y %H:%M:%S", tz="GMT")) # days
@@ -5,6 +6,7 @@
   }
 
 
+# Convert SAS DateTime values to R 'POSIXct' objects
 fromSASDateTime <- function( sDateTime )
   {
     sasBaseSeconds <- as.numeric(ISOdatetime(1960,1,1,0,0,0) - 0)

Modified: pkg/SASxport/R/fstr.R
===================================================================
--- pkg/SASxport/R/fstr.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/fstr.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,6 +1,7 @@
+# Construct a SAS format string for a specified (vector of) type names, lengths, and digits.
 fstr <- function(name, length, digits)
   {
-    invalid <- function(x) is.null(x) | ( length(x)<1 ) | ( nchar(x, "bytes") < 1 ) | x==0
+    invalid <- function(x) is.null(x) | ( length(x)<1 ) | ( nchar(x) < 1 ) | x==0
     inner <- function(i)
       {
         if( invalid(name[i]) )

Deleted: pkg/SASxport/R/importConvertDateTime.R
===================================================================
--- pkg/SASxport/R/importConvertDateTime.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/importConvertDateTime.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,21 +0,0 @@
-##
-## Code originally from Frank Harrell's 'Hmisc' library: 
-##   http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/Hmisc
-## Copied with permission on 2007-08-04
-##
-
-importConvertDateTime <- 
-  function(x, type=c('date','time','datetime'), input='sas', form)
-{
-  type <- match.arg(type)
-  input <- match.arg(input)
-
-  adjdays <- 3653   ## 1970-1-1 minus 1960-1-1
-
-  switch(type,
-         date = structure(x - adjdays, class='Date'), 
-         time = times(x/86400, out.format=c(dates='day mon year', times='h:m:s')),
-         datetime = chron((x - adjdays*86400)/86400,
-                          out.format=c(dates='day mon year', times='h:m:s'))
-         )
-}

Deleted: pkg/SASxport/R/in.opererator.R
===================================================================
--- pkg/SASxport/R/in.opererator.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/in.opererator.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,7 +0,0 @@
-##
-## Code originally from Frank Harrell's 'Hmisc' library: 
-##   http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/Hmisc
-## Copied with permission on 2007-08-04
-##
-
-"%nin%" <- function(a, b) ! (a %in% b)

Modified: pkg/SASxport/R/lookup.xport.R
===================================================================
--- pkg/SASxport/R/lookup.xport.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/lookup.xport.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,4 +1,7 @@
 ## Simply make this accessible here as a convenience to the user
+
+#' @export
+#' @importFrom utils download.file
 lookup.xport <- function(file)
   {
     fname <- file
@@ -18,6 +21,8 @@
     ret
   }
 
+
+#' @export
 print.lookup.xport <- function(x, ...)
   {
     Sinfo <- summary(x, ...)
@@ -25,6 +30,7 @@
   }
 
 
+#' @export
 summary.lookup.xport <- function(object, ...)
   {
     subFun <- function(XX)
@@ -52,6 +58,7 @@
     singleFrame
   }
 
+#' @export
 print.summary.lookup.xport <- function(x, ...)
 {
   cat("\n")

Deleted: pkg/SASxport/R/makeNames.R
===================================================================
--- pkg/SASxport/R/makeNames.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/makeNames.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,18 +0,0 @@
-##
-## Code originally from Frank Harrell's 'Hmisc' library:
-##   http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/Hmisc
-## Copied with permission on 2007-08-04
-##
-
-makeNames <- function(names, unique=FALSE, allow=NULL)
-{
-  # ## Runs make.names with exceptions in vector allow
-  # ## By default, R 1.9 make.names is overridden to convert _ to . as
-  # ## with S-Plus and previous versions of R.  Specify allow='_' otherwise.
-  # if(!.R. & length(allow))
-  #   stop('does not apply for S-Plus')
-  n <- make.names(names, unique)
-  if(!length(allow))
-    n <- gsub('_', '.', n)
-  n
-}

Modified: pkg/SASxport/R/makeSASNames.R
===================================================================
--- pkg/SASxport/R/makeSASNames.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/makeSASNames.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,3 +1,4 @@
+#' @export
 makeSASNames <- function(names, nchar=8, maxPasses=10, quiet=FALSE)
   {
     ## This function takes a vector of potential SAS dataset or
@@ -6,9 +7,9 @@
 
     # Step 0: converce to uppercase
     names <- toupper(names)
-
+    
     # Step 1: expand/truncate to 8 characters
-    tooLong <- nchar(names, "bytes")>8
+    tooLong <- nchar(names)>8
     if (any(tooLong))
       {
         shortNames <- substr(as.character(names), 1, nchar)
@@ -28,18 +29,18 @@
         passes <- passes+1
         dups <- duplicated(varNames)
         repeatCount <- table(varNames)-1
-        digitChars <- nchar(as.character(repeatCount), "bytes")+1
+        digitChars <- nchar(as.character(repeatCount))+1
         names(digitChars) <- names(repeatCount)
         newNames <- make.names(substr(varNames, 1, nchar-digitChars[varNames]), unique=TRUE)
         changed <- newNames != names
-
+        
         ##newNames[changed] <- gsub("\\.([0-9]+)$","\\1", newNames[changed])
         varNames <- newNames
       }
 
     if(any(duplicated(varNames)))
       stop("Unable to make all names unique after ", passes, " passes.")
-
+    
     if(any(dups) && !quiet)
       warning("Made ",sum(dups)," duplicate names unique.")
 

Added: pkg/SASxport/R/package.R
===================================================================
--- pkg/SASxport/R/package.R	                        (rev 0)
+++ pkg/SASxport/R/package.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -0,0 +1,3 @@
+
+#' @useDynLib SASxport
+NULL

Modified: pkg/SASxport/R/parseFormat.R
===================================================================
--- pkg/SASxport/R/parseFormat.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/parseFormat.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -17,7 +17,7 @@
                   {
                     retval$name <- substr(format,0,index-1)[1]
 
-                    lenStr <- substr(format, index, nchar(format, "bytes"))
+                    lenStr <- substr(format, index, nchar(format))
 
                     index <- regexpr("\\.", lenStr)
                     if(index==-1)
@@ -28,7 +28,7 @@
                     else
                       {
                         retval$len     <- as.numeric(substr(lenStr, 0, index-1))
-                        retval$digits  <- as.numeric(substr(lenStr, index+1, nchar(lenStr, "bytes")))
+                        retval$digits  <- as.numeric(substr(lenStr, index+1, nchar(lenStr)))
                       }
                   }
 

Modified: pkg/SASxport/R/process.formats.R
===================================================================
--- pkg/SASxport/R/process.formats.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/process.formats.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -31,7 +31,7 @@
                       if(!all(st==en))
                         stop("Format ranges are not handled.")
 
-                      list(value = all.is.numeric(st, 'vector'),
+                      list(value = Hmisc::all.is.numeric(st, 'vector'),
                            label = lab)
                     })
     finfo

Modified: pkg/SASxport/R/read.xport.R
===================================================================
--- pkg/SASxport/R/read.xport.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/read.xport.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -4,6 +4,10 @@
 ## Copied with permission on 2007-08-04
 ##
 
+#' @importFrom Hmisc label label<- label<-.default label<-.data.frame
+#' @importFrom utils download.file
+#' @export
+
 read.xport <- function(file,
                        force.integer=TRUE,
                        formats=NULL,
@@ -40,8 +44,8 @@
 
     scat("Checking if the specified file has the appropriate header")
     xport.file.header <- "HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!000000000000000000000000000000  "
-    file.header <- readBin( file, what=character(0), n=1, size=nchar(xport.file.header, "bytes") )
-    file.header <- substr(file.header, start=1, stop=nchar(xport.file.header, "bytes") )
+    file.header <- readBin( file, what=character(0), n=1, size=nchar(xport.file.header) )
+    file.header <- substr(file.header, start=1, stop=nchar(xport.file.header) )
     if( !identical(xport.file.header, file.header) )
       stop("The specified file does not start with a SAS xport file header!")
 
@@ -126,7 +130,7 @@
       SAStype(w) <- dsTypes[k]
       names(SAStype(w)) <- NULL
 
-      nam      <- names.tolower(makeNames(names(w), allow=name.chars))
+      nam      <- names.tolower(Hmisc::makeNames(names(w), allow=name.chars))
       names(w) <- nam
       dinfo    <- dsinfo[[k]]
 
@@ -138,7 +142,7 @@
 
       lab      <- dinfo$label
 
-      ndinfo   <- names.tolower(makeNames(dinfo$name, allow=name.chars))
+      ndinfo   <- names.tolower(Hmisc::makeNames(dinfo$name, allow=name.chars))
       names(lab) <- names(fmt) <- names(formats) <- names(iformats) <- ndinfo
       if(length(w)>0)
         for(i in 1:length(w)) {
@@ -157,13 +161,13 @@
 
           if(is.numeric(x)) {
             if(fi %in% sasdateform) {
-              x <- importConvertDateTime(x, 'date', 'sas')
+              x <- Hmisc::importConvertDateTime(x, 'date', 'sas')
               changed <- TRUE
             } else if(fi %in% sastimeform) {
-              x <- importConvertDateTime(x, 'time', 'sas')
+              x <- Hmisc::importConvertDateTime(x, 'time', 'sas')
               changed <- TRUE
             } else if(fi %in% sasdatetimeform) {
-              x <- importConvertDateTime(x, 'datetime', 'sas')
+              x <- Hmisc::importConvertDateTime(x, 'datetime', 'sas')
               changed <- TRUE
             } else if(force.integer) {
               if(all(is.na(x))) {

Modified: pkg/SASxport/R/scat.R
===================================================================
--- pkg/SASxport/R/scat.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/scat.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,6 +1,4 @@
-# $Id: scat.R 625 2005-06-09 14:20:30Z nj7w $
-
-# cat to stdout and immediately flush
+# Write message to stdout and immediately flush
 scat <- function(...)
   {
     DEBUG <- options()$DEBUG

Deleted: pkg/SASxport/R/testDateTime.R
===================================================================
--- pkg/SASxport/R/testDateTime.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/testDateTime.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,45 +0,0 @@
-##
-## Code originally from Frank Harrell's 'Hmisc' library:
-##   http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/Hmisc
-## Copied with permission on 2007-08-04
-##
-
-## Determine if variable is a date, time, or date/time variable in R
-## or S-Plus.  The following 2 functions are used by describe.vector
-## timeUsed assumes is date/time combination variable and has no NAs
-testDateTime <- function(x, what=c('either','both','timeVaries'))
-{
-  what <- match.arg(what)
-  cl <- class(x)  # was oldClass 22jun03
-  if(!length(cl))
-    return(FALSE)
-
-  # dc <- if(.R.)
-  #         c('Date', 'POSIXt','POSIXct','dates','times','chron')
-  #       else
-  #         c('timeDate','date','dates','times','chron')
-  dc <- c('Date', 'POSIXt','POSIXct','dates','times','chron')
-
-  # dtc <- if(.R.)
-  #          c('POSIXt','POSIXct','chron')
-  #        else
-  #          c('timeDate','chron')
-  dtc <- c('POSIXt','POSIXct','chron')
-
-  switch(what,
-         either = any(cl %in% dc),
-         both   = any(cl %in% dtc),
-         timeVaries = {
-           #if('chron' %in% cl || 'Date' %in% cl || !.R.) {
-           if('chron' %in% cl || 'Date' %in% cl) {
-             ## chron or S+ timeDate
-             y <- as.numeric(x)
-             length(unique(round(y - floor(y),13))) > 1
-           }
-           # else if(.R.)
-           else
-             length(unique(format(x,'%H%M%S'))) > 1
-           # else
-           #   FALSE
-         })
-}

Modified: pkg/SASxport/R/toSAS.R
===================================================================
--- pkg/SASxport/R/toSAS.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/toSAS.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,6 +1,9 @@
+#' @export
 toSAS <- function(x, format, format.info=NULL)
   UseMethod("toSAS")
 
+
+#' @export
 toSAS.numeric <- function(x, format=SASformat(x), format.info=NULL)
   {
     retval <- as.numeric(x)
@@ -8,14 +11,17 @@
     retval
   }
 
+
+#' @export
 toSAS.logical <- function(x, format=SASformat(x), format.info=NULL)
   {
     retval <- as.character(x)
     attr(retval, "SASformat")=format
     retval
   }
+
   
-
+#' @export
 toSAS.character <- function(x, format=SASformat(x), format.info=NULL)
   {
     retval <- as.character(x)
@@ -23,6 +29,8 @@
     retval
   }
 
+
+#' @export
 toSAS.factor <- function(x, format=SASformat(x), format.info=NULL)
   {
     finfo <- process.formats(format.info)
@@ -40,6 +48,8 @@
     retval
   }
 
+
+#' @export
 toSAS.POSIXt <- function( x, format="DATETIME16.", format.info=NULL)
   {
     sasBaseSeconds <- as.numeric(ISOdatetime(1960,1,1,0,0,0))
@@ -48,6 +58,8 @@
     retval
   }
 
+
+#' @export
 toSAS.Date <- function(x, format="DATE9.", format.info=NULL )
   {
     sasBase <- as.Date(strptime("01/01/1960", "%m/%d/%Y", tz="GMT")) # days
@@ -56,11 +68,15 @@
     retval
   }
 
+
+#' @export
 toSAS.default <- function(x, format=SASformat(x), format.info=NULL)
   {
     retval <- as.character(x)
     attr(retval, "SASformat") <- format
     retval
   }
-    
+
+
+#' @export
 toSAS.chron <- toSAS.POSIXt

Modified: pkg/SASxport/R/write.xport.R
===================================================================
--- pkg/SASxport/R/write.xport.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/write.xport.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,3 +1,5 @@
+#' @importFrom Hmisc label
+#' @export
 write.xport <- function(...,
                         list=base::list(),
                         file = stop("'file' must be specified"),
@@ -187,10 +189,19 @@
             df[[i]] <- var <- toSAS(var, format.info=formats)
 
             # compute variable length
-            if(is.character(var))
-              varLen <- max(c(8,nchar(var, "bytes") ) )
-            else
+            # From R 3.3.0 NA is returned by nchar if the 
+            # the argument is NA, unless keepNA = FALSE is supplied
+            # In older versions nchar(NA) is 2, and this is the
+            # behavior we need now
+            if(is.character(var)) {
+              if ("keepNA" %in% names(as.list(args(nchar)))) {
+                varLen <- max(c(8,nchar(var, keepNA = FALSE) ) )
+              } else {
+                varLen <- max(c(8,nchar(var) ) )
+              }
+            } else {
               varLen <- 8
+            }
 
             # fill in variable offset and length information
             offsetTable[i, "len"]    <- varLen

Modified: pkg/SASxport/R/xport.NA.R
===================================================================
--- pkg/SASxport/R/xport.NA.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/xport.NA.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,4 +1,3 @@
-
 xport.NA <- function()
   {
     .C("fill_numeric_NA", PACKAGE="SASxport")

Modified: pkg/SASxport/R/xport.R
===================================================================
--- pkg/SASxport/R/xport.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/xport.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -21,11 +21,13 @@
 ### License along with this program; if not, a copy is available at
 ### http://www.r-project.org/Licenses/
 
-lookup.xport.inner <- function(file) .Call(xport_info, file)
+lookup.xport.inner <- function(file) {
+  .Call('xport_info', file, PACKAGE = "SASxport")
+}
 
 read.xport.inner <- function(file, stringsAsFactors=FALSE) {
     data.info <- lookup.xport.inner(file)
-    ans <- .Call(xport_read, file, data.info)
+    ans <- .Call('xport_read', file, data.info, PACKAGE = "SASxport")
     if (length(ans) == 1L)
       as.data.frame(ans[[1L]], stringsAsFactors=stringsAsFactors)
     else

Modified: pkg/SASxport/R/xport.dateFMT.R
===================================================================
--- pkg/SASxport/R/xport.dateFMT.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/xport.dateFMT.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,5 +1,4 @@
-`xport.dateFMT` <-
-  function(when, fill=16)
+xport.dateFMT <- function(when, fill=16)
   {
     if(missing(when)) when <- Sys.time()
     

Modified: pkg/SASxport/R/xport.file.header.R
===================================================================
--- pkg/SASxport/R/xport.file.header.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/xport.file.header.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,5 +1,4 @@
-`xport.file.header` <-
-  function( cDate=Sys.time(), mDate=cDate, sasVer="7.00", osType="Unknown" )
+xport.file.header <- function( cDate=Sys.time(), mDate=cDate, sasVer="7.00", osType="Unknown" )
   {
     .C("fill_file_header",
        cDate = xport.dateFMT(cDate),           # Creation date
@@ -10,6 +9,5 @@
        )
 
     .Call("getRawBuffer", PACKAGE="SASxport")
-
   }
 

Modified: pkg/SASxport/R/xport.fill.R
===================================================================
--- pkg/SASxport/R/xport.fill.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/xport.fill.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,7 +1,5 @@
 xport.fill <- function( useSpace, width )
   {
-    
-    
     .C("fill_space",
        value = as.integer(useSpace),
        width = as.integer(width),

Modified: pkg/SASxport/R/xport.member.header.R
===================================================================
--- pkg/SASxport/R/xport.member.header.R	2016-08-24 19:48:14 UTC (rev 2144)
+++ pkg/SASxport/R/xport.member.header.R	2017-05-23 15:55:37 UTC (rev 2145)
@@ -1,6 +1,10 @@
-`xport.member.header` <- 
-function(dfName, cDate=Sys.time(), mDate=cDate, sasVer="7.00", osType="Unknown",
-         dfLabel="", dfType="" )
+xport.member.header <- function(dfName, 
+                                  cDate=Sys.time(), 
+                                  mDate=cDate, 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/r-gregmisc -r 2145


More information about the R-gregmisc-commits mailing list