Thread: [R-gregmisc-users] SF.net SVN: r-gregmisc:[1457] trunk/SASxport
Brought to you by:
warnes
From: <wa...@us...> - 2010-11-12 02:51:25
|
Revision: 1457 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1457&view=rev Author: warnes Date: 2010-11-12 02:51:19 +0000 (Fri, 12 Nov 2010) Log Message: ----------- Update for SASxport release 1.2.4 Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/ChangeLog trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2010-11-12 02:45:39 UTC (rev 1456) +++ trunk/SASxport/DESCRIPTION 2010-11-12 02:51:19 UTC (rev 1457) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.2.3 -Date: 2008-02-29 +Version: 1.2.4 +Date: 2010-11-11 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either @@ -11,9 +11,7 @@ variables of different data types are stored. Author: Unless otherwise noted, the contents of this package were written by - Gregory R. Warnes <gr...@ra...>, are - Copyright (c) 2007 by Random Technologies LLC - <http://random-technologies-llc.com>, and are provided under the + Gregory R. Warnes <gr...@wa...> and are provided under the terms of the GNU General Public License, version 2.0 or later. -- The files 'ieee2ibm.c' and 'ibm2ieee.c' were extracted from BRL-CAD, @@ -31,8 +29,8 @@ -- The creation of this package was partially funded by Metrum Institute <http://metruminstitute.org>. -Maintainer: Gregory R. Warnes <gr...@ra...> +Maintainer: Gregory R. Warnes <gr...@wa...> License: GPL-2 Depends: R (>= 2.4.0) Imports: chron -URL: http://random-technologies-llc.com, http://metruminstitute.org +URL: http://www.warnes.net, http://metruminstitute.org Modified: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog 2010-11-12 02:45:39 UTC (rev 1456) +++ trunk/SASxport/inst/ChangeLog 2010-11-12 02:51:19 UTC (rev 1457) @@ -1,3 +1,24 @@ +2010-11-12 02:41 warnes + + * [r1455] R/read.xport.R, R/xport.R: Fix bug: 'as.is=TRUE' argument + to read.xport was being ignored. + +2010-11-12 02:36 warnes + + * [r1454] tests/Alfalfa_Test.Rout.save, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.Rout.save, tests/datetime.xpt, tests/puromycin.xpt, + tests/testDates.Rout.save, tests/testNegative.Rout.save, + tests/testNumeric.Rout.save, tests/test_as_is.R, + tests/test_as_is.Rout.save, tests/test_fields.Rout.save, + tests/xport.Rout.save, tests/xxx.Rout.save: Add test for proper + function of as.is flag to read.xport + +2008-02-29 15:40 warnes + + * [r1245] DESCRIPTION, inst/ChangeLog, inst/NEWS: Update for + release 1.2.3 + 2008-02-29 15:37 warnes * [r1244] man/write.xport.Rd: Correct typo in write.xport man page Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2010-11-12 02:45:39 UTC (rev 1456) +++ trunk/SASxport/inst/NEWS 2010-11-12 02:51:19 UTC (rev 1457) @@ -1,3 +1,12 @@ +Version 1.2.4 2010-11-11 +------------------------ + +Bug fixes: + +- Fix bug in handling of 'as.is' argument to read.xport ('as.is=TRUE' + was not operating as documented). + + Version 1.2.3 2008-02-29 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2012-06-28 01:34:18
|
Revision: 1578 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1578&view=rev Author: warnes Date: 2012-06-28 01:34:11 +0000 (Thu, 28 Jun 2012) Log Message: ----------- Remove references to Random Technologies LLC and update email address. Modified Paths: -------------- trunk/SASxport/R/zzz.R trunk/SASxport/man/SASxport-package.Rd trunk/SASxport/src/ibm2ieee.c trunk/SASxport/src/ieee2ibm.c trunk/SASxport/src/init.c trunk/SASxport/src/test_fields.c trunk/SASxport/src/writeSAS.c trunk/SASxport/src/writeSAS.h Modified: trunk/SASxport/R/zzz.R =================================================================== --- trunk/SASxport/R/zzz.R 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/R/zzz.R 2012-06-28 01:34:11 UTC (rev 1578) @@ -5,9 +5,6 @@ date <- packageDescription("SASxport", fields="Date") cat("Loaded SASxport version ", ver, " (", date ,").\n", sep="") cat("\n") - cat(" Updates and technical support available from Random Technologies, LLC\n") - cat(" <http://random-technologies-llc.com/products/SASxport>\n") - cat("\n") cat(" Type `?SASxport' for usage information.\n") cat("\n") } Modified: trunk/SASxport/man/SASxport-package.Rd =================================================================== --- trunk/SASxport/man/SASxport-package.Rd 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/man/SASxport-package.Rd 2012-06-28 01:34:11 UTC (rev 1578) @@ -51,11 +51,10 @@ } } \author{ - Unless otherwise noted, the contents of this package were written by - Gregory R. Warnes \email{gr...@wa...}, are - Copyright (c) 2007 by Random Technologies LLC \cr - \url{http://random-technologies-llc.com}, and are provided under the - terms of the GNU General Public License, version 2.0 or later. + Unless otherwise noted, the contents of this package were written and + Copyright (C) 2007 by Gregory R. Warnes \email{gr...@wa...} and + are provided under the terms of the GNU General Public License, + version 2.0 or later. The file 'htond.c' is extracted from BRL-CAD \url{http://www.brlcad.org/}, written by Michael John Muuss, and is @@ -77,9 +76,4 @@ \section{Maintainer}{ Gregory R. Warnes \email{gr...@wa...} } -\section{Support}{ - Technical support contracts and other services for R, this package, - and other packages are available from Random Technologies LLC - \url{http://random-technologies-llc.com}. -} \keyword{package} Modified: trunk/SASxport/src/ibm2ieee.c =================================================================== --- trunk/SASxport/src/ibm2ieee.c 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/src/ibm2ieee.c 2012-06-28 01:34:11 UTC (rev 1578) @@ -6,8 +6,7 @@ * Copyright (c) 2004-2007 United States Government as represented by * the U.S. Army Research Laboratory. * - * * Minor changes (c) 2007 Random Technologies LLC by Gregory R. Warnes - * <gr...@ra...> + * * Minor changes (c) 2007 by Gregory R. Warnes <gr...@wa...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -146,7 +145,8 @@ /* After suitable testing, this check can be deleted */ if( (left & 0x00800000) == 0 ) { - fprintf(stderr,"ibm->ieee missing 1, left=x%x\n", left); + //fprintf(stderr, + error("ibm->ieee missing 1, left=x%x\n", left); left = (left<<1) | (right>>31); right <<= 1; goto ibm_normalized; Modified: trunk/SASxport/src/ieee2ibm.c =================================================================== --- trunk/SASxport/src/ieee2ibm.c 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/src/ieee2ibm.c 2012-06-28 01:34:11 UTC (rev 1578) @@ -6,8 +6,7 @@ * Copyright (c) 2004-2007 United States Government as represented by * the U.S. Army Research Laboratory. * - * Minor changes (c) 2007 Random Technologies LLC by Gregory R. Warnes - * <gr...@ra...> + * Minor changes (c) 2007 Gregory R. Warnes <gr...@wa...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License Modified: trunk/SASxport/src/init.c =================================================================== --- trunk/SASxport/src/init.c 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/src/init.c 2012-06-28 01:34:11 UTC (rev 1578) @@ -2,9 +2,9 @@ * * init.c: Routines to register SASxport C routines with R * - * Author: Gregory R. Warnes <gr...@ra...> + * Author: Gregory R. Warnes <gr...@wa...> * - * Copyright (C) 2007 Random Technologies LLC + * Copyright (C) 2007 Gregory R. Warnes * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by Modified: trunk/SASxport/src/test_fields.c =================================================================== --- trunk/SASxport/src/test_fields.c 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/src/test_fields.c 2012-06-28 01:34:11 UTC (rev 1578) @@ -2,9 +2,9 @@ * * test_fields.c: Unit test routines for writeSAS.c functions. * - * Author: Gregory R. Warnes <gr...@ra...> + * Author: Gregory R. Warnes <gr...@wa...> * - * Copyright (C) 2007 Random Technologies LLC + * Copyright (C) 2007 Gregory R. Warnes * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/src/writeSAS.c 2012-06-28 01:34:11 UTC (rev 1578) @@ -2,9 +2,9 @@ * * writeSAS.c: Routines for writing SAS XPT formatted files * - * Author: Gregory R. Warnes <gr...@ra...> + * Author: Gregory R. Warnes <gr...@wa...> * - * Copyright (C) 2007 Random Technologies LLC + * Copyright (C) 2007 Gregory R. Warnes <gr...@wa...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by Modified: trunk/SASxport/src/writeSAS.h =================================================================== --- trunk/SASxport/src/writeSAS.h 2012-06-28 00:49:06 UTC (rev 1577) +++ trunk/SASxport/src/writeSAS.h 2012-06-28 01:34:11 UTC (rev 1578) @@ -2,9 +2,9 @@ * * writeSAS.h: Routines for writing SAS XPT formatted files * - * Author: Gregory R. Warnes <gr...@ra...> + * Author: Gregory R. Warnes <gr...@wa...> * - * Copyright (C) 2007 Random Technologies LLC + * Copyright (C) 2007 Gregory R. Warnes <gr...@wa...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2012-06-28 01:42:59
|
Revision: 1580 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1580&view=rev Author: warnes Date: 2012-06-28 01:42:52 +0000 (Thu, 28 Jun 2012) Log Message: ----------- New makeSASNames() function creates valid SAS names from a list of R object or column names, properly handling case conversion (all converted to upper-case), length restructions (8 characters), and making duplicate names unique. This is not as obvious as it appears, since the process of shortening names can render cause name to become duplicates, and adding digits to the end of names to make them unique can make them too long, so a few iterations may be requireed to ensure valid and unique names. Modified Paths: -------------- trunk/SASxport/R/write.xport.R Added Paths: ----------- trunk/SASxport/R/makeSASNames.R trunk/SASxport/tests/testDuplicateNames.R trunk/SASxport/tests/testDuplicateNames.Rout.save trunk/SASxport/tests/testManyNames.R trunk/SASxport/tests/testManyNames.Rout.save Added: trunk/SASxport/R/makeSASNames.R =================================================================== --- trunk/SASxport/R/makeSASNames.R (rev 0) +++ trunk/SASxport/R/makeSASNames.R 2012-06-28 01:42:52 UTC (rev 1580) @@ -0,0 +1,46 @@ +makeSASNames <- function(names, nchar=8, maxPasses=10) + { + ## This function takes a vector of potential SAS dataset or + ## variable names and converts them into *unique* 8-character + ## names. + + # Step 0: converce to uppercase + names <- toupper(names) + + # Step 1: expand/truncate to 8 characters + tooLong <- nchar(names)>8 + if (any(tooLong)) + { + shortNames <- substr(as.character(names), 1, nchar) + warning("Truncated ", sum(tooLong), " long names to 8 characters.") + } + else + shortNames <- names + + # concievably, this could take a couple of iterations, because + # shortening the names to add digits may create new duplicates... + varNames <- shortNames + passes <- 0 + dups <- FALSE + while ( any(duplicated(varNames)) && passes<maxPasses ) + { + passes <- passes+1 + dups <- duplicated(varNames) + repeatCount <- table(varNames[dups]) + 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)) + warning("Made ",sum(dups)," duplicate names unique.") + + varNames + } Modified: trunk/SASxport/R/write.xport.R =================================================================== --- trunk/SASxport/R/write.xport.R 2012-06-28 01:37:19 UTC (rev 1579) +++ trunk/SASxport/R/write.xport.R 2012-06-28 01:42:52 UTC (rev 1580) @@ -88,33 +88,8 @@ ####### ## - scat("Check length of object names...\n") - long.names <- which(nchar(dfNames)>8) - if(length(long.names)>0) - { - old.names <- dfNames[long.names] - new.names <- substr(old.names, 1, 8 ) - - warning("Truncating object names with more than 8 characters. ", - paste(long.names, - ":'", - old.names, - "' --> '", - new.names, - "'", - sep="", - collapse=", " )) - - dfNames[long.names] <- new.names - } - - ####### - ## scat("Ensure object names are valid and unique...\n") - dfNames <- substr(make.names(dfNames, unique=TRUE),1,8) - if( all(names(dfList)!=dfNames)) - warning("Data frame names modified to obey SAS rules") - names(dfList) <- dfNames + names(dfList) <- dfNames <- makeSASNames(dfNames) ## ####### @@ -174,14 +149,9 @@ dfList[[i]] <- df } - varNames <- substr(make.names(colnames(df), unique=TRUE),1,8) - if( any(colnames(df)!=varNames)) - { - warning("Variable names modified to obey SAS rules") - colnames(df) <- varNames - dfList[[i]] <- df - } - + + colnames(dfList[[i]]) <- colnames(df) <- varNames <- makeSASNames(colnames(df)) + offsetTable <- data.frame("name"=varNames, "len"=NA, "offset"=NA ) rownames(offsetTable) <- offsetTable[,"name"] Added: trunk/SASxport/tests/testDuplicateNames.R =================================================================== --- trunk/SASxport/tests/testDuplicateNames.R (rev 0) +++ trunk/SASxport/tests/testDuplicateNames.R 2012-06-28 01:42:52 UTC (rev 1580) @@ -0,0 +1,16 @@ +library(SASxport) + + +##tests +example(read.xport) + +# Duplicate df names +write.xport("AA"=w$test,"Aa"=w$test,"aA"=w$test,"aa"=w$test, file="dn.a.xpt") #1.a +read.xport("dn.a.xpt") + +# Duplicate column names +a = w$test +b = w$test +colnames(b) <- tolower(colnames(b)) +write.xport("combined"=cbind(a, b), file="dn.b.xpt") +read.xport("dn.b.xpt") Added: trunk/SASxport/tests/testDuplicateNames.Rout.save =================================================================== --- trunk/SASxport/tests/testDuplicateNames.Rout.save (rev 0) +++ trunk/SASxport/tests/testDuplicateNames.Rout.save 2012-06-28 01:42:52 UTC (rev 1580) @@ -0,0 +1,159 @@ + +R version 2.15.0 (2012-03-30) +Copyright (C) 2012 The R Foundation for Statistical Computing +ISBN 3-900051-07-0 +Platform: i386-apple-darwin9.8.0/i386 (32-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(SASxport) + +Loaded SASxport version 1.3.0 (2012-06-21). + + Type `?SASxport' for usage information. + +> +> +> ##tests +> example(read.xport) + +rd.xpr> # ------- +rd.xpr> # SAS code to generate test dataset: +rd.xpr> # ------- +rd.xpr> # libname y SASV5XPT "test2.xpt"; +rd.xpr> # +rd.xpr> # PROC FORMAT; VALUE race 1=green 2=blue 3=purple; RUN; +rd.xpr> # PROC FORMAT CNTLOUT=format;RUN; * Name, e.g. 'format', unimportant; +rd.xpr> # data test; +rd.xpr> # LENGTH race 3 age 4; +rd.xpr> # age=30; label age="Age at Beginning of Study"; +rd.xpr> # race=2; +rd.xpr> # d1='3mar2002'd ; +rd.xpr> # dt1='3mar2002 9:31:02'dt; +rd.xpr> # t1='11:13:45't; +rd.xpr> # output; +rd.xpr> # +rd.xpr> # age=31; +rd.xpr> # race=4; +rd.xpr> # d1='3jun2002'd ; +rd.xpr> # dt1='3jun2002 9:42:07'dt; +rd.xpr> # t1='11:14:13't; +rd.xpr> # output; +rd.xpr> # format d1 mmddyy10. dt1 datetime. t1 time. race race.; +rd.xpr> # run; +rd.xpr> # data z; LENGTH x3 3 x4 4 x5 5 x6 6 x7 7 x8 8; +rd.xpr> # DO i=1 TO 100; +rd.xpr> # x3=ranuni(3); +rd.xpr> # x4=ranuni(5); +rd.xpr> # x5=ranuni(7); +rd.xpr> # x6=ranuni(9); +rd.xpr> # x7=ranuni(11); +rd.xpr> # x8=ranuni(13); +rd.xpr> # output; +rd.xpr> # END; +rd.xpr> # DROP i; +rd.xpr> # RUN; +rd.xpr> # PROC MEANS; RUN; +rd.xpr> # PROC COPY IN=work OUT=y;SELECT test format z;RUN; *Creates test2.xpt; +rd.xpr> # ------ +rd.xpr> +rd.xpr> # Read this dataset from a local file: +rd.xpr> ## Not run: +rd.xpr> ##D w <- read.xport('test2.xpt') +rd.xpr> ## End(Not run) +rd.xpr> +rd.xpr> # Or read a copy of test2.xpt available on the web: +rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' + +rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' + +rd.xpr> url <- paste(host,path,sep="") + +rd.xpr> w <- read.xport(url) + +rd.xpr> # We can also get the dataset wrapped in a list +rd.xpr> w <- read.xport(url, as.list=TRUE) + +rd.xpr> # And we can ask for the format information to be included as well. +rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) + +rd.xpr> ## Don't show: +rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) + +rd.xpr> ## End Don't show +rd.xpr> +rd.xpr> +rd.xpr> ## Not run: +rd.xpr> ##D ## The Hmisc library provides many useful functions for interacting with +rd.xpr> ##D ## data imported from SAS via read.xport() +rd.xpr> ##D library(Hmisc) +rd.xpr> ##D +rd.xpr> ##D describe(w$test) # see labels, format names for dataset test +rd.xpr> ##D lapply(w, describe)# see descriptive stats in more detaiil for each variable +rd.xpr> ##D +rd.xpr> ##D contents(w$test) # another way to see variable attributes +rd.xpr> ##D lapply(w, contents)# show contents of individual items in more detail +rd.xpr> ##D +rd.xpr> ##D options(digits=7) # compare the following matrix with PROC MEANS output +rd.xpr> ##D t(sapply(w$z, function(x) +rd.xpr> ##D c(Mean=mean(x),SD=sqrt(var(x)),Min=min(x),Max=max(x)))) +rd.xpr> ## End(Not run) +rd.xpr> +rd.xpr> +rd.xpr> +rd.xpr> +> +> # Duplicate df names +> write.xport("AA"=w$test,"Aa"=w$test,"aA"=w$test,"aa"=w$test, file="dn.a.xpt") #1.a +Warning message: +In makeSASNames(dfNames) : Made 3 duplicate names unique. +> read.xport("dn.a.xpt") +$aa + RACE AGE D1 DT1 T1 +1 blue 30 2002-03-03 (03 Mar 2002 04:31:02) 11:13:45 +2 31 2002-06-03 (03 Jun 2002 04:42:07) 11:14:13 + +$aa.1 + RACE AGE D1 DT1 T1 +1 blue 30 2002-03-03 (03 Mar 2002 04:31:02) 11:13:45 +2 31 2002-06-03 (03 Jun 2002 04:42:07) 11:14:13 + +$aa.2 + RACE AGE D1 DT1 T1 +1 blue 30 2002-03-03 (03 Mar 2002 04:31:02) 11:13:45 +2 31 2002-06-03 (03 Jun 2002 04:42:07) 11:14:13 + +$aa.3 + RACE AGE D1 DT1 T1 +1 blue 30 2002-03-03 (03 Mar 2002 04:31:02) 11:13:45 +2 31 2002-06-03 (03 Jun 2002 04:42:07) 11:14:13 + +> +> # Duplicate column names +> a = w$test +> b = w$test +> colnames(b) <- tolower(colnames(b)) +> write.xport("combined"=cbind(a, b), file="dn.b.xpt") +Warning message: +In makeSASNames(colnames(df)) : Made 5 duplicate names unique. +> read.xport("dn.b.xpt") + RACE AGE D1 DT1 T1 RACE.1 AGE.1 D1.1 +1 blue 30 2002-03-03 (03 Mar 2002 04:31:02) 11:13:45 blue 30 2002-03-03 +2 31 2002-06-03 (03 Jun 2002 04:42:07) 11:14:13 31 2002-06-03 + DT1.1 T1.1 +1 (03 Mar 2002 04:31:02) 11:13:45 +2 (03 Jun 2002 04:42:07) 11:14:13 +> +> proc.time() + user system elapsed + 0.430 0.031 2.232 Added: trunk/SASxport/tests/testManyNames.R =================================================================== --- trunk/SASxport/tests/testManyNames.R (rev 0) +++ trunk/SASxport/tests/testManyNames.R 2012-06-28 01:42:52 UTC (rev 1580) @@ -0,0 +1,30 @@ +library(SASxport) + +data(iris) + +# to 'stress test' use 200 instead of 20 +ncopies <- 20 + +## create a data file containing ncopies separate copies of the iris *dataframe* +manyDF.out <- rep(list(iris),ncopies) +names(manyDF.out) <- rep("iris", ncopies) +manyDF.out$file <- "manyDF.xport" + +do.call(write.xport, manyDF.out) +manyDF.in <- read.xport(file="manyDF.xport") +names(manyDF.in) +head(manyDF.in[[ncopies]]) +tail(manyDF.in[[ncopies]]) +stopifnot( all( sapply(manyDF.in, dim)==c(150,5) ) ) +stopifnot( all( sapply(manyDF.in, colnames) == colnames(manyDF.in[[ncopies]]) ) ) + +## create a data file containing a single dataframe that holds ncopies copies of +## the *columns* of the iris dataframe +manyCols.out <- do.call(cbind, rep(list(iris),ncopies)) +dim(manyCols.out) +write.xport(manyCols.out, file="manyCols.xport") + +manyCols.in <- read.xport("manyCols.xport") +names(manyCols.in) +stopifnot(dim(manyCols.in)==dim(manyCols.out)) + Added: trunk/SASxport/tests/testManyNames.Rout.save =================================================================== --- trunk/SASxport/tests/testManyNames.Rout.save (rev 0) +++ trunk/SASxport/tests/testManyNames.Rout.save 2012-06-28 01:42:52 UTC (rev 1580) @@ -0,0 +1,98 @@ + +R version 2.15.0 (2012-03-30) +Copyright (C) 2012 The R Foundation for Statistical Computing +ISBN 3-900051-07-0 +Platform: i386-apple-darwin9.8.0/i386 (32-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(SASxport) + +Loaded SASxport version 1.3.0 (2012-06-21). + + Type `?SASxport' for usage information. + +> +> data(iris) +> +> # to 'stress test' use 200 instead of 20 +> ncopies <- 20 +> +> ## create a data file containing ncopies separate copies of the iris *dataframe* +> manyDF.out <- rep(list(iris),ncopies) +> names(manyDF.out) <- rep("iris", ncopies) +> manyDF.out$file <- "manyDF.xport" +> +> do.call(write.xport, manyDF.out) +There were 21 warnings (use warnings() to see them) +> manyDF.in <- read.xport(file="manyDF.xport") +> names(manyDF.in) + [1] "iris" "iris.1" "iris.2" "iris.3" "iris.4" "iris.5" "iris.6" + [8] "iris.7" "iris.8" "iris.9" "iris.10" "iris.11" "iris.12" "iris.13" +[15] "iris.14" "iris.15" "iris.16" "iris.17" "iris.18" "iris.19" +> head(manyDF.in[[ncopies]]) + SEPAL.LE SEPAL.WI PETAL.LE PETAL.WI SPECIES +1 5.1 3.5 1.4 0.2 setosa +2 4.9 3.0 1.4 0.2 setosa +3 4.7 3.2 1.3 0.2 setosa +4 4.6 3.1 1.5 0.2 setosa +5 5.0 3.6 1.4 0.2 setosa +6 5.4 3.9 1.7 0.4 setosa +> tail(manyDF.in[[ncopies]]) + SEPAL.LE SEPAL.WI PETAL.LE PETAL.WI SPECIES +145 6.7 3.3 5.7 2.5 virginica +146 6.7 3.0 5.2 2.3 virginica +147 6.3 2.5 5.0 1.9 virginica +148 6.5 3.0 5.2 2.0 virginica +149 6.2 3.4 5.4 2.3 virginica +150 5.9 3.0 5.1 1.8 virginica +> stopifnot( all( sapply(manyDF.in, dim)==c(150,5) ) ) +> stopifnot( all( sapply(manyDF.in, colnames) == colnames(manyDF.in[[ncopies]]) ) ) +> +> ## create a data file containing a single dataframe that holds ncopies copies of +> ## the *columns* of the iris dataframe +> manyCols.out <- do.call(cbind, rep(list(iris),ncopies)) +> dim(manyCols.out) +[1] 150 100 +> write.xport(manyCols.out, file="manyCols.xport") +Warning messages: +1: In makeSASNames(dfNames) : Truncated 1 long names to 8 characters. +2: In makeSASNames(colnames(df)) : + Truncated 80 long names to 8 characters. +3: In makeSASNames(colnames(df)) : Made 95 duplicate names unique. +> +> manyCols.in <- read.xport("manyCols.xport") +> names(manyCols.in) + [1] "SEPAL" "SEPAL.1" "PETAL" "PETAL.1" "SPECI" "SEPAL.2" + [7] "SEPAL.3" "PETAL.2" "PETAL.3" "SPECI.1" "SEPAL.4" "SEPAL.5" + [13] "PETAL.4" "PETAL.5" "SPECI.2" "SEPAL.6" "SEPAL.7" "PETAL.6" + [19] "PETAL.7" "SPECI.3" "SEPAL.8" "SEPAL.9" "PETAL.8" "PETAL.9" + [25] "SPECI.4" "SEPAL.10" "SEPAL.11" "PETAL.10" "PETAL.11" "SPECI.5" + [31] "SEPAL.12" "SEPAL.13" "PETAL.12" "PETAL.13" "SPECI.6" "SEPAL.14" + [37] "SEPAL.15" "PETAL.14" "PETAL.15" "SPECI.7" "SEPAL.16" "SEPAL.17" + [43] "PETAL.16" "PETAL.17" "SPECI.8" "SEPAL.18" "SEPAL.19" "PETAL.18" + [49] "PETAL.19" "SPECI.9" "SEPAL.20" "SEPAL.21" "PETAL.20" "PETAL.21" + [55] "SPECI.10" "SEPAL.22" "SEPAL.23" "PETAL.22" "PETAL.23" "SPECI.11" + [61] "SEPAL.24" "SEPAL.25" "PETAL.24" "PETAL.25" "SPECI.12" "SEPAL.26" + [67] "SEPAL.27" "PETAL.26" "PETAL.27" "SPECI.13" "SEPAL.28" "SEPAL.29" + [73] "PETAL.28" "PETAL.29" "SPECI.14" "SEPAL.30" "SEPAL.31" "PETAL.30" + [79] "PETAL.31" "SPECI.15" "SEPAL.32" "SEPAL.33" "PETAL.32" "PETAL.33" + [85] "SPECI.16" "SEPAL.34" "SEPAL.35" "PETAL.34" "PETAL.35" "SPECI.17" + [91] "SEPAL.36" "SEPAL.37" "PETAL.36" "PETAL.37" "SPECI.18" "SEPAL.38" + [97] "SEPAL.39" "PETAL.38" "PETAL.39" "SPECI.19" +> stopifnot(dim(manyCols.in)==dim(manyCols.out)) +> +> +> proc.time() + user system elapsed + 6.985 0.068 7.099 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2012-06-29 18:10:40
|
Revision: 1588 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1588&view=rev Author: warnes Date: 2012-06-29 18:10:34 +0000 (Fri, 29 Jun 2012) Log Message: ----------- Update DESCRIPTION and NEWS for SASxport 1.3.0 Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2012-06-29 18:08:33 UTC (rev 1587) +++ trunk/SASxport/DESCRIPTION 2012-06-29 18:10:34 UTC (rev 1588) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.2.4 -Date: 2010-11-11 +Version: 1.3.0 +Date: 2012-06-29 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2012-06-29 18:08:33 UTC (rev 1587) +++ trunk/SASxport/inst/NEWS 2012-06-29 18:10:34 UTC (rev 1588) @@ -1,3 +1,19 @@ +Version 1.3.0 2012-06-27 +------------------------ + +New features: + +- New function makeSASNames() to create valid and unique SAS names + from character vectors. + +Bug fixes: + +- Improper handling of duplicates names in write.xport() was + generating names longer than 8 characters, resulting in invalid + files. Corrected by using the new makeSASNames() function instead + of the R make.names() function. + + Version 1.2.4 2010-11-11 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2012-06-29 19:03:33
|
Revision: 1593 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1593&view=rev Author: warnes Date: 2012-06-29 19:03:27 +0000 (Fri, 29 Jun 2012) Log Message: ----------- Create inst/extdata directory to hold example file Alfalfa.xpt. Modified Paths: -------------- trunk/SASxport/man/Alfalfa.Rd trunk/SASxport/man/lookup.xport.Rd Added Paths: ----------- trunk/SASxport/inst/extdata/ trunk/SASxport/inst/extdata/Alfalfa.xpt Added: trunk/SASxport/inst/extdata/Alfalfa.xpt =================================================================== (Binary files differ) Property changes on: trunk/SASxport/inst/extdata/Alfalfa.xpt ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/SASxport/man/Alfalfa.Rd =================================================================== --- trunk/SASxport/man/Alfalfa.Rd 2012-06-29 19:02:14 UTC (rev 1592) +++ trunk/SASxport/man/Alfalfa.Rd 2012-06-29 19:03:27 UTC (rev 1593) @@ -30,7 +30,7 @@ # go were the data is... here <- getwd() -setwd(file.path(.path.package("SASxport"),"data")) +setwd(file.path(.path.package("SASxport"),"extdata")) # Description of the file contents lookup.xport("Alfalfa.xpt") Modified: trunk/SASxport/man/lookup.xport.Rd =================================================================== --- trunk/SASxport/man/lookup.xport.Rd 2012-06-29 19:02:14 UTC (rev 1592) +++ trunk/SASxport/man/lookup.xport.Rd 2012-06-29 19:03:27 UTC (rev 1593) @@ -45,7 +45,7 @@ } \examples{ \dontshow{ -setwd(file.path(.path.package("SASxport"),"data")) +setwd(file.path(.path.package("SASxport"),"extData")) } ## Get information on a local file lookup.xport("Alfalfa.xpt") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-03-24 05:43:00
|
Revision: 1649 http://sourceforge.net/p/r-gregmisc/code/1649 Author: warnes Date: 2013-03-24 05:42:57 +0000 (Sun, 24 Mar 2013) Log Message: ----------- Update for release 1.3.1 Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2013-03-24 05:41:53 UTC (rev 1648) +++ trunk/SASxport/DESCRIPTION 2013-03-24 05:42:57 UTC (rev 1649) @@ -1,34 +1,34 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.3.0 -Date: 2012-06-29 +Version: 1.3.1 +Date: 2013-03-24 Description: This package provides functions for reading, listing - the contents of, and writing SAS xport format files. + 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: + variables of different data types are stored. +Author: Unless otherwise noted, the contents of this package were written by Gregory R. Warnes <gr...@wa...> and are provided under the - terms of the GNU General Public License, version 2.0 or later. + terms of the GNU General Public License, version 2.0 or later. -- - The files 'ieee2ibm.c' and 'ibm2ieee.c' were extracted from BRL-CAD, - file /brlcad/src/libbu/htond.c written by Michael John Muuss, + The files 'ieee2ibm.c' and '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 'AFirst.lib.s', 'all.is.numeric.R', - 'importConvertDateTime.R', 'in.opererator.R', 'makeNames.R', + 'importConvertDateTime.R', 'in.opererator.R', 'makeNames.R', 'read.xport.R', and 'testDateTime.R' are copied or adapted from the - 'Hmisc' package created by Frank E. Harrell, Jr. + 'Hmisc' package created by Frank E. Harrell, Jr. <f.h...@va...>, and are utilized and redistributed under - the terms of the GNU General Public License, version 2.0 or later. - -- + 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>. + <http://metruminstitute.org>. Maintainer: Gregory R. Warnes <gr...@wa...> License: GPL-2 Depends: R (>= 2.4.0) Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2013-03-24 05:41:53 UTC (rev 1648) +++ trunk/SASxport/inst/NEWS 2013-03-24 05:42:57 UTC (rev 1649) @@ -1,3 +1,10 @@ +Version 1.3.1 2013-03-24 +------------------------ + +Changes: + +- Replace use of depreciated .path.package() with path.package() for R 3.0.0. + Version 1.3.0 2012-06-27 ------------------------ @@ -37,7 +44,7 @@ Bug fixes: - Apply patches to fix problems on 64 bit platforms, as sumitted by - Brian Ripley. + Brian Ripley. Version 1.2.1 2007-11-05 @@ -63,27 +70,27 @@ - Copies of the code for foreign::read.xport and foreign::lookup.xport is now part of the SASxport package, permitting extension to these functions as needed, and removing the dependency on the foreign - package. + package. - Overflow of SASxport numeric format values, which have a smaller range than IEEE 754 numeric values now standard, now generates NAN - instead of 0.0. + instead of 0.0. Bug Fixes: - Fix for problem storing negative numbers. -- SAS format length and digit information is now properly captured +- SAS format length and digit information is now properly captured by read.xport(). This is supported by an improved version of - lookup.xport(). + lookup.xport(). -- SAS format information was not being properly utilized when more +- SAS format information was not being properly utilized when more than one format was present. - Improved handling of SAS date formats - + Other: - Test routines added to test handling of numeric values. @@ -95,7 +102,7 @@ - Display support information at package startup -Version 1.1.0 - +Version 1.1.0 - ------------------------- New Features: @@ -133,7 +140,7 @@ New features: - read.xport's names.tolower argument now defaults to FALSE so that - variable (and data set) names are now left as uppercase. + variable (and data set) names are now left as uppercase. - Improved crediting of BRL-CAD source code @@ -143,7 +150,7 @@ Other: -- Augmented ieee2ibm code with corresponding ibm2ieee code for +- Augmented ieee2ibm code with corresponding ibm2ieee code for completeness. @@ -152,7 +159,7 @@ New Features: -- Replaced IEEE to IBM translation code with GPL'ed version from BPL-CAD. +- Replaced IEEE to IBM translation code with GPL'ed version from BPL-CAD. Bug Fixes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-05-11 23:41:38
|
Revision: 1658 http://sourceforge.net/p/r-gregmisc/code/1658 Author: warnes Date: 2013-05-11 23:41:36 +0000 (Sat, 11 May 2013) Log Message: ----------- Add support for dataset labels and types Modified Paths: -------------- trunk/SASxport/NAMESPACE trunk/SASxport/R/write.xport.R trunk/SASxport/R/xport.member.header.R trunk/SASxport/man/label.Rd trunk/SASxport/src/SASxport.c trunk/SASxport/src/SASxport.h trunk/SASxport/src/init.c trunk/SASxport/src/writeSAS.c trunk/SASxport/src/writeSAS.h Added Paths: ----------- trunk/SASxport/R/SAStype.R Modified: trunk/SASxport/NAMESPACE =================================================================== --- trunk/SASxport/NAMESPACE 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/NAMESPACE 2013-05-11 23:41:36 UTC (rev 1658) @@ -17,9 +17,12 @@ "SASformat<-", "SASiformat", - "SASiformat<-" - ) + "SASiformat<-", + "SAStype", + "SAStype<-" +) + S3method(toSAS, numeric) S3method(toSAS, logical) S3method(toSAS, character) @@ -32,10 +35,12 @@ S3method(label, default) S3method(SASformat, default) S3method(SASiformat, default) +S3method(SAStype, data.frame) S3method("label<-", default) S3method("SASformat<-", default) S3method("SASiformat<-", default) +S3method("SAStype<-", data.frame) S3method(print, lookup.xport) S3method(summary, lookup.xport) Added: trunk/SASxport/R/SAStype.R =================================================================== --- trunk/SASxport/R/SAStype.R (rev 0) +++ trunk/SASxport/R/SAStype.R 2013-05-11 23:41:36 UTC (rev 1658) @@ -0,0 +1,20 @@ +SAStype <- function(x, default) + UseMethod("SAStype") + +SAStype.data.frame <- function(x, default=NULL) +{ + lab <- attr(x,"SAStype") + if(is.null(lab)) + default + else + lab +} + +"SAStype<-" <- function(x, value) + UseMethod("SAStype<-") + +"SAStype<-.data.frame" <- function(x, value) +{ + attr(x,'SAStype') <- value + x +} Modified: trunk/SASxport/R/write.xport.R =================================================================== --- trunk/SASxport/R/write.xport.R 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/R/write.xport.R 2013-05-11 23:41:36 UTC (rev 1658) @@ -155,8 +155,12 @@ offsetTable <- data.frame("name"=varNames, "len"=NA, "offset"=NA ) rownames(offsetTable) <- offsetTable[,"name"] + dfLabel <- label(df, default="" ) + dfType <- SAStype(df, default="") + scat("Write data frame header ...") - out( xport.member.header(dfName=i, cDate=cDate, sasVer=sasVer, osType=osType ) ) + out( xport.member.header(dfName=i, cDate=cDate, sasVer=sasVer, osType=osType, + dfLabel=dfLabel, dfType=dfType) ) scat("Done.") scat("Write variable information block header ...") Modified: trunk/SASxport/R/xport.member.header.R =================================================================== --- trunk/SASxport/R/xport.member.header.R 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/R/xport.member.header.R 2013-05-11 23:41:36 UTC (rev 1658) @@ -1,12 +1,15 @@ `xport.member.header` <- -function( dfName, cDate=Sys.time(), mDate=cDate, sasVer="7.00", osType="Unknown" ) +function(dfName, cDate=Sys.time(), mDate=cDate, sasVer="7.00", osType="Unknown", + dfLabel="", dfType="" ) { .C("fill_member_header", dfName = toupper(as.character(dfName)), # Name of data set sasVer = toupper(as.character(sasVer)), # SAS version number osType = as.character(osType), # Operating System (can include lowercase) - cDate = xport.dateFMT(cDate), # Creation date - mDate = xport.dateFMT(mDate), # modification date + cDate = xport.dateFMT(cDate), # Creation date + mDate = xport.dateFMT(mDate), # modification date + dfLabel= as.character(dfLabel), # Data set label + dfType = as.character(dfType), # Data set type PACKAGE="SASxport" ) Modified: trunk/SASxport/man/label.Rd =================================================================== --- trunk/SASxport/man/label.Rd 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/man/label.Rd 2013-05-11 23:41:36 UTC (rev 1658) @@ -15,13 +15,18 @@ \alias{SASiformat<-} \alias{SASiformat<-.default} +\alias{SAStype} +\alias{SAStype.default} +\alias{SAStype<-} +\alias{SAStype<-.default} \title{ -Set or Retreive the 'label', 'SASformat', or 'SASiformat' Attribute of a Vector +Set or Retreive the 'label', 'SASformat', 'SASiformat', or 'SAStype' +attribute of a vector or (components of) a data frame } \description{ - Sets or retrieves the \code{"label"}, \code{"SASformat"}, or - \code{"SASiformat"} attribute of an object. + Sets or retrieves the \code{"label"}, \code{"SASformat"}, + \code{"SASiformat"}, or \code{SAStype} attribute of an object. More comprehensive support for object labels, and SASformat, are available in Frank Harrell's \code{Hmisc} package. @@ -36,18 +41,20 @@ SASiformat(x, default) SASiformat(x) <- value +SAStype(x, default) +SAStype(x) <- value } \arguments{ \item{x}{any object} -\item{value}{new value for the \code{"label"}, \code{"SASformat"}, or - \code{"SASiformat"} attribute of an object.} +\item{value}{new value for the \code{"label"}, \code{"SASformat"}, + \code{"SASiformat"}, or \code{SAStype} attribute of an object.} \item{default}{value to return when no appropriate attribute is found. The usual return value is NULL.} } \value{ - the contents of the \code{"label"}, \code{"SASformat"}, or - \code{"SASiformat"} attribute of x, if any; otherwise, the value provided - by \code{default}. + the contents of the \code{"label"}, \code{"SASformat"}, + \code{"SASiformat"}, \code{"SAStype"} attribute of x, if any; + otherwise, the value provided by \code{default}. } \author{ Gregory R. Warnes \email{gr...@wa...} based on code from the @@ -57,6 +64,8 @@ %} \examples{ +## Examples for vectors + fail.time <- c(10,20) # set attributes @@ -72,20 +81,24 @@ # display all attributes attributes(fail.time) -# Example showing specification of default return value +## SAStype only applies to data frames +df <- data.frame( fail.time, day=c("Mon","Tue") ) +label(df) <- "Data frame object" +SAStype(df) <- "USER" + +label(df) +SAStype(df) + +## Example showing specification of default return value a <- 70 label(a, default="no label") - \dontrun{ -# for a nice display +# Hmisc packages functions label attributes for annotating tables and plots: library(Hmisc) +label(fail.time) describe(fail.time) - -f <- cph(Surv(fail.time, event) ~ xx) -plot(xx,xx2,xlab=label(xx),"s",sep="")) } - } \keyword{utilities} \keyword{interface} Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/src/SASxport.c 2013-05-11 23:41:36 UTC (rev 1658) @@ -194,9 +194,12 @@ n = GET_RECORD(record, fp, 80); if(n != 80) return 0; + record[80] = '\0'; memcpy(member->sas_mod, record, 16); - if((strrchr(record+16, ' ') - record) != 79) - return 0; + + memcpy(member->sas_dslabel, record+32, 40); + memcpy(member->sas_dstype, record+72, 8); + return 1; } @@ -230,7 +233,7 @@ } static int -init_mem_info(FILE *fp, char *name) +init_mem_info(FILE *fp, char *name, char *dslabel, char *dstype) { int length, n; char record[81]; @@ -253,6 +256,7 @@ record[58] = '\0'; sscanf(record+54, "%d", &length); + /* Extract data set name */ tmp = strchr(mem_head->sas_dsname, ' '); n = tmp - mem_head->sas_dsname; if(n > 0) { @@ -262,6 +266,26 @@ name[n] = '\0'; } else name[0] = '\0'; + /* Extract data set label */ + tmp = strchr(mem_head->sas_dslabel, ' '); + n = tmp - mem_head->sas_dslabel; + if(n > 0) { + if (n > 40) + n = 40; + strncpy(dslabel, mem_head->sas_dslabel, n); + dslabel[n] = '\0'; + } else dslabel[0] = '\0'; + + /* Extract data set type */ + tmp = strchr(mem_head->sas_dstype, ' '); + n = tmp - mem_head->sas_dstype; + if(n > 0) { + if (n > 40) + n = 40; + strncpy(dstype, mem_head->sas_dstype, n); + dstype[n] = '\0'; + } else dstype[0] = '\0'; + Free(mem_head); return length; @@ -542,8 +566,11 @@ FILE *fp; int i, namestrLength, memLength, ansLength; char dsname[9]; + char dslabel[41]; + char dstype[9]; SEXP ans, ansNames, varInfoNames, varInfo; SEXP char_numeric, char_character; + SEXP dfLabel, dfType; PROTECT(varInfoNames = allocVector(STRSXP, VAR_INFO_LENGTH)); for(i = 0; i < VAR_INFO_LENGTH; i++) @@ -561,13 +588,18 @@ ansLength = 0; PROTECT(ans = allocVector(VECSXP, 0)); - PROTECT(ansNames = allocVector(STRSXP, 0)); + PROTECT(ansNames = allocVector(STRSXP, 0)); - while(namestrLength > 0 && (memLength = init_mem_info(fp, dsname)) > 0) { + while(namestrLength > 0 && (memLength = init_mem_info(fp, dsname, dslabel, dstype)) > 0) { PROTECT(varInfo = allocVector(VECSXP, VAR_INFO_LENGTH)); setAttrib(varInfo, R_NamesSymbol, varInfoNames); + PROTECT(dfLabel = mkChar(dslabel)); + PROTECT(dfType = mkChar(dstype) ); + setAttrib(varInfo, install("label" ), dfLabel); + setAttrib(varInfo, install("SAStype"), dfType ); + SET_XPORT_VAR_TYPE(varInfo, allocVector(STRSXP, memLength)); SET_XPORT_VAR_WIDTH(varInfo, allocVector(INTSXP, memLength)); SET_XPORT_VAR_INDEX(varInfo, allocVector(INTSXP, memLength)); @@ -611,7 +643,8 @@ char_character); } PROTECT(ans = lengthgets(ans, ansLength+1)); - PROTECT(ansNames = lengthgets(ansNames, ansLength+1)); + PROTECT(ansNames = lengthgets(ansNames, ansLength+1)); + /* PROTECT(newAns = allocVector(VECSXP, ansLength+1)); */ /* PROTECT(newAnsNames = allocVector(STRSXP, ansLength+1)); */ @@ -622,15 +655,16 @@ /* ans = newAns; */ /* ansNames = newAnsNames; */ - SET_STRING_ELT(ansNames, ansLength, mkChar(dsname)); + SET_STRING_ELT(ansNames , ansLength, mkChar(dsname )); SET_VECTOR_ELT(ans, ansLength, varInfo); ansLength++; - UNPROTECT(5); + UNPROTECT(7); PROTECT(ans); PROTECT(ansNames); } + setAttrib(ans, R_NamesSymbol, ansNames); UNPROTECT(5); fclose(fp); Modified: trunk/SASxport/src/SASxport.h =================================================================== --- trunk/SASxport/src/SASxport.h 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/src/SASxport.h 2013-05-11 23:41:36 UTC (rev 1658) @@ -50,6 +50,9 @@ char sas_osname[8]; char sas_create[16]; char sas_mod[16]; + char sas_dslabel[40]; + char sas_dstype[8]; + }; struct SAS_XPORT_namestr { Modified: trunk/SASxport/src/init.c =================================================================== --- trunk/SASxport/src/init.c 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/src/init.c 2013-05-11 23:41:36 UTC (rev 1658) @@ -31,7 +31,8 @@ #define ARGTYPE static R_NativePrimitiveArgType ARGTYPE fill_file_header_args[] = { STRSXP, STRSXP, STRSXP, STRSXP }; -ARGTYPE fill_member_header_args[] = { STRSXP, STRSXP, STRSXP, STRSXP, STRSXP }; +ARGTYPE fill_member_header_args[] = { STRSXP, STRSXP, STRSXP, STRSXP, STRSXP, STRSXP, + STRSXP }; ARGTYPE fill_namestr_args[] = { INTSXP, INTSXP, INTSXP, STRSXP, STRSXP, STRSXP, INTSXP, INTSXP, INTSXP, STRSXP, INTSXP, INTSXP, INTSXP }; @@ -43,7 +44,7 @@ #define CDEF(name, narg, argVec) { #name, (DL_FUNC) &name, narg, argVec } static const R_CMethodDef CEntries[] = { CDEF(fill_file_header, 4, fill_file_header_args ), - CDEF(fill_member_header, 5, fill_member_header_args ), + CDEF(fill_member_header, 7, fill_member_header_args ), CDEF(fill_namestr, 13, fill_namestr_args ), CDEF(fill_namestr_header, 1, fill_namestr_header_args ), CDEF(fill_obs_header, 0, 0 ), Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/src/writeSAS.c 2013-05-11 23:41:36 UTC (rev 1658) @@ -149,11 +149,13 @@ void fill_member_header( - char **dfName, /* Name of data set */ - char **sasVer, /* SAS version number*/ - char **osType, /* Operating System */ - char **cDate, /* Creation date */ - char **mDate /* Modification date */ + char **dfName, /* Name of data set */ + char **sasVer, /* SAS version number */ + char **osType, /* Operating System */ + char **cDate, /* Creation date */ + char **mDate, /* Modification date */ + char **dfLabel, /* Label of data set */ + char **dfType /* Type of data set */ ) { struct MEMBER_HEADER member_header; @@ -175,8 +177,11 @@ /* Line 4 */ blankCopy( member_header.sas_modified,16, mDate[0] ); - blankFill( member_header.blanks2, 64); + blankFill( member_header.padding, 16); + blankCopy( member_header.dslabel, 40, dfLabel[0] ); + blankCopy( member_header.dstype, 8, dfType[0] ); + /* Copy over for return */ memcpy( raw_buffer, &member_header, sizeof(member_header) ); Modified: trunk/SASxport/src/writeSAS.h =================================================================== --- trunk/SASxport/src/writeSAS.h 2013-05-11 23:32:35 UTC (rev 1657) +++ trunk/SASxport/src/writeSAS.h 2013-05-11 23:41:36 UTC (rev 1658) @@ -103,7 +103,10 @@ /* Line 4 */ char sas_modified[16]; - char blanks2[64]; + //char blanks2[64]; + char padding[16]; + char dslabel[40]; + char dstype[8]; }; @@ -155,7 +158,7 @@ void fill_file_header(char **cDate, char **mDate, char **sasVer, char **osType); void fill_member_header(char **dfName, char **sasVer, char **osType, char **cDate, - char **mDate); + char **mDate, char **dfLabel, char **dfType); void fill_namestr(int *isChar, int *nlng, int *nvar0, char **nname, char **nlabel, char **nform, int *nfl, int *nfd, int *nfj, char **niform, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-05-12 00:55:27
|
Revision: 1659 http://sourceforge.net/p/r-gregmisc/code/1659 Author: warnes Date: 2013-05-12 00:55:24 +0000 (Sun, 12 May 2013) Log Message: ----------- Complete work to handle dataframe label and type Modified Paths: -------------- trunk/SASxport/NAMESPACE trunk/SASxport/R/SAStype.R trunk/SASxport/R/read.xport.R trunk/SASxport/src/SASxport.c trunk/SASxport/tests/dfAttributes.R Modified: trunk/SASxport/NAMESPACE =================================================================== --- trunk/SASxport/NAMESPACE 2013-05-11 23:41:36 UTC (rev 1658) +++ trunk/SASxport/NAMESPACE 2013-05-12 00:55:24 UTC (rev 1659) @@ -35,12 +35,12 @@ S3method(label, default) S3method(SASformat, default) S3method(SASiformat, default) -S3method(SAStype, data.frame) +S3method(SAStype, default) S3method("label<-", default) S3method("SASformat<-", default) S3method("SASiformat<-", default) -S3method("SAStype<-", data.frame) +S3method("SAStype<-", default) S3method(print, lookup.xport) S3method(summary, lookup.xport) Modified: trunk/SASxport/R/SAStype.R =================================================================== --- trunk/SASxport/R/SAStype.R 2013-05-11 23:41:36 UTC (rev 1658) +++ trunk/SASxport/R/SAStype.R 2013-05-12 00:55:24 UTC (rev 1659) @@ -1,7 +1,7 @@ SAStype <- function(x, default) UseMethod("SAStype") -SAStype.data.frame <- function(x, default=NULL) +SAStype.default <- function(x, default=NULL) { lab <- attr(x,"SAStype") if(is.null(lab)) @@ -13,7 +13,7 @@ "SAStype<-" <- function(x, value) UseMethod("SAStype<-") -"SAStype<-.data.frame" <- function(x, value) +"SAStype<-.default" <- function(x, value) { attr(x,'SAStype') <- value x Modified: trunk/SASxport/R/read.xport.R =================================================================== --- trunk/SASxport/R/read.xport.R 2013-05-11 23:41:36 UTC (rev 1658) +++ trunk/SASxport/R/read.xport.R 2013-05-12 00:55:24 UTC (rev 1659) @@ -48,6 +48,9 @@ scat("Extracting data file information...") dsinfo <- lookup.xport.inner(file) + dsLabels <- sapply(dsinfo, label) + dsTypes <- sapply(dsinfo, SAStype) + if(length(keep)) whichds <- toupper(keep) else @@ -123,6 +126,9 @@ next } + label(w) <- dsLabels[k] + SAStype(w) <- dsTypes[k] + nam <- names.tolower(makeNames(names(w), allow=name.chars)) names(w) <- nam dinfo <- dsinfo[[k]] Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2013-05-11 23:41:36 UTC (rev 1658) +++ trunk/SASxport/src/SASxport.c 2013-05-12 00:55:24 UTC (rev 1659) @@ -22,6 +22,7 @@ */ #include <stdio.h> +#include <ctype.h> #include <string.h> #include <R.h> #include <Rinternals.h> @@ -266,25 +267,21 @@ name[n] = '\0'; } else name[0] = '\0'; - /* Extract data set label */ - tmp = strchr(mem_head->sas_dslabel, ' '); - n = tmp - mem_head->sas_dslabel; - if(n > 0) { - if (n > 40) - n = 40; - strncpy(dslabel, mem_head->sas_dslabel, n); - dslabel[n] = '\0'; - } else dslabel[0] = '\0'; + /* Extract data set label, and trim trailing blanks */ + strncpy(dslabel, mem_head->sas_dslabel, 40); + for(int i=40-1; i>0; i--) + if( isspace(dslabel[i]) ) + dslabel[i] = '\0'; + else + break; /* Extract data set type */ - tmp = strchr(mem_head->sas_dstype, ' '); - n = tmp - mem_head->sas_dstype; - if(n > 0) { - if (n > 40) - n = 40; - strncpy(dstype, mem_head->sas_dstype, n); - dstype[n] = '\0'; - } else dstype[0] = '\0'; + strncpy(dstype, mem_head->sas_dstype, 8); + for(int i=8-1; i>0; i--) + if( isspace(dstype[i]) ) + dstype[i] = '\0'; + else + break; Free(mem_head); @@ -595,9 +592,14 @@ PROTECT(varInfo = allocVector(VECSXP, VAR_INFO_LENGTH)); setAttrib(varInfo, R_NamesSymbol, varInfoNames); - PROTECT(dfLabel = mkChar(dslabel)); - PROTECT(dfType = mkChar(dstype) ); + dslabel[40] = '\n'; + PROTECT(dfLabel = allocVector(STRSXP, 1)); + SET_STRING_ELT(dfLabel, 0, mkChar(dslabel)); setAttrib(varInfo, install("label" ), dfLabel); + + dstype[8] = '\n'; + PROTECT(dfType = allocVector(STRSXP, 1)); + SET_STRING_ELT(dfType, 0, mkChar(dstype)); setAttrib(varInfo, install("SAStype"), dfType ); SET_XPORT_VAR_TYPE(varInfo, allocVector(STRSXP, memLength)); Modified: trunk/SASxport/tests/dfAttributes.R =================================================================== --- trunk/SASxport/tests/dfAttributes.R 2013-05-11 23:41:36 UTC (rev 1658) +++ trunk/SASxport/tests/dfAttributes.R 2013-05-12 00:55:24 UTC (rev 1659) @@ -4,7 +4,7 @@ abc.out <- data.frame( x=c(1, 2, NA, NA ), y=c('a', 'B', NA, '*' ) ) ## add a data set label (not used by R) -label(abc.out) <- "data set" +label(abc.out) <- "xxxx data set xxxxx" SAStype(abc.out) <- "normal" ## add a format specifier (not used by R) @@ -15,7 +15,7 @@ # create a SAS XPORT file from our local data frame write.xport(abc.out, - file="xxx2.xpt", + file="dfAttributes.xpt", cDate=strptime("28JUL07:21:08:06 ", format="%d%b%y:%H:%M:%S"), osType="SunOS", sasVer="9.1", @@ -23,16 +23,16 @@ ) # read the SAS data back in -abc.in <- read.xport("xxx2.xpt", names.tolower=FALSE) +abc.in <- read.xport("dfAttributes.xpt", names.tolower=FALSE) ## Test that the files are otherwise identical -label(abc.out, "missing!") -label(abc.in , "missing!") +label(abc.out, "MISSING!") +label(abc.in , "MISSING!") -SAStype(abc.out, "missing!") -SAStype(abc.in , "missing!") +SAStype(abc.out, "MISSING!") +SAStype(abc.in , "MISSING!") -stopifnot( label(abc.out)==label(abc.in, "missing!") ) -stopifnot( SAStype(abc.out)==SAStype(abc.in, "missing!") ) +stopifnot( label (abc.out, "MISSING!")==label (abc.in, "MISSING!") ) +stopifnot( SAStype(abc.out, "MISSING!")==SAStype(abc.in, "MISSING!") ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-05-12 01:48:53
|
Revision: 1660 http://sourceforge.net/p/r-gregmisc/code/1660 Author: warnes Date: 2013-05-12 01:48:49 +0000 (Sun, 12 May 2013) Log Message: ----------- Update NEWS for release Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/R/SAStype.R trunk/SASxport/R/read.xport.R trunk/SASxport/inst/NEWS trunk/SASxport/man/SASxport-package.Rd trunk/SASxport/man/label.Rd trunk/SASxport/man/read.xport.Rd trunk/SASxport/man/write.xport.Rd trunk/SASxport/tests/Alfalfa_Test.Rout.save trunk/SASxport/tests/Theoph.Rout.save trunk/SASxport/tests/cars.Rout.save trunk/SASxport/tests/testDates.Rout.save trunk/SASxport/tests/testDuplicateNames.Rout.save trunk/SASxport/tests/testManyNames.Rout.save trunk/SASxport/tests/testNegative.Rout.save trunk/SASxport/tests/testNumeric.Rout.save trunk/SASxport/tests/testUnnamedComponents.Rout.save trunk/SASxport/tests/test_as_is.Rout.save trunk/SASxport/tests/test_fields.Rout.save trunk/SASxport/tests/xport.Rout.save trunk/SASxport/tests/xxx.Rout.save Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/DESCRIPTION 2013-05-12 01:48:49 UTC (rev 1660) @@ -14,19 +14,26 @@ Gregory R. Warnes <gr...@wa...> and are provided under the terms of the GNU General Public License, version 2.0 or later. -- - The files 'ieee2ibm.c' and '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 '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 'AFirst.lib.s', 'all.is.numeric.R', - 'importConvertDateTime.R', 'in.opererator.R', 'makeNames.R', - 'read.xport.R', and 'testDateTime.R' are copied or adapted from the + 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.h...@va...>, 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 <ba...@st...> and Saikat DebRoy + <sa...@st...>, 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 <gr...@wa...> Modified: trunk/SASxport/R/SAStype.R =================================================================== --- trunk/SASxport/R/SAStype.R 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/R/SAStype.R 2013-05-12 01:48:49 UTC (rev 1660) @@ -15,6 +15,6 @@ "SAStype<-.default" <- function(x, value) { - attr(x,'SAStype') <- value + attr(x,'SAStype') <- makeSASNames(value) x } Modified: trunk/SASxport/R/read.xport.R =================================================================== --- trunk/SASxport/R/read.xport.R 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/R/read.xport.R 2013-05-12 01:48:49 UTC (rev 1660) @@ -127,7 +127,9 @@ } label(w) <- dsLabels[k] + names(label(w)) <- NULL SAStype(w) <- dsTypes[k] + names(SAStype(w)) <- NULL nam <- names.tolower(makeNames(names(w), allow=name.chars)) names(w) <- nam Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/inst/NEWS 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,6 +1,11 @@ Version 1.3.2 2013-05-11 ------------------------ +New features: + +- dataset label and type are now supported. See write.xport() and + read.xport() for examples. + Bug fixes: - Integrate patch from foreign package to properly handle xport files Modified: trunk/SASxport/man/SASxport-package.Rd =================================================================== --- trunk/SASxport/man/SASxport-package.Rd 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/man/SASxport-package.Rd 2013-05-12 01:48:49 UTC (rev 1660) @@ -12,7 +12,7 @@ \details{ The \code{read.xport} function reads SAS xport formatted files, augmenting the functionality of the \code{\link[foreign]{read.xport}} - function provided in the 'foreign' package with additional features + function provided in the 'foreign' package with additional features, borrowed from \code{\link[Hmisc]{sasxport.get}} in Frank Harrell's 'Hmisc' package. Namely, variables are properly coerced into the types specified by the format field. All standard numeric and string @@ -21,7 +21,10 @@ in the xport file via: \preformatted{ PROC FORMAT CNTLOUT=format; -} + } + In addition, labels are supported for variable and data frames, as + are dataset 'types'. + The \code{write.xport} function writes one or more data sets into a SAS xport formatted file. Standard R data types, including date and time objects (e.g. \code{Date}, and \code{POSIX.t}) are stored with @@ -57,19 +60,25 @@ are provided under the terms of the GNU General Public License, version 2.0 or later. - The file 'htond.c' is extracted from BRL-CAD - \url{http://www.brlcad.org/}, written by Michael John Muuss, and is - 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 '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 'AFirst.lib.s', 'all.is.numeric.R', - 'importConvertDateTime.R', 'in.opererator.R', 'makeNames.R', - 'read.xport.R', and 'testDateTime.R' are copied or adapted from the - 'Hmisc' package created by Frank E. Harrell, Jr. - \email{f.h...@va...}, and are utilized and redistributed under + 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.h...@va...>, 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 <ba...@st...> and Saikat DebRoy + <sa...@st...>, and are utilized and redistributed under the + terms of the GNU General Public License, version 2.0 or later. +} \section{Funding}{ This creation of this package was partially funded by Metrum Institute \url{http://metruminstitute.org}. Modified: trunk/SASxport/man/label.Rd =================================================================== --- trunk/SASxport/man/label.Rd 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/man/label.Rd 2013-05-12 01:48:49 UTC (rev 1660) @@ -30,6 +30,8 @@ More comprehensive support for object labels, and SASformat, are available in Frank Harrell's \code{Hmisc} package. + + Note that \code{SAStype} enforces the SAS 8-character naming convention. } \usage{ label(x, default) Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/man/read.xport.Rd 2013-05-12 01:48:49 UTC (rev 1660) @@ -82,10 +82,15 @@ \item SAS date, time, and date/time variables are converted respectively to \code{Date}, POSIX, or \code{chron} objects - \item SAS labels are stored in "label" attributes on each variable + \item SAS labels are stored in "label" attributes on each variable, + and are accessible using the \code{\link{label}} function. - \item SAS formats are stored in "format" attributes on each variable + \item SAS formats are stored in "SASformat" attributes on each + variable, and are accessable using \code{\link{SASformat}} + \item SAS iformats are stored in "SASiformat" attributes on each + variable, and are accessable using \code{\link{SASiformat}} + \item SAS integer variables are stored as integers unless \code{force.integer} is \code{FALSE} } @@ -93,6 +98,11 @@ If the file includes the output of \code{PROC FORMAT CNTLOUT=}, variables having customized label formats will be converted to \code{factor} objects with appropriate labels. + + If a datasets in the original file has a label or type, these will be + stored in the corresponding 'lable' and 'SAStype' attributes, which + can be accessed by the \code{\link{label}} and \code{\link{SAStype}} + functions. } \author{ Gregory R. Warnes \email{gr...@wa...} based on \code{Hmisc:::sasxport.get} by Frank E. Harrell, Jr.} @@ -110,7 +120,11 @@ \code{\link[chron]{chron}}, \code{\link[foreign]{lookup.xport}}, \code{\link[Hmisc]{contents}}, - \code{\link[Hmisc]{describe}} + \code{\link[Hmisc]{describe}}, + \code{\link{label}}, + \code{\link{SASformat}}, + \code{\link{SASiformat}}, and + \code{\link{SAStype}} } \examples{ Modified: trunk/SASxport/man/write.xport.Rd =================================================================== --- trunk/SASxport/man/write.xport.Rd 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/man/write.xport.Rd 2013-05-12 01:48:49 UTC (rev 1660) @@ -39,9 +39,10 @@ converted to upper case. All characters outside of the set A-Z, 0-9, and '\_' are converted to '\_'. \item Character variables are stored as characters. - \item If \code{autogen.formats=TRUE} (the default), factor variables are stored as numeric with an appropriate SAS - format specification. If \code{autogen.formats=FALSE}, factor - variables are stored as characters. + \item If \code{autogen.formats=TRUE} (the default), factor variables + are stored as numeric with an appropriate SAS format + specification. If \code{autogen.formats=FALSE}, factor variables + are stored as characters. \item All numeric variables are stored as double-precision floating point values utilizing the IBM mainframe double precision floating point format (see the reference). @@ -52,13 +53,18 @@ '.' } - In addition, the SAS XPORT format allows each variable to have a - corresponding label, display format, and input format. To set these - values, add the attribute 'label', 'SASformat', or 'SASiformat' to - individual data frame variables. (See the example section.) + The SAS XPORT format allows each dataset to have a label and a type + (set via the \code{\link{label}} and \code{\link{SAStype}} functions). + In addition, each variable may have a corresponding label, display + format, and input format. To set these values, add the attribute + 'label', 'SASformat', or 'SASiformat' to individual data frame. These + attributes may be set using the \code{\link{label}}, + \code{\link{SASformat}}, and \code{\link{SASiformat}} functions. (See + examples provided below.) The actual translation of R objects to objects appropriate for SAS is - handled by the \code{\link{toSAS}} generic and associated methods. + handled by the \code{\link{toSAS}} generic and associated methods, + which can be (re)defined by the user to provide fine-grained control. } \value{ No return value @@ -76,7 +82,11 @@ \seealso{ \code{\link{toSAS}}, \code{\link{lookup.xport}}, - \code{\link{read.xport}} + \code{\link{read.xport}}, + \code{\link{label}}, + \code{\link{SAStype}}, + \code{\link{SASformat}}, + and \code{\link{SASiformat}} } \examples{ @@ -85,23 +95,24 @@ ##### ## manually create a data set -temp <- data.frame( x=c(1, 2, NA, NA ), y=c('a', 'B', NA, '*' ) ) +abc <- data.frame( x=c(1, 2, NA, NA ), y=c('a', 'B', NA, '*' ) ) ## look at it -temp +abc ## add a format specifier (not used by R) -attr(temp$x, 'SASformat') <- 'date7.' +SASformat(abc$x) <- 'date7.' ## add a variable label (not used by R) -attr(temp$y, 'label') <- 'character variable' +label(abc$y) <- 'character variable' +## add a dataset label and type +label(abc) <- 'Simple example' +SAStype(abc) <- 'MYTYPE' + ## verify the additions -str(temp) +str(abc) -## rename the data set -abc <- temp - # create a SAS XPORT file write.xport( abc, file="xxx.dat" ) @@ -114,7 +125,12 @@ ## and look at it xxx.abc -## Note that the variable names have been converted to uppercase +## Check the label and type +label(xxx.abc) +SAStype(xxx.abc) +## Note that the variable names and SAS dataset type have been converted +## to uppercase + } \keyword{file} Modified: trunk/SASxport/tests/Alfalfa_Test.Rout.save =================================================================== --- trunk/SASxport/tests/Alfalfa_Test.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/Alfalfa_Test.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -21,7 +20,7 @@ > > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -47,4 +46,4 @@ > > proc.time() user system elapsed - 0.303 0.025 0.316 + 0.940 0.052 0.985 Modified: trunk/SASxport/tests/Theoph.Rout.save =================================================================== --- trunk/SASxport/tests/Theoph.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/Theoph.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -23,7 +22,7 @@ > > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -43,4 +42,4 @@ > > proc.time() user system elapsed - 0.539 0.026 0.555 + 1.632 0.084 1.705 Modified: trunk/SASxport/tests/cars.Rout.save =================================================================== --- trunk/SASxport/tests/cars.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/cars.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -64,4 +63,4 @@ > > proc.time() user system elapsed - 0.296 0.025 0.310 + 0.904 0.096 0.998 Modified: trunk/SASxport/tests/testDates.Rout.save =================================================================== --- trunk/SASxport/tests/testDates.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/testDates.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -62,4 +61,4 @@ > > proc.time() user system elapsed - 0.364 0.025 0.378 + 1.112 0.084 1.183 Modified: trunk/SASxport/tests/testDuplicateNames.Rout.save =================================================================== --- trunk/SASxport/tests/testDuplicateNames.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/testDuplicateNames.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -156,4 +155,4 @@ > > proc.time() user system elapsed - 0.430 0.031 2.232 + 1.292 0.124 2.566 Modified: trunk/SASxport/tests/testManyNames.Rout.save =================================================================== --- trunk/SASxport/tests/testManyNames.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/testManyNames.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -95,4 +94,4 @@ > > proc.time() user system elapsed - 6.985 0.068 7.099 + 19.392 0.172 19.717 Modified: trunk/SASxport/tests/testNegative.Rout.save =================================================================== --- trunk/SASxport/tests/testNegative.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/testNegative.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -48,4 +47,4 @@ > > proc.time() user system elapsed - 0.423 0.027 0.439 + 1.260 0.072 1.321 Modified: trunk/SASxport/tests/testNumeric.Rout.save =================================================================== --- trunk/SASxport/tests/testNumeric.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/testNumeric.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -87,4 +86,4 @@ > > proc.time() user system elapsed - 0.494 0.025 0.507 + 1.584 0.096 1.673 Modified: trunk/SASxport/tests/testUnnamedComponents.Rout.save =================================================================== --- trunk/SASxport/tests/testUnnamedComponents.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/testUnnamedComponents.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -2164,4 +2163,4 @@ > > proc.time() user system elapsed - 2.092 0.073 8.083 + 6.024 1.684 14.087 Modified: trunk/SASxport/tests/test_as_is.Rout.save =================================================================== --- trunk/SASxport/tests/test_as_is.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/test_as_is.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -48,6 +47,8 @@ $ CONC : num 0.02 0.02 0.06 0.06 0.11 0.11 0.22 0.22 0.56 0.56 ... $ RATE : int 76 47 97 107 123 139 159 152 191 201 ... $ STATE: Factor w/ 2 levels "treated","untreated": 1 1 1 1 1 1 1 1 1 1 ... + - attr(*, "label")= chr " " + - attr(*, "SAStype")= chr " " > > SASxport:::assert( class(x$STATE)=="factor" ) > @@ -60,6 +61,8 @@ $ CONC : num 0.02 0.02 0.06 0.06 0.11 0.11 0.22 0.22 0.56 0.56 ... $ RATE : int 76 47 97 107 123 139 159 152 191 201 ... $ STATE: chr "treated" "treated" "treated" "treated" ... + - attr(*, "label")= chr " " + - attr(*, "SAStype")= chr " " > > SASxport:::assert( class(x$STATE)=="character" ) > @@ -67,4 +70,4 @@ > > proc.time() user system elapsed - 0.269 0.024 0.282 + 0.860 0.112 0.996 Modified: trunk/SASxport/tests/test_fields.Rout.save =================================================================== --- trunk/SASxport/tests/test_fields.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/test_fields.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -32,4 +31,4 @@ > > proc.time() user system elapsed - 0.240 0.023 0.252 + 0.756 0.056 0.820 Modified: trunk/SASxport/tests/xport.Rout.save =================================================================== --- trunk/SASxport/tests/xport.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/xport.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -106,4 +105,4 @@ > q() > proc.time() user system elapsed - 0.286 0.025 0.300 + 0.908 0.108 1.018 Modified: trunk/SASxport/tests/xxx.Rout.save =================================================================== --- trunk/SASxport/tests/xxx.Rout.save 2013-05-12 00:55:24 UTC (rev 1659) +++ trunk/SASxport/tests/xxx.Rout.save 2013-05-12 01:48:49 UTC (rev 1660) @@ -1,8 +1,7 @@ -R version 2.15.0 (2012-03-30) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) +R version 3.0.0 (2013-04-03) -- "Masked Marvel" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -18,7 +17,7 @@ > library(SASxport) -Loaded SASxport version 1.3.0 (2012-06-29). +Loaded SASxport version 1.3.2 (2013-05-11). Type `?SASxport' for usage information. @@ -67,7 +66,7 @@ > ## R doesn't have multiple NA types, while SAS does. The original > ## file contains a SAS '.A' missing value, while what we've created > ## contains an ordinary '.' missing value, so mash this one byte to -> ## avoid a comparison error for this know limitation. +> ## avoid a comparison error for this known limitation. > > a.1[1089] <- as.raw("0x2e") > @@ -79,4 +78,4 @@ > > proc.time() user system elapsed - 0.287 0.027 0.303 + 0.908 0.092 0.991 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-05-31 03:02:46
|
Revision: 1661 http://sourceforge.net/p/r-gregmisc/code/1661 Author: warnes Date: 2013-05-31 03:02:44 +0000 (Fri, 31 May 2013) Log Message: ----------- Correct error in write.xport when a factor contains only NA entries. Modified Paths: -------------- trunk/SASxport/R/make.formats.R Added Paths: ----------- trunk/SASxport/tests/testFactorAllNA.R Modified: trunk/SASxport/R/make.formats.R =================================================================== --- trunk/SASxport/R/make.formats.R 2013-05-12 01:48:49 UTC (rev 1660) +++ trunk/SASxport/R/make.formats.R 2013-05-31 03:02:44 UTC (rev 1661) @@ -76,14 +76,16 @@ else formatName <- fname varLevels <- levels(var) - formats <- empty.format.table() - for( j in 1:nlevels(var) ) - formats <- add.format.entry(formats, - formatName, - j, - j, - varLevels[j] - ) + formats <- empty.format.table() + + if(nlevels(var)>0) + for( j in 1:nlevels(var) ) + formats <- add.format.entry(formats, + formatName, + j, + j, + varLevels[j] + ) formats } Added: trunk/SASxport/tests/testFactorAllNA.R =================================================================== --- trunk/SASxport/tests/testFactorAllNA.R (rev 0) +++ trunk/SASxport/tests/testFactorAllNA.R 2013-05-31 03:02:44 UTC (rev 1661) @@ -0,0 +1,16 @@ +library(SASxport) + +x <- data.frame(A=1:10, + B=letters[1:10], + C=factor(rep(NA,10)), + D=factor(rep(NA,10), levels=c("A","B","C")), + E=as.numeric(rep(NA,10)), + stringsAsFactors=FALSE + ) +write.xport(x,file='testFactorAllNA.out.xpt') + +y <- read.xport(file='testFactorAllNA.out.xpt') + +stopifnot( all.equal(x,y, check.attributes = FALSE) ) +stopifnot( all.equal(levels(x$C), levels(y$C) ) ) +stopifnot( all.equal(levels(x$D), levels(y$D) ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-05-31 03:04:32
|
Revision: 1662 http://sourceforge.net/p/r-gregmisc/code/1662 Author: warnes Date: 2013-05-31 03:04:30 +0000 (Fri, 31 May 2013) Log Message: ----------- Update for SASxport 1.3.3 Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2013-05-31 03:02:44 UTC (rev 1661) +++ trunk/SASxport/DESCRIPTION 2013-05-31 03:04:30 UTC (rev 1662) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.3.2 -Date: 2013-05-11 +Version: 1.3.3 +Date: 2013-05-30 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2013-05-31 03:02:44 UTC (rev 1661) +++ trunk/SASxport/inst/NEWS 2013-05-31 03:04:30 UTC (rev 1662) @@ -1,3 +1,10 @@ +Version 1.3.3 2013-05-30 +------------------------ + +Bug fixes: + +- Correct error in write.xport when a factor contains only NA entries. + Version 1.3.2 2013-05-11 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-05-31 17:26:14
|
Revision: 1666 http://sourceforge.net/p/r-gregmisc/code/1666 Author: warnes Date: 2013-05-31 17:26:09 +0000 (Fri, 31 May 2013) Log Message: ----------- Update for SASxport 1.3.4 Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2013-05-31 03:53:49 UTC (rev 1665) +++ trunk/SASxport/DESCRIPTION 2013-05-31 17:26:09 UTC (rev 1666) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.3.3 -Date: 2013-05-30 +Version: 1.3.4 +Date: 2013-05-31 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2013-05-31 03:53:49 UTC (rev 1665) +++ trunk/SASxport/inst/NEWS 2013-05-31 17:26:09 UTC (rev 1666) @@ -1,10 +1,14 @@ -Version 1.3.3 2013-05-30 +Version 1.3.4 2013-05-31 ------------------------ Bug fixes: - Correct error in write.xport when a factor contains only NA entries. +Other Changes: + +- Package test scripts now use a fixed timezone to prevent unhelpful warnings. + Version 1.3.2 2013-05-11 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-06-14 03:10:12
|
Revision: 1668 http://sourceforge.net/p/r-gregmisc/code/1668 Author: warnes Date: 2013-06-14 03:10:06 +0000 (Fri, 14 Jun 2013) Log Message: ----------- Fix bug when xpt file contains an empty data set Modified Paths: -------------- trunk/SASxport/R/lookup.xport.R trunk/SASxport/src/SASxport.c Modified: trunk/SASxport/R/lookup.xport.R =================================================================== --- trunk/SASxport/R/lookup.xport.R 2013-05-31 23:18:03 UTC (rev 1667) +++ trunk/SASxport/R/lookup.xport.R 2013-06-14 03:10:06 UTC (rev 1668) @@ -37,6 +37,7 @@ "label" ) ]) + if(nrow(ret)==0) ret[1,] <- NA # ensure at least one row cbind(dataset=XX, ret, nobs=df$length) } Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2013-05-31 23:18:03 UTC (rev 1667) +++ trunk/SASxport/src/SASxport.c 2013-06-14 03:10:06 UTC (rev 1668) @@ -587,7 +587,9 @@ PROTECT(ans = allocVector(VECSXP, 0)); PROTECT(ansNames = allocVector(STRSXP, 0)); - while(namestrLength > 0 && (memLength = init_mem_info(fp, dsname, dslabel, dstype)) > 0) { + while(!feof(fp)) + { + memLength = init_mem_info(fp, dsname, dslabel, dstype); PROTECT(varInfo = allocVector(VECSXP, VAR_INFO_LENGTH)); setAttrib(varInfo, R_NamesSymbol, varInfoNames); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-06-14 16:22:42
|
Revision: 1670 http://sourceforge.net/p/r-gregmisc/code/1670 Author: warnes Date: 2013-06-14 16:22:39 +0000 (Fri, 14 Jun 2013) Log Message: ----------- Complete changes to handle empty datasets in xport files. Modified Paths: -------------- trunk/SASxport/R/fstr.R trunk/SASxport/R/read.xport.R trunk/SASxport/src/SASxport.c trunk/SASxport/src/writeSAS.c trunk/SASxport/tests/Alfalfa_Test.Rout.save trunk/SASxport/tests/Theoph.Rout.save trunk/SASxport/tests/cars.Rout.save trunk/SASxport/tests/testDates.Rout.save trunk/SASxport/tests/testDuplicateNames.Rout.save trunk/SASxport/tests/testManyNames.Rout.save trunk/SASxport/tests/testNegative.Rout.save trunk/SASxport/tests/testNumeric.Rout.save trunk/SASxport/tests/testUnnamedComponents.Rout.save trunk/SASxport/tests/test_as_is.Rout.save trunk/SASxport/tests/test_fields.Rout.save trunk/SASxport/tests/xport.Rout.save trunk/SASxport/tests/xxx.Rout.save Added Paths: ----------- trunk/SASxport/tests/testEmpty.R trunk/SASxport/tests/testEmpty.Rout.save Modified: trunk/SASxport/R/fstr.R =================================================================== --- trunk/SASxport/R/fstr.R 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/R/fstr.R 2013-06-14 16:22:39 UTC (rev 1670) @@ -12,6 +12,8 @@ else return( paste(name[i], length[i], '.', digits[i], sep='' ) ) } - sapply( 1:length(name), inner) - + if(length(name)>0) + sapply( 1:length(name), inner) + else + character(0) } Modified: trunk/SASxport/R/read.xport.R =================================================================== --- trunk/SASxport/R/read.xport.R 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/R/read.xport.R 2013-06-14 16:22:39 UTC (rev 1670) @@ -121,11 +121,6 @@ scat('.') - if(!length(w)) { - scat('Empty dataset', k, 'ignored\n') - next - } - label(w) <- dsLabels[k] names(label(w)) <- NULL SAStype(w) <- dsTypes[k] @@ -145,71 +140,72 @@ ndinfo <- names.tolower(makeNames(dinfo$name, allow=name.chars)) names(lab) <- names(fmt) <- names(formats) <- names(iformats) <- ndinfo - for(i in 1:length(w)) { - changed <- FALSE - x <- w[[i]] - fi <- fmt[nam[i]]; - names(fi) <- NULL - if(fi != '' && length(finfo) && (fi %in% names(finfo))) { - f <- finfo[[fi]] - if(length(f)) { ## may be NULL because had a range in format - x <- factor(x, f$value, f$label) - attr(x, 'SASformat') <- fi - changed <- TRUE + if(length(w)>0) + for(i in 1:length(w)) { + changed <- FALSE + x <- w[[i]] + fi <- fmt[nam[i]]; + names(fi) <- NULL + if(fi != '' && length(finfo) && (fi %in% names(finfo))) { + f <- finfo[[fi]] + if(length(f)) { ## may be NULL because had a range in format + x <- factor(x, f$value, f$label) + attr(x, 'SASformat') <- fi + changed <- TRUE + } } - } - if(is.numeric(x)) { - if(fi %in% sasdateform) { - x <- importConvertDateTime(x, 'date', 'sas') - changed <- TRUE - } else if(fi %in% sastimeform) { - x <- importConvertDateTime(x, 'time', 'sas') - changed <- TRUE - } else if(fi %in% sasdatetimeform) { - x <- importConvertDateTime(x, 'datetime', 'sas') - changed <- TRUE - } else if(force.integer) { - if(all(is.na(x))) { - storage.mode(x) <- 'integer' + if(is.numeric(x)) { + if(fi %in% sasdateform) { + x <- importConvertDateTime(x, 'date', 'sas') changed <- TRUE - } else if(max(abs(x),na.rm=TRUE) <= (2^31-1) && - all(floor(x) == x, na.rm=TRUE)) { - storage.mode(x) <- 'integer' + } else if(fi %in% sastimeform) { + x <- importConvertDateTime(x, 'time', 'sas') changed <- TRUE + } else if(fi %in% sasdatetimeform) { + x <- importConvertDateTime(x, 'datetime', 'sas') + changed <- TRUE + } else if(force.integer) { + if(all(is.na(x))) { + storage.mode(x) <- 'integer' + changed <- TRUE + } else if(max(abs(x),na.rm=TRUE) <= (2^31-1) && + all(floor(x) == x, na.rm=TRUE)) { + storage.mode(x) <- 'integer' + changed <- TRUE } + } + } else if(possiblyConvertChar && is.character(x)) { + if((is.logical(as.is) && !as.is) || + (is.numeric(as.is) && length(unique(x)) < as.is*length(x))) { + x <- factor(x, exclude='') + changed <- TRUE + } } - } else if(possiblyConvertChar && is.character(x)) { - if((is.logical(as.is) && !as.is) || - (is.numeric(as.is) && length(unique(x)) < as.is*length(x))) { - x <- factor(x, exclude='') - changed <- TRUE + + lz <- lab[nam[i]] + if(!is.null(lz) && length(lz)>0 && !is.na(lz) && lz != '') { + names(lz) <- NULL + label(x) <- lz + changed <- TRUE } - } - lz <- lab[nam[i]] - if(!is.null(lz) && length(lz)>0 && !is.na(lz) && lz != '') { - names(lz) <- NULL - label(x) <- lz - changed <- TRUE + if(nam[i] %in% names(formats) && formats[nam[i]] > "" ) + { + SASformat(x) <- formats[[nam[i]]] + changed <- TRUE + } + + if(nam[i] %in% names(iformats) && iformats[nam[i]] > "" ) + { + SASformat(x) <- formats[[nam[i]]] + changed <- TRUE + } + + if(changed) + w[[i]] <- x } - if( formats[nam[i]] > "" ) - { - SASformat(x) <- formats[[nam[i]]] - changed <- TRUE - } - - if( iformats[nam[i]] > "" ) - { - SASformat(x) <- formats[[nam[i]]] - changed <- TRUE - } - - if(changed) - w[[i]] <- x - } - scat('.') res[[j]] <- w @@ -226,9 +222,11 @@ res$FORMATS <- empty.format.table() } - if(nds > 1 || as.list) res else + if(class(w)=="list") + w[[1]] + else w } Modified: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/src/SASxport.c 2013-06-14 16:22:39 UTC (rev 1670) @@ -4,6 +4,7 @@ * * Copyright 1999-1999 Douglas M. Bates <ba...@st...>, * Saikat DebRoy <sa...@st...> + * Additions copyright 2007-2013 Gregory R. Warnes <gr...@wa...> * * * This program is free software; you can redistribute it and/or modify Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/src/writeSAS.c 2013-06-14 16:22:39 UTC (rev 1670) @@ -4,7 +4,7 @@ * * Author: Gregory R. Warnes <gr...@wa...> * - * Copyright (C) 2007 Gregory R. Warnes <gr...@wa...> + * Copyright (C) 2007-2013 Gregory R. Warnes <gr...@wa...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by Modified: trunk/SASxport/tests/Alfalfa_Test.Rout.save =================================================================== --- trunk/SASxport/tests/Alfalfa_Test.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/Alfalfa_Test.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -47,4 +47,4 @@ > > proc.time() user system elapsed - 0.908 0.084 0.981 + 0.952 0.076 1.020 Modified: trunk/SASxport/tests/Theoph.Rout.save =================================================================== --- trunk/SASxport/tests/Theoph.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/Theoph.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -43,4 +43,4 @@ > > proc.time() user system elapsed - 1.632 0.092 1.811 + 1.660 0.088 1.787 Modified: trunk/SASxport/tests/cars.Rout.save =================================================================== --- trunk/SASxport/tests/cars.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/cars.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -64,4 +64,4 @@ > > proc.time() user system elapsed - 0.920 0.128 1.036 + 0.972 0.084 1.061 Modified: trunk/SASxport/tests/testDates.Rout.save =================================================================== --- trunk/SASxport/tests/testDates.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/testDates.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -62,4 +62,4 @@ > > proc.time() user system elapsed - 1.092 0.108 1.187 + 1.132 0.096 1.244 Modified: trunk/SASxport/tests/testDuplicateNames.Rout.save =================================================================== --- trunk/SASxport/tests/testDuplicateNames.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/testDuplicateNames.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -155,4 +155,4 @@ > > proc.time() user system elapsed - 1.348 0.104 2.636 + 1.300 0.144 2.626 Added: trunk/SASxport/tests/testEmpty.R =================================================================== --- trunk/SASxport/tests/testEmpty.R (rev 0) +++ trunk/SASxport/tests/testEmpty.R 2013-06-14 16:22:39 UTC (rev 1670) @@ -0,0 +1,16 @@ +library(SASxport) + +data(iris) +write.xport(Iris1=iris[1:2,], + empty=data.frame(), + Iris2=iris[3:4,], + file="testEmpty.xpt") + +empty.s <- lookup.xport(file="testEmpty.xpt") +names(empty.s) +stopifnot( length(names(empty.s)) == 4 ) + +dat <- read.xport(file="testEmpty.xpt", verbose=TRUE) +stopifnot( length(names(dat)) == 3 ) +stopifnot( nrow(dat)!=0 ) +dat Added: trunk/SASxport/tests/testEmpty.Rout.save =================================================================== --- trunk/SASxport/tests/testEmpty.Rout.save (rev 0) +++ trunk/SASxport/tests/testEmpty.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -0,0 +1,73 @@ + +R version 3.0.1 (2013-05-16) -- "Good Sport" +Copyright (C) 2013 The R Foundation for Statistical Computing +Platform: i686-pc-linux-gnu (32-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(SASxport) + +Loaded SASxport version 1.3.4 (2013-05-31). + + Type `?SASxport' for usage information. + +> +> data(iris) +> write.xport(Iris1=iris[1:2,], ++ empty=data.frame(), ++ Iris2=iris[3:4,], ++ file="testEmpty.xpt") +Warning messages: +1: In makeSASNames(colnames(df)) : Truncated 4 long names to 8 characters. +2: In makeSASNames(colnames(df)) : Truncated 4 long names to 8 characters. +> +> empty.s <- lookup.xport(file="testEmpty.xpt") +> names(empty.s) +[1] "IRIS1" "EMPTY" "IRIS2" "FORMATS" +> stopifnot( length(names(empty.s)) == 4 ) +> +> dat <- read.xport(file="testEmpty.xpt", verbose=TRUE) +### Checking if the specified file has the appropriate header ### +### Extracting data file information... ### +### Reading the data file... ### +### Processing contents... ### +### Processing SAS dataset IRIS1 ### +### . ### +### . ### +### Processing SAS dataset EMPTY ### +### . ### +### . ### +### Processing SAS dataset IRIS2 ### +### . ### +### . ### +### Done ### +> stopifnot( length(names(dat)) == 3 ) +> stopifnot( nrow(dat)!=0 ) +> dat +$iris1 + SEPAL.LE SEPAL.WI PETAL.LE PETAL.WI SPECIES +1 5.1 3.5 1.4 0.2 setosa +2 4.9 3.0 1.4 0.2 setosa + +$empty +data frame with 0 columns and 0 rows + +$iris2 + SEPAL.LE SEPAL.WI PETAL.LE PETAL.WI SPECIES +1 4.7 3.2 1.3 0.2 setosa +2 4.6 3.1 1.5 0.2 setosa + +> +> proc.time() + user system elapsed + 1.296 0.088 1.466 Modified: trunk/SASxport/tests/testManyNames.Rout.save =================================================================== --- trunk/SASxport/tests/testManyNames.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/testManyNames.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -95,4 +95,4 @@ > > proc.time() user system elapsed - 19.180 0.228 20.097 + 19.108 0.212 19.530 Modified: trunk/SASxport/tests/testNegative.Rout.save =================================================================== --- trunk/SASxport/tests/testNegative.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/testNegative.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -48,4 +48,4 @@ > > proc.time() user system elapsed - 1.292 0.116 1.475 + 1.224 0.112 1.334 Modified: trunk/SASxport/tests/testNumeric.Rout.save =================================================================== --- trunk/SASxport/tests/testNumeric.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/testNumeric.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -87,4 +87,4 @@ > > proc.time() user system elapsed - 1.604 0.180 1.846 + 1.548 0.080 1.621 Modified: trunk/SASxport/tests/testUnnamedComponents.Rout.save =================================================================== --- trunk/SASxport/tests/testUnnamedComponents.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/testUnnamedComponents.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -2163,4 +2163,4 @@ > > proc.time() user system elapsed - 5.872 1.744 12.296 + 5.896 1.676 12.756 Modified: trunk/SASxport/tests/test_as_is.Rout.save =================================================================== --- trunk/SASxport/tests/test_as_is.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/test_as_is.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -71,4 +71,4 @@ > > proc.time() user system elapsed - 0.828 0.124 0.942 + 0.868 0.092 0.946 Modified: trunk/SASxport/tests/test_fields.Rout.save =================================================================== --- trunk/SASxport/tests/test_fields.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/test_fields.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -32,4 +32,4 @@ > > proc.time() user system elapsed - 0.724 0.092 0.808 + 0.716 0.092 0.833 Modified: trunk/SASxport/tests/xport.Rout.save =================================================================== --- trunk/SASxport/tests/xport.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/xport.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -106,4 +106,4 @@ > q() > proc.time() user system elapsed - 0.892 0.128 1.026 + 0.888 0.132 1.031 Modified: trunk/SASxport/tests/xxx.Rout.save =================================================================== --- trunk/SASxport/tests/xxx.Rout.save 2013-06-14 15:13:47 UTC (rev 1669) +++ trunk/SASxport/tests/xxx.Rout.save 2013-06-14 16:22:39 UTC (rev 1670) @@ -79,4 +79,4 @@ > > proc.time() user system elapsed - 0.872 0.124 0.982 + 0.896 0.096 0.983 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-06-14 16:26:06
|
Revision: 1671 http://sourceforge.net/p/r-gregmisc/code/1671 Author: warnes Date: 2013-06-14 16:26:02 +0000 (Fri, 14 Jun 2013) Log Message: ----------- Updates for SASxport 1.3.5 Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2013-06-14 16:22:39 UTC (rev 1670) +++ trunk/SASxport/DESCRIPTION 2013-06-14 16:26:02 UTC (rev 1671) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.3.4 -Date: 2013-05-31 +Version: 1.3.5 +Date: 2013-06-14 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2013-06-14 16:22:39 UTC (rev 1670) +++ trunk/SASxport/inst/NEWS 2013-06-14 16:26:02 UTC (rev 1671) @@ -1,3 +1,11 @@ +Version 1.3.5 2013-06-14 +------------------------ + +Bug fixes: + +- read.xport() and write.xport() now properly handle empty + dataset/dataframe objects. + Version 1.3.4 2013-05-31 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-10-09 18:18:11
|
Revision: 1719 http://sourceforge.net/p/r-gregmisc/code/1719 Author: warnes Date: 2013-10-09 18:18:08 +0000 (Wed, 09 Oct 2013) Log Message: ----------- Update for SASxport 1.3.6 release Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2013-10-09 18:15:08 UTC (rev 1718) +++ trunk/SASxport/DESCRIPTION 2013-10-09 18:18:08 UTC (rev 1719) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.3.5 -Date: 2013-06-14 +Version: 1.3.6 +Date: 2013-10-09 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either @@ -38,6 +38,6 @@ <http://metruminstitute.org>. Maintainer: Gregory R. Warnes <gr...@wa...> License: GPL-2 -Depends: R (>= 2.4.0) +Depends: R (>= 2.4.0), chron Imports: chron URL: http://www.warnes.net, http://metruminstitute.org Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2013-10-09 18:15:08 UTC (rev 1718) +++ trunk/SASxport/inst/NEWS 2013-10-09 18:18:08 UTC (rev 1719) @@ -1,3 +1,11 @@ +Version 1.3.6 2013-10-09 +------------------------ + +Bug fixes: + +- In manual pages for read.xport() and lookup.xporT(): Update URL for + 'test2.xpt', and use a local copy for executed example code. + Version 1.3.5 2013-06-14 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-04-10 02:02:29
|
Revision: 1803 http://sourceforge.net/p/r-gregmisc/code/1803 Author: warnes Date: 2014-04-10 02:02:25 +0000 (Thu, 10 Apr 2014) Log Message: ----------- Remove definitions of labels in favor of those coming from Hmisc. Modify read.xport and write.xport to use appropriate arguments for label method for data.frames. Modified Paths: -------------- trunk/SASxport/R/read.xport.R trunk/SASxport/R/write.xport.R Removed Paths: ------------- trunk/SASxport/R/label.R trunk/SASxport/man/label.Rd Deleted: trunk/SASxport/R/label.R =================================================================== --- trunk/SASxport/R/label.R 2014-04-09 23:52:17 UTC (rev 1802) +++ trunk/SASxport/R/label.R 2014-04-10 02:02:25 UTC (rev 1803) @@ -1,20 +0,0 @@ -label <- function(x, default) - UseMethod("label") - -label.default <- function(x, default=NULL) -{ - lab <- attr(x,"label") - if(is.null(lab)) - default - else - lab -} - -"label<-" <- function(x, value) - UseMethod("label<-") - -"label<-.default" <- function(x, value) -{ - attr(x,'label') <- value - x -} Modified: trunk/SASxport/R/read.xport.R =================================================================== --- trunk/SASxport/R/read.xport.R 2014-04-09 23:52:17 UTC (rev 1802) +++ trunk/SASxport/R/read.xport.R 2014-04-10 02:02:25 UTC (rev 1803) @@ -1,5 +1,5 @@ ## -## Code originally from Frank Harrell's 'Hmisc' library: +## 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 ## @@ -32,7 +32,7 @@ if(length(grep('http://', file))>0 || length(grep('ftp://', file))>0 ) { - scat("Downloading file...") + scat("Downloading file...") tf <- tempfile() download.file(file, tf, mode='wb', quiet=TRUE) file <- tf @@ -44,13 +44,13 @@ 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!") - + scat("Extracting data file information...") dsinfo <- lookup.xport.inner(file) dsLabels <- sapply(dsinfo, label) dsTypes <- sapply(dsinfo, SAStype) - + if(length(keep)) whichds <- toupper(keep) else @@ -65,7 +65,7 @@ names(ds) <- make.unique(names(ds)) } - + if( (length(keep)>0 || length(drop)>0) ) ds <- ds[whichds] @@ -82,7 +82,7 @@ fds <- fds[1] } } - + finfo <- NULL if(length(formats) || length(fds)) { if(length(formats)) @@ -108,7 +108,7 @@ names(res) <- gsub('_','.',dsn) - possiblyConvertChar <- (is.logical(as.is) && !as.is) || + possiblyConvertChar <- (is.logical(as.is) && !as.is) || (is.numeric(as.is) && as.is > 0) j <- 0 for(k in which.regular) { @@ -120,9 +120,9 @@ else ds[[k]] scat('.') - - label(w) <- dsLabels[k] - names(label(w)) <- NULL + + label(w, self=TRUE) <- dsLabels[k] + names(label(w, self=TRUE)) <- NULL SAStype(w) <- dsTypes[k] names(SAStype(w)) <- NULL @@ -137,7 +137,7 @@ iformats <- fstr( ifmt, dinfo$iflength, dinfo$ifdigits) lab <- dinfo$label - + ndinfo <- names.tolower(makeNames(dinfo$name, allow=name.chars)) names(lab) <- names(fmt) <- names(formats) <- names(iformats) <- ndinfo if(length(w)>0) @@ -176,13 +176,13 @@ } } } else if(possiblyConvertChar && is.character(x)) { - if((is.logical(as.is) && !as.is) || + if((is.logical(as.is) && !as.is) || (is.numeric(as.is) && length(unique(x)) < as.is*length(x))) { x <- factor(x, exclude='') changed <- TRUE } } - + lz <- lab[nam[i]] if(!is.null(lz) && length(lz)>0 && !is.na(lz) && lz != '') { names(lz) <- NULL @@ -195,13 +195,13 @@ SASformat(x) <- formats[[nam[i]]] changed <- TRUE } - + if(nam[i] %in% names(iformats) && iformats[nam[i]] > "" ) { SASformat(x) <- formats[[nam[i]]] changed <- TRUE } - + if(changed) w[[i]] <- x } @@ -216,7 +216,7 @@ if( include.formats ) { nds <- nds+1 - if( length(fds)>0 ) + if( length(fds)>0 ) res$"FORMATS" <- ds[[fds]] else res$FORMATS <- empty.format.table() Modified: trunk/SASxport/R/write.xport.R =================================================================== --- trunk/SASxport/R/write.xport.R 2014-04-09 23:52:17 UTC (rev 1802) +++ trunk/SASxport/R/write.xport.R 2014-04-10 02:02:25 UTC (rev 1803) @@ -1,13 +1,13 @@ write.xport <- function(..., list=base::list(), - file = stop("'file' must be specified"), + file = stop("'file' must be specified"), verbose=FALSE, sasVer="7.00", osType, cDate=Sys.time(), formats=NULL, autogen.formats=TRUE - ) + ) { ## Handle verbose option ## @@ -31,10 +31,10 @@ dotNames <- names(dotList) if(is.null(dotNames)) dotNames <- rep("", length(dotList)) - if(length(dotList)>0) + if(length(dotList)>0) { ## Get data frame names from ... in function call, but don't - ## clobber any explicitly provided names + ## clobber any explicitly provided names mc <- match.call() mc$file <- NULL mc$verbose <- NULL @@ -45,8 +45,8 @@ mc$autogen.formats <- NULL mc[[1]] <- NULL # note we *do not* mask off format argument so it will get - # magically included if present. - + # magically included if present. + mc <- as.character(mc) badNames <- which(is.na(dotNames) | dotNames<="") @@ -59,7 +59,7 @@ listNames <- rep("", length(list)) dfList <- c(dotList, list) dfNames <- c(dotNames, listNames) - + ## check for and handle <NA> or empty names ## badNames <- which(is.na(dfNames) | dfNames<="") if(length(badNames)>0) @@ -79,7 +79,7 @@ if(length(not.df)==1) stop(paste("'", dfNames[not.df], "'"), " is not a data.frame object.") - else + else stop(paste("'", dfNames[not.df], "'", sep="", collapse=", "), " are not data.frame objects.") ## @@ -111,8 +111,8 @@ ####### scat("opening file ...") - if (is.character(file)) - if (file == "") + if (is.character(file)) + if (file == "") file <- stdout() else { file <- file(description=file, open="wb") @@ -132,10 +132,10 @@ scat("Write file header ...") out( xport.file.header( cDate=cDate, sasVer=sasVer, osType=osType ) ) scat("Done.") - + for(i in dfNames) { - + df <- dfList[[i]] if(is.null(colnames(df))) @@ -149,17 +149,17 @@ dfList[[i]] <- df } - + colnames(dfList[[i]]) <- colnames(df) <- varNames <- makeSASNames(colnames(df)) - + offsetTable <- data.frame("name"=varNames, "len"=rep(NA, length(varNames)), "offset"=rep(NA, length(varNames)) ) rownames(offsetTable) <- offsetTable[,"name"] - dfLabel <- label(df, default="" ) + dfLabel <- label(df, default="", self=TRUE ) dfType <- SAStype(df, default="") - + scat("Write data frame header ...") out( xport.member.header(dfName=i, cDate=cDate, sasVer=sasVer, osType=osType, dfLabel=dfLabel, dfType=dfType) ) @@ -168,7 +168,7 @@ scat("Write variable information block header ...") out( xport.namestr.header( nvar=ncol(df) ) ) scat("Done.") - + scat("Write entries for variable information block ...") lenIndex <- 0 varIndex <- 1 @@ -197,14 +197,14 @@ offsetTable[i, "offset"] <- lenIndex - + # parse format and iformat formatInfo <- parseFormat(varFormat) iFormatInfo <- parseFormat(varIFormat) - - - + + + # write the entry out( xport.namestr( @@ -213,7 +213,7 @@ varNum = varIndex, varPos = lenIndex, varLength = varLen, - varLabel = varLabel, + varLabel = varLabel, fName = formatInfo$name, fLength = formatInfo$len, fDigits = formatInfo$digits, @@ -232,8 +232,8 @@ # Space-fill to 80 character record end fillSize <- 80 - (spaceUsed %% 80) - if(fillSize==80) fillSize <- 0 - out( xport.fill( TRUE, fillSize ) ) + if(fillSize==80) fillSize <- 0 + out( xport.fill( TRUE, fillSize ) ) scat("Write header for data block ...") out( xport.obs.header() ) @@ -248,7 +248,7 @@ { val <- df[i,j] valLen <- offsetTable[j,"len"] - + scat("i=", i, " j=", j, " value=", val, " len=", valLen, ""); if(is.character( val )) { @@ -260,18 +260,18 @@ spaceUsed <- spaceUsed + valLen } } - + fillSize <- 80 - (spaceUsed %% 80) if(fillSize==80) fillSize <- 0 out( xport.fill(TRUE, fillSize ) ) - + scat("Done.") } scat("Closing file ...") - if (is.character(file)) + if (is.character(file)) if (file != "") - { + { close(file) on.exit() } Deleted: trunk/SASxport/man/label.Rd =================================================================== --- trunk/SASxport/man/label.Rd 2014-04-09 23:52:17 UTC (rev 1802) +++ trunk/SASxport/man/label.Rd 2014-04-10 02:02:25 UTC (rev 1803) @@ -1,107 +0,0 @@ -\name{label} - -\alias{label} -\alias{label.default} -\alias{label<-} -\alias{label<-.default} - -\alias{SASformat} -\alias{SASformat.default} -\alias{SASformat<-} -\alias{SASformat<-.default} - -\alias{SASiformat} -\alias{SASiformat.default} -\alias{SASiformat<-} -\alias{SASiformat<-.default} - -\alias{SAStype} -\alias{SAStype.default} -\alias{SAStype<-} -\alias{SAStype<-.default} - -\title{ -Set or Retreive the 'label', 'SASformat', 'SASiformat', or 'SAStype' -attribute of a vector or (components of) a data frame -} -\description{ - Sets or retrieves the \code{"label"}, \code{"SASformat"}, - \code{"SASiformat"}, or \code{SAStype} attribute of an object. - - More comprehensive support for object labels, and SASformat, are - available in Frank Harrell's \code{Hmisc} package. - - Note that \code{SAStype} enforces the SAS 8-character naming convention. -} -\usage{ -label(x, default) -label(x) <- value - -SASformat(x, default) -SASformat(x) <- value - -SASiformat(x, default) -SASiformat(x) <- value - -SAStype(x, default) -SAStype(x) <- value -} -\arguments{ -\item{x}{any object} -\item{value}{new value for the \code{"label"}, \code{"SASformat"}, - \code{"SASiformat"}, or \code{SAStype} attribute of an object.} -\item{default}{value to return when no appropriate attribute is - found. The usual return value is NULL.} -} -\value{ - the contents of the \code{"label"}, \code{"SASformat"}, - \code{"SASiformat"}, \code{"SAStype"} attribute of x, if any; - otherwise, the value provided by \code{default}. -} -\author{ - Gregory R. Warnes \email{gr...@wa...} based on code from the - \code{Hmisc} library by Frank E. Harrell, Jr. ] -} -%\seealso{ -%} -\examples{ - -## Examples for vectors - -fail.time <- c(10,20) - -# set attributes -label(fail.time) <- 'Failure Time' -SASformat(fail.time) <- 'Numeric2' -SASiformat(fail.time) <- 'Numeric2' - -# display individual attributes -label(fail.time) -SASformat(fail.time) -SASiformat(fail.time) - -# display all attributes -attributes(fail.time) - -## SAStype only applies to data frames -df <- data.frame( fail.time, day=c("Mon","Tue") ) -label(df) <- "Data frame object" -SAStype(df) <- "USER" - -label(df) -SAStype(df) - -## Example showing specification of default return value -a <- 70 -label(a, default="no label") - -\dontrun{ -# Hmisc packages functions label attributes for annotating tables and plots: -library(Hmisc) -label(fail.time) -describe(fail.time) -} -} -\keyword{utilities} -\keyword{interface} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-04-10 02:03:22
|
Revision: 1804 http://sourceforge.net/p/r-gregmisc/code/1804 Author: warnes Date: 2014-04-10 02:03:19 +0000 (Thu, 10 Apr 2014) Log Message: ----------- Remove definitions of labels in favor of those coming from Hmisc. Modify read.xport and write.xport to use appropriate arguments for label method for data.frames. Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/NAMESPACE Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2014-04-10 02:02:25 UTC (rev 1803) +++ trunk/SASxport/DESCRIPTION 2014-04-10 02:03:19 UTC (rev 1804) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.3.6 -Date: 2013-10-09 +Version: 1.3.7 +Date: 2014-04-09 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either @@ -38,5 +38,5 @@ <http://metruminstitute.org>. Maintainer: Gregory R. Warnes <gr...@wa...> License: GPL-2 -Depends: R (>= 2.4.0), chron +Depends: R (>= 2.4.0), chron, Hmisc URL: http://www.warnes.net, http://metruminstitute.org Modified: trunk/SASxport/NAMESPACE =================================================================== --- trunk/SASxport/NAMESPACE 2014-04-10 02:02:25 UTC (rev 1803) +++ trunk/SASxport/NAMESPACE 2014-04-10 02:03:19 UTC (rev 1804) @@ -2,20 +2,21 @@ importFrom(chron, chron, times) importFrom(utils, packageDescription) +importFrom(Hmisc, label, "label<-") export( toSAS, lookup.xport, read.xport, write.xport, - "label", - "label<-", + ## "label", + ## "label<-", makeSASNames, - + "SASformat", "SASformat<-", - + "SASiformat", "SASiformat<-", @@ -32,12 +33,12 @@ S3method(toSAS, Date) S3method(toSAS, default) -S3method(label, default) +## S3method(label, default) S3method(SASformat, default) S3method(SASiformat, default) S3method(SAStype, default) -S3method("label<-", default) +## S3method("label<-", default) S3method("SASformat<-", default) S3method("SASiformat<-", default) S3method("SAStype<-", default) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-04-10 02:11:49
|
Revision: 1805 http://sourceforge.net/p/r-gregmisc/code/1805 Author: warnes Date: 2014-04-10 02:11:45 +0000 (Thu, 10 Apr 2014) Log Message: ----------- Update for SASxport 1.4.0. Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2014-04-10 02:03:19 UTC (rev 1804) +++ trunk/SASxport/DESCRIPTION 2014-04-10 02:11:45 UTC (rev 1805) @@ -1,7 +1,7 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.3.7 +Version: 1.4.0 Date: 2014-04-09 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2014-04-10 02:03:19 UTC (rev 1804) +++ trunk/SASxport/inst/NEWS 2014-04-10 02:11:45 UTC (rev 1805) @@ -1,3 +1,20 @@ +Version 1.4.0 - 2014-04-09 +-------------------------- + +API Change: + +- SASxport now relies on the 'label' methods defined by the Hmisc + package instead of defining its own. + +Bug fixes: + +- The 'read.xport' and 'write.xport' functions were failing when both + the SASxport and the Hmisc packages were loaded due to conflicts + between the label methods defined by each package. This has been + resolved by removing the label methods from SASxport and using those + from Hmisc instead. + + Version 1.3.6 2013-10-09 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-17 02:16:25
|
Revision: 1828 http://sourceforge.net/p/r-gregmisc/code/1828 Author: warnes Date: 2014-07-17 02:16:22 +0000 (Thu, 17 Jul 2014) Log Message: ----------- Update DESCRIPTION and NEWS for SASxport 1.4.1. Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2014-07-17 02:15:45 UTC (rev 1827) +++ trunk/SASxport/DESCRIPTION 2014-07-17 02:16:22 UTC (rev 1828) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.4.0 -Date: 2014-04-09 +Version: 1.4.1 +Date: 2014-07-16 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2014-07-17 02:15:45 UTC (rev 1827) +++ trunk/SASxport/inst/NEWS 2014-07-17 02:16:22 UTC (rev 1828) @@ -1,3 +1,14 @@ +Version 1.4.1 - 2014-07-16 +-------------------------- + +Bug fixes: + +- 'read.xport' now preserves '$' at the beginning of SAS character + format and iformat strings. + +- 'read.xport' argument names.tolower was not being honored for dataset + names. + Version 1.4.0 - 2014-04-09 -------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-18 12:08:06
|
Revision: 1834 http://sourceforge.net/p/r-gregmisc/code/1834 Author: warnes Date: 2014-07-18 12:08:03 +0000 (Fri, 18 Jul 2014) Log Message: ----------- Remove SASxport:::assert() and replace all uses with stopifnot() Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS trunk/SASxport/tests/Alfalfa_Test.R trunk/SASxport/tests/Theoph.R trunk/SASxport/tests/cars.R trunk/SASxport/tests/testNegative.R trunk/SASxport/tests/testNumeric.R trunk/SASxport/tests/testUnnamedComponents.R trunk/SASxport/tests/test_as_is.R trunk/SASxport/tests/test_fields.R trunk/SASxport/tests/xxx.R Removed Paths: ------------- trunk/SASxport/R/assert.R Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/DESCRIPTION 2014-07-18 12:08:03 UTC (rev 1834) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.4.1 -Date: 2014-07-16 +Version: 1.4.2 +Date: 2014-07-17 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Deleted: trunk/SASxport/R/assert.R =================================================================== --- trunk/SASxport/R/assert.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/R/assert.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -1,6 +0,0 @@ -## useful function, raises an error if the FLAG expression is FALSE -assert <- function( FLAG ) - { - if(!all(FLAG)) - stop("Failed Assertion") - } Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/inst/NEWS 2014-07-18 12:08:03 UTC (rev 1834) @@ -1,3 +1,15 @@ +Version 1.4.2 - 2014-07-17 +-------------------------- + +Bug fixes: + +- Explicitly cast left shifts in ibm2ieee.c to avoid undefined + behavior. (Reported by Brian Ripley) + +- Resolve problem in accessing "Hmisc::label.default<-" if + SASxport::read.xport is called without loading SASxport. (Reported + by Dominic Comtois) + Version 1.4.1 - 2014-07-16 -------------------------- @@ -4,10 +16,10 @@ Bug fixes: - 'read.xport' now preserves '$' at the beginning of SAS character - format and iformat strings. + format and iformat strings. (Reported by Dominic Comtois) -- 'read.xport' argument names.tolower was not being honored for dataset - names. +- 'read.xport' argument names.tolower was not being honored for + dataset names. (Reported by Dominic Comtois) Version 1.4.0 - 2014-04-09 -------------------------- Modified: trunk/SASxport/tests/Alfalfa_Test.R =================================================================== --- trunk/SASxport/tests/Alfalfa_Test.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/Alfalfa_Test.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -21,4 +21,4 @@ a.2 <- readBin( con="Alfalfa2.xpt", what=raw(), n=3600 ) ## Test that the files are identical -SASxport:::assert( all(a.1 == a.2) ) +stopifnot( all(a.1 == a.2) ) Modified: trunk/SASxport/tests/Theoph.R =================================================================== --- trunk/SASxport/tests/Theoph.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/Theoph.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -15,6 +15,6 @@ ## Test equality, handling the ordered factor Subject separately because ## SAS xport files don't provide a mechanism for storing factor orders -SASxport:::assert( all( as.character(Theoph$Subject) == as.character(Theoph.2$Subject) )) -SASxport:::assert( all(Theoph[,-1] == Theoph.2[,-1]) ) +stopifnot( all( as.character(Theoph$Subject) == as.character(Theoph.2$Subject) )) +stopifnot( all(Theoph[,-1] == Theoph.2[,-1]) ) Modified: trunk/SASxport/tests/cars.R =================================================================== --- trunk/SASxport/tests/cars.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/cars.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -24,4 +24,4 @@ a.2 <- readBin( con="cars2.xpt", what=raw(), n=1e5) ## Test that the files are identical -SASxport:::assert( all(a.1 == a.2) ) +stopifnot( all(a.1 == a.2) ) Modified: trunk/SASxport/tests/testNegative.R =================================================================== --- trunk/SASxport/tests/testNegative.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/testNegative.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -8,10 +8,10 @@ print(df1) print(df2) -SASxport:::assert(all(df1==df2)) +stopifnot(all(df1==df2)) df3 <- data.frame(x.continuous=seq(-100,100,by=0.5), x.integer=as.integer(seq(-100,100,by=0.5)) ) write.xport(df3, file='df3.xpt') df4 <- read.xport(file='df3.xpt') -SASxport:::assert(all(df3==df4)) +stopifnot(all(df3==df4)) Modified: trunk/SASxport/tests/testNumeric.R =================================================================== --- trunk/SASxport/tests/testNumeric.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/testNumeric.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -16,7 +16,7 @@ write.xport(df, file='testNumeric.xpt') df.2 <- read.xport(file='testNumeric.xpt') -SASxport:::assert( all(df == df.2, na.rm=TRUE) ) +stopifnot( all(df == df.2, na.rm=TRUE) ) df.2 # this gets properly handled @@ -25,6 +25,6 @@ df.2 <- read.xport(file='testNumeric.xpt') -SASxport:::assert(all(df==df.2,na.rm=TRUE)) +stopifnot(all(df==df.2,na.rm=TRUE)) df.2 Modified: trunk/SASxport/tests/testUnnamedComponents.R =================================================================== --- trunk/SASxport/tests/testUnnamedComponents.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/testUnnamedComponents.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -48,11 +48,11 @@ ### Check that we catch invalid parameters failure <- try( write.xport(5,"a.xpt") ) #10.a -SASxport:::assert( "try-error" %in% class(failure) ) #10.b +stopifnot( "try-error" %in% class(failure) ) #10.b (tmp <- read.xport("a.xpt")) #10.c failure <- try( write.xport(list(a=5,b=6),"a.xpt") ) #11.a -SASxport:::assert( "try-error" %in% class(failure) ) #11.b +stopifnot( "try-error" %in% class(failure) ) #11.b (tmp <- read.xport("a.xpt")) #10.c # Check with different list construction function *name* Modified: trunk/SASxport/tests/test_as_is.R =================================================================== --- trunk/SASxport/tests/test_as_is.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/test_as_is.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -8,7 +8,7 @@ x <- read.xport('puromycin.xpt') str(x) -SASxport:::assert( class(x$STATE)=="factor" ) +stopifnot( class(x$STATE)=="factor" ) ## When as.is=TRUE, character variable "STATE" should be preserved as ## a character variable. @@ -16,6 +16,6 @@ x <- read.xport('puromycin.xpt',as.is=TRUE) str(x) -SASxport:::assert( class(x$STATE)=="character" ) +stopifnot( class(x$STATE)=="character" ) Modified: trunk/SASxport/tests/test_fields.R =================================================================== --- trunk/SASxport/tests/test_fields.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/test_fields.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -5,4 +5,4 @@ .C("doTest",PACKAGE="SASxport") -## Successful completion means all SASxport:::assertions have been met +## Successful completion means all assertions have been met Modified: trunk/SASxport/tests/xxx.R =================================================================== --- trunk/SASxport/tests/xxx.R 2014-07-18 11:32:48 UTC (rev 1833) +++ trunk/SASxport/tests/xxx.R 2014-07-18 12:08:03 UTC (rev 1834) @@ -50,7 +50,7 @@ a.1[1089] <- as.raw("0x2e") ## Test that the files are otherwise identical -SASxport:::assert( all(a.1 == a.2) ) -SASxport:::assert( all(a.1 == a.3) ) +stopifnot( all(a.1 == a.2) ) +stopifnot( all(a.1 == a.3) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-21 14:48:30
|
Revision: 1861 http://sourceforge.net/p/r-gregmisc/code/1861 Author: warnes Date: 2014-07-21 14:48:27 +0000 (Mon, 21 Jul 2014) Log Message: ----------- Change version number to 1.5.0 and update NEWS file. Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2014-07-21 14:43:57 UTC (rev 1860) +++ trunk/SASxport/DESCRIPTION 2014-07-21 14:48:27 UTC (rev 1861) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.4.2 -Date: 2014-07-17 +Version: 1.5.0 +Date: 2014-07-21 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2014-07-21 14:43:57 UTC (rev 1860) +++ trunk/SASxport/inst/NEWS 2014-07-21 14:48:27 UTC (rev 1861) @@ -1,8 +1,11 @@ -Version 1.4.2 - 2014-07-17 +Version 1.5.0 - 2014-07-21 -------------------------- Bug fixes: +- Now works properly on big-endian systems such as the PowerPC, + Spark. (Reported by Brian Ripley ) + - Explicitly cast left bit shifts to avoid undefined C language behavior. (Reported by Brian Ripley) @@ -10,6 +13,12 @@ SASxport::read.xport is called without loading SASxport. (Reported by Dominic Comtois) +- 'read.xport' now preserves '$' at the beginning of SAS character + format and iformat strings. (Reported by Dominic Comtois) + +- 'read.xport' argument names.tolower was not being honored for + dataset names. (Reported by Dominic Comtois) + Other changes: - Modified several test files to display generated .xpt data so that @@ -17,17 +26,7 @@ - C code cleanup and reorgaization to improve clarity. -Version 1.4.1 - 2014-07-16 --------------------------- -Bug fixes: - -- 'read.xport' now preserves '$' at the beginning of SAS character - format and iformat strings. (Reported by Dominic Comtois) - -- 'read.xport' argument names.tolower was not being honored for - dataset names. (Reported by Dominic Comtois) - Version 1.4.0 - 2014-04-09 -------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2014-07-21 14:51:52
|
Revision: 1862 http://sourceforge.net/p/r-gregmisc/code/1862 Author: warnes Date: 2014-07-21 14:51:44 +0000 (Mon, 21 Jul 2014) Log Message: ----------- Update version number in test script output comparison files. Modified Paths: -------------- trunk/SASxport/inst/NEWS trunk/SASxport/tests/Alfalfa_Test.Rout.save trunk/SASxport/tests/Theoph.Rout.save trunk/SASxport/tests/cars.Rout.save trunk/SASxport/tests/testDates.Rout.save trunk/SASxport/tests/testDuplicateNames.Rout.save trunk/SASxport/tests/testEmpty.Rout.save trunk/SASxport/tests/testExamples.Rout.save trunk/SASxport/tests/testManyNames.Rout.save trunk/SASxport/tests/testNegative.Rout.save trunk/SASxport/tests/testNumeric.Rout.save trunk/SASxport/tests/testUnnamedComponents.Rout.save trunk/SASxport/tests/test_as_is.Rout.save trunk/SASxport/tests/test_fields.Rout.save trunk/SASxport/tests/xport.Rout.save trunk/SASxport/tests/xxx.Rout.save Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/inst/NEWS 2014-07-21 14:51:44 UTC (rev 1862) @@ -4,7 +4,7 @@ Bug fixes: - Now works properly on big-endian systems such as the PowerPC, - Spark. (Reported by Brian Ripley ) + Spark. (Reported by Brian Ripley )x - Explicitly cast left bit shifts to avoid undefined C language behavior. (Reported by Brian Ripley) Modified: trunk/SASxport/tests/Alfalfa_Test.Rout.save =================================================================== --- trunk/SASxport/tests/Alfalfa_Test.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/Alfalfa_Test.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -34,7 +34,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -861,4 +861,4 @@ > > proc.time() user system elapsed - 0.557 0.059 0.608 + 0.518 0.053 0.561 Modified: trunk/SASxport/tests/Theoph.Rout.save =================================================================== --- trunk/SASxport/tests/Theoph.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/Theoph.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -36,7 +36,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -57,4 +57,4 @@ > > proc.time() user system elapsed - 0.599 0.038 0.627 + 0.584 0.038 0.610 Modified: trunk/SASxport/tests/cars.Rout.save =================================================================== --- trunk/SASxport/tests/cars.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/cars.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -525,4 +525,4 @@ > > proc.time() user system elapsed - 0.471 0.048 0.504 + 0.483 0.048 0.533 Modified: trunk/SASxport/tests/testDates.Rout.save =================================================================== --- trunk/SASxport/tests/testDates.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testDates.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -76,4 +76,4 @@ > > proc.time() user system elapsed - 0.468 0.034 0.491 + 0.472 0.034 0.496 Modified: trunk/SASxport/tests/testDuplicateNames.Rout.save =================================================================== --- trunk/SASxport/tests/testDuplicateNames.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testDuplicateNames.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -84,4 +84,4 @@ > > proc.time() user system elapsed - 0.485 0.036 0.510 + 0.493 0.036 0.518 Modified: trunk/SASxport/tests/testEmpty.Rout.save =================================================================== --- trunk/SASxport/tests/testEmpty.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testEmpty.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -84,4 +84,4 @@ > > proc.time() user system elapsed - 0.529 0.039 0.558 + 0.515 0.038 0.541 Modified: trunk/SASxport/tests/testExamples.Rout.save =================================================================== --- trunk/SASxport/tests/testExamples.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testExamples.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -968,4 +968,4 @@ > > proc.time() user system elapsed - 0.723 0.049 0.763 + 0.709 0.045 0.744 Modified: trunk/SASxport/tests/testManyNames.Rout.save =================================================================== --- trunk/SASxport/tests/testManyNames.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testManyNames.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -109,4 +109,4 @@ > > proc.time() user system elapsed - 4.396 0.056 4.447 + 4.290 0.056 4.341 Modified: trunk/SASxport/tests/testNegative.Rout.save =================================================================== --- trunk/SASxport/tests/testNegative.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testNegative.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -62,4 +62,4 @@ > > proc.time() user system elapsed - 0.518 0.036 0.545 + 0.513 0.036 0.538 Modified: trunk/SASxport/tests/testNumeric.Rout.save =================================================================== --- trunk/SASxport/tests/testNumeric.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testNumeric.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -101,4 +101,4 @@ > > proc.time() user system elapsed - 0.589 0.039 0.617 + 0.560 0.034 0.584 Modified: trunk/SASxport/tests/testUnnamedComponents.Rout.save =================================================================== --- trunk/SASxport/tests/testUnnamedComponents.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/testUnnamedComponents.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -2130,4 +2130,4 @@ > > proc.time() user system elapsed - 1.546 0.064 1.605 + 1.561 0.059 1.615 Modified: trunk/SASxport/tests/test_as_is.Rout.save =================================================================== --- trunk/SASxport/tests/test_as_is.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/test_as_is.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -85,4 +85,4 @@ > > proc.time() user system elapsed - 0.422 0.033 0.449 + 0.424 0.033 0.445 Modified: trunk/SASxport/tests/test_fields.Rout.save =================================================================== --- trunk/SASxport/tests/test_fields.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/test_fields.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -46,4 +46,4 @@ > > proc.time() user system elapsed - 0.393 0.035 0.416 + 0.378 0.035 0.406 Modified: trunk/SASxport/tests/xport.Rout.save =================================================================== --- trunk/SASxport/tests/xport.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/xport.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -120,4 +120,4 @@ > q() > proc.time() user system elapsed - 0.430 0.036 0.451 + 0.427 0.033 0.448 Modified: trunk/SASxport/tests/xxx.Rout.save =================================================================== --- trunk/SASxport/tests/xxx.Rout.save 2014-07-21 14:48:27 UTC (rev 1861) +++ trunk/SASxport/tests/xxx.Rout.save 2014-07-21 14:51:44 UTC (rev 1862) @@ -31,7 +31,7 @@ format.pval, round.POSIXt, trunc.POSIXt, units -Loaded SASxport version 1.4.2 (2014-07-17). +Loaded SASxport version 1.5.0 (2014-07-21). Type `?SASxport' for usage information. @@ -237,4 +237,4 @@ > > proc.time() user system elapsed - 0.438 0.042 0.470 + 0.434 0.041 0.464 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |