From noreply at r-forge.r-project.org Thu Oct 15 22:46:52 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 15 Oct 2015 22:46:52 +0200 (CEST) Subject: [R-gregmisc-commits] r2068 - pkg/gdata/R Message-ID: <20151015204652.D52E7185142@r-forge.r-project.org> Author: warnes Date: 2015-10-15 22:46:52 +0200 (Thu, 15 Oct 2015) New Revision: 2068 Modified: pkg/gdata/R/installXLSXsupport.R Log: Remove unused call to tempdir(). Modified: pkg/gdata/R/installXLSXsupport.R =================================================================== --- pkg/gdata/R/installXLSXsupport.R 2015-08-08 05:01:12 UTC (rev 2067) +++ pkg/gdata/R/installXLSXsupport.R 2015-10-15 20:46:52 UTC (rev 2068) @@ -7,18 +7,17 @@ findPerl(verbose = verbose) else findPerl(perl, verbose = verbose) - + ## ## directories package.dir <- find.package('gdata') perl.dir <- file.path(package.dir,'perl') - temp.dir <- tempdir() ## ## cmd <- "install_modules.pl" sc <- file.path(perl.dir, cmd) - + ## ## @@ -54,6 +53,6 @@ else { stop("\nUnable to install Perl XLSX support libraries.\n\n") - invisible(FALSE) - } + invisible(FALSE) + } } From noreply at r-forge.r-project.org Thu Oct 15 23:15:58 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 15 Oct 2015 23:15:58 +0200 (CEST) Subject: [R-gregmisc-commits] r2069 - pkg/gtools/R Message-ID: <20151015211558.8D749187B69@r-forge.r-project.org> Author: warnes Date: 2015-10-15 23:15:57 +0200 (Thu, 15 Oct 2015) New Revision: 2069 Modified: pkg/gtools/R/smartbind.R Log: smartbind() was not properly handling columsn that were numeric on one df and character in the other and other similar ctype conflicts. Fixed. Modified: pkg/gtools/R/smartbind.R =================================================================== --- pkg/gtools/R/smartbind.R 2015-10-15 20:46:52 UTC (rev 2068) +++ pkg/gtools/R/smartbind.R 2015-10-15 21:15:57 UTC (rev 2069) @@ -11,14 +11,14 @@ } defaultNames <- seq.int(length(data)) - + if(is.null(names(data))) names(data) <- defaultNames emptyNames <- names(data)=="" if (any(emptyNames) ) names(data)[emptyNames] <- defaultNames[emptyNames] - + data <- lapply(data, function(x) if(is.matrix(x) || is.data.frame(x)) @@ -95,7 +95,31 @@ retval[[col]] <- as.vector(rep(fill,nrows), mode=newclass) } - mode <- class(retval[[col]]) + ## Handle case when current and previous native types differ + oldclass <- class(retval[[col]]) + + if(oldclass != newclass) + { + # handle conversions in case of conflicts + # numeric vs integer --> numeric + # complex vs numeric or integer --> complex + # anything else: --> character + if(oldclass %in% c("integer", "numeric") && newclass %in% c("integer", "numeric") ) + class(retval[[col]]) <- mode <- "numeric" + else if(oldclass=="complex" && newclass %in% c("integer", "numeric") ) + class(retval[[col]]) <- mode <- "complex" + else if(oldclass %in% c("integer", "numeric") && newclass=="complex") + class(retval[[col]]) <- mode <- "complex" + else + { + class(retval[[col]]) <- mode <- "character" + warning("Column class mismatch for '", col, "'. ", + "Converting column to class 'character'.") + } + } + else + mode <- oldclass + if(mode=="character") vals <- as.character(block[,col]) else