[R-gregmisc-users] SF.net SVN: r-gregmisc:[1883] trunk/gdata
Brought to you by:
warnes
From: <wa...@us...> - 2014-08-28 15:01:54
|
Revision: 1883 http://sourceforge.net/p/r-gregmisc/code/1883 Author: warnes Date: 2014-08-28 15:01:51 +0000 (Thu, 28 Aug 2014) Log Message: ----------- Everything works now! Modified Paths: -------------- trunk/gdata/R/trim.R trunk/gdata/inst/NEWS trunk/gdata/inst/perl/xls2csv.pl trunk/gdata/inst/xls/ExampleExcelFile.xls trunk/gdata/inst/xls/ExampleExcelFile.xlsx trunk/gdata/inst/xls/ExampleExcelFile_1900.xls trunk/gdata/inst/xls/ExampleExcelFile_1900.xlsx trunk/gdata/inst/xls/ExampleExcelFile_1904.xls trunk/gdata/inst/xls/ExampleExcelFile_1904.xlsx trunk/gdata/tests/test.read.xls.R trunk/gdata/tests/test.read.xls.Rout.save trunk/gdata/tests/tests.write.fwf.Rout.save Modified: trunk/gdata/R/trim.R =================================================================== --- trunk/gdata/R/trim.R 2014-08-28 05:22:50 UTC (rev 1882) +++ trunk/gdata/R/trim.R 2014-08-28 15:01:51 UTC (rev 1883) @@ -19,7 +19,7 @@ if(recode.factor) { dots <- list(x=s, ...) if(is.null(dots$sort)) dots$sort <- sort - s <- do.call(what=reorder.factor, args=dots) + s <- do.call(what="reorder.factor", args=dots) } s } Modified: trunk/gdata/inst/NEWS =================================================================== --- trunk/gdata/inst/NEWS 2014-08-28 05:22:50 UTC (rev 1882) +++ trunk/gdata/inst/NEWS 2014-08-28 15:01:51 UTC (rev 1883) @@ -6,6 +6,10 @@ - read.xls() can now properly process XLSX files with up to 16385 columns (the maximum generated by Microsoft Excel). +- read.xls() now properly handles XLS/XLSX files that use 1904-01-01 + as the reference value for dates instead of 1900-01-01 (the + default for MS-Excel files created on the Mac). + Other changes: - Updated perl libraries and code underlying read.xls() to the latest Modified: trunk/gdata/inst/perl/xls2csv.pl =================================================================== --- trunk/gdata/inst/perl/xls2csv.pl 2014-08-28 05:22:50 UTC (rev 1882) +++ trunk/gdata/inst/perl/xls2csv.pl 2014-08-28 15:01:51 UTC (rev 1883) @@ -27,9 +27,10 @@ my($row, $col, $sheet, $cell, $usage, $targetfile,$basename, $sheetnumber, $filename, $volume, $directories, $whoami, - $sep, $sepName, $sepLabel, $sepExt, + $sep, $sepName, $sepLabel, $sepExt, $skipBlankLines, %switches, - $parser, $oBook, $formatter + $parser, $oBook, $formatter, + $using_1904_date ); ## @@ -141,6 +142,7 @@ open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n"; close(FH); +print "\n"; print "Loading '$ARGV[0]'...\n"; ## First try as a Excel 2007+ 'xml' file eval @@ -158,9 +160,26 @@ } print "Done.\n"; +## Does this file use 1904-01-01 as the reference date instead of +## 1900-01-01? +$using_1904_date = ( $oBook->using_1904_date() == 1 ) || # ParseExcel + ( $oBook->{Flag1904} == 1 ); # ParseXLSX + + +## Show the user some summary information before we start extracting +## date print "\n"; print "Orignal Filename: ", $ARGV[0], "\n"; print "Number of Sheets: ", $oBook->{SheetCount} , "\n"; +if($using_1904_date) + { + print "Date reference : 1904-01-01\n"; + } +else + { + print "Date reference : 1900-01-01\n"; + } + print "\n"; ## Get list all worksheets in the file @@ -245,14 +264,35 @@ my $format = $formatter->FmtString($cell, $oBook); if( defined($cell) ) { - if ($cell->type() eq "Date" && $oBook->{Flag1904} ) + if ($cell->type() eq "Date") # && $using_1904_date ) { + my $is_date = ( $format =~ m/y/ && + $format =~ m/m/ && + $format =~ m/d/ ); + + my $is_time = ( $format =~ m/h[:\]]*m/ || + $format =~ m/m[:\]]*s/ ); + + + if($is_date && $is_time) + { + $format = "yyyy-mm-dd hh:mm:ss.00"; + } + elsif ($is_date) + { + $format = "yyyy-mm-dd"; + } + elsif ($is_time) + { + $format = "hh:mm:ss.00" + } + $_ = ExcelFmt($format, $cell->unformatted(), - $oBook->{Flag1904}); + $using_1904_date); } else - { + { $_=$cell->value(); } @@ -266,7 +306,7 @@ # they are used as field delimiters s/\"/\\\"/g; } - else + else { $_ = ''; } @@ -291,7 +331,7 @@ close OutFile; - print " (Ignored $cumulativeBlankLines blank lines.)\n" + print " (Ignored $cumulativeBlankLines blank lines.)\n" if $skipBlankLines; print "\n"; } Modified: trunk/gdata/inst/xls/ExampleExcelFile.xls =================================================================== (Binary files differ) Modified: trunk/gdata/inst/xls/ExampleExcelFile.xlsx =================================================================== (Binary files differ) Modified: trunk/gdata/inst/xls/ExampleExcelFile_1900.xls =================================================================== (Binary files differ) Modified: trunk/gdata/inst/xls/ExampleExcelFile_1900.xlsx =================================================================== (Binary files differ) Modified: trunk/gdata/inst/xls/ExampleExcelFile_1904.xls =================================================================== (Binary files differ) Modified: trunk/gdata/inst/xls/ExampleExcelFile_1904.xlsx =================================================================== (Binary files differ) Modified: trunk/gdata/tests/test.read.xls.R =================================================================== --- trunk/gdata/tests/test.read.xls.R 2014-08-28 05:22:50 UTC (rev 1882) +++ trunk/gdata/tests/test.read.xls.R 2014-08-28 15:01:51 UTC (rev 1883) @@ -23,19 +23,19 @@ exampleFile <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile.xls') -exampleFile2007 <- file.path(path.package('gdata'),'xls', +exampleFileX <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile.xlsx') # see the number and names of sheets: sheetCount(exampleFile) if( 'XLSX' %in% xlsFormats() ) - sheetCount(exampleFile2007) + sheetCount(exampleFileX) sheetNames(exampleFile) if( 'XLSX' %in% xlsFormats() ) - sheetNames(exampleFile2007) + sheetNames(exampleFileX) example.1 <- read.xls(exampleFile, sheet=1) # default is first worksheet example.1 @@ -46,28 +46,28 @@ example.3 <- read.xls(exampleFile, sheet=3, header=FALSE) # third worksheet by number example.3 -example.4 <- read.xls(exampleFile, sheet=3, header=FALSE) # third worksheet by number +example.4 <- read.xls(exampleFile, sheet=4, header=FALSE) # fourth worksheet by number example.4 if( 'XLSX' %in% xlsFormats() ) { - example.x.1 <- read.xls(exampleFile2007, sheet=1) # default is first worksheet + example.x.1 <- read.xls(exampleFileX, sheet=1) # default is first worksheet print(example.x.1) - example.x.2 <- read.xls(exampleFile2007, sheet=2) # second worksheet by number + example.x.2 <- read.xls(exampleFileX, sheet=2) # second worksheet by number print(example.x.2) - example.x.3 <- read.xls(exampleFile2007, sheet=3, header=FALSE) # third worksheet by number + example.x.3 <- read.xls(exampleFileX, sheet=3, header=FALSE) # third worksheet by number print(example.x.3) - example.x.4 <- read.xls(exampleFile2007, sheet=3, header=FALSE) # third worksheet by number + example.x.4 <- read.xls(exampleFileX, sheet=4, header=FALSE) # fourth worksheet by number print(example.x.4) - data <- read.xls(exampleFile2007, sheet="Sheet Second") # and by name + data <- read.xls(exampleFileX, sheet="Sheet Second") # and by name print(data) # load the third worksheet, skipping the first two non-data lines... - data <- read.xls(exampleFile2007, sheet="Sheet with initial text", skip=2) + data <- read.xls(exampleFileX, sheet="Sheet with initial text", skip=2) print(data) } @@ -79,7 +79,7 @@ if( 'XLSX' %in% xlsFormats() ) { - example.x.skip <- read.xls(exampleFile2007, sheet=2, blank.lines.skip=FALSE) + example.x.skip <- read.xls(exampleFileX, sheet=2, blank.lines.skip=FALSE) example.x.skip } @@ -114,18 +114,30 @@ ## Check handling of files with dates calulcated relative to ## 1900-01-01 and 1904-01-01 -file.1900 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1900.xls') -file.1904 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1904.xls') +file.1900 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1900.xls' ) +file.1904 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1904.xls' ) +fileX.1900 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1900.xlsx') +fileX.1904 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1904.xlsx') -example.1900 <- read.xls(file.1900, sheet=3) -example.1904 <- read.xls(file.1904, sheet=3) +example.1900 <- read.xls(file.1900, sheet=3, header=FALSE) +example.1900 -stopifnot( na.omit(example.1900 == example.1904) ) +example.1904 <- read.xls(file.1904, sheet=3, header=FALSE) +example.1904 -fileX.1900 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1900.xlsx') -fileX.1904 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1904.xlsx') +exampleX.1900 <- read.xls(file.1900, sheet=3, header=FALSE) +exampleX.1900 -exampleX.1900 <- read.xls(file.1900, sheet=3) -exampleX.1904 <- read.xls(file.1904, sheet=3) +exampleX.1904 <- read.xls(file.1904, sheet=3, header=FALSE) +exampleX.1904 -stopifnot( na.omit(exampleX.1900 == exampleX.1904) ) +# all colmns should be identical +stopifnot( na.omit(example.1900 == exampleX.1900) ) +stopifnot( na.omit(example.1904 == exampleX.1904) ) + +# column 8 will differ by 1462 due to different date baselines (1900 vs 1904) +stopifnot( na.omit(example.1900 [,-8] == example.1904 [,-8]) ) +stopifnot( na.omit(exampleX.1900[,-8] == exampleX.1904[,-8]) ) + +stopifnot( na.omit(example.1900 [,8] - example.1904 [,8]) == 1462 ) +stopifnot( na.omit(exampleX.1900[,8] - exampleX.1904[,8]) == 1462 ) Modified: trunk/gdata/tests/test.read.xls.Rout.save =================================================================== --- trunk/gdata/tests/test.read.xls.Rout.save 2014-08-28 05:22:50 UTC (rev 1882) +++ trunk/gdata/tests/test.read.xls.Rout.save 2014-08-28 15:01:51 UTC (rev 1883) @@ -1,7 +1,7 @@ -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 version 3.1.0 Patched (2014-05-26 r65771) -- "Spring Dance" +Copyright (C) 2014 The R Foundation for Statistical Computing +Platform: x86_64-apple-darwin13.1.0 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -507,7 +507,7 @@ > exampleFile <- file.path(path.package('gdata'),'xls', + 'ExampleExcelFile.xls') > -> exampleFile2007 <- file.path(path.package('gdata'),'xls', +> exampleFileX <- file.path(path.package('gdata'),'xls', + 'ExampleExcelFile.xlsx') > > # see the number and names of sheets: @@ -515,7 +515,7 @@ [1] 4 > > if( 'XLSX' %in% xlsFormats() ) -+ sheetCount(exampleFile2007) ++ sheetCount(exampleFileX) [1] 4 > > sheetNames(exampleFile) @@ -523,7 +523,7 @@ [3] "Sheet with a very long name!" "Sheet with initial text" > > if( 'XLSX' %in% xlsFormats() ) -+ sheetNames(exampleFile2007) ++ sheetNames(exampleFileX) [1] "Sheet First" "Sheet Second" [3] "Sheet with a very long name!" "Sheet with initial text" > @@ -548,51 +548,67 @@ > > example.3 <- read.xls(exampleFile, sheet=3, header=FALSE) # third worksheet by number > example.3 - V1 V2 V3 V4 V5 V6 -1 1 2001-01-01 1:01 0.2058182 NA A -2 2 2002-02-02 2:02 0.2910708 NA B -3 3 2003-03-03 3:03 0.3564875 -0.84147098 C -4 4 2004-04-04 4:04 0.4116363 0.70807342 -5 5 2005-05-05 5:05 0.4602234 0.50136797 A -6 6 2006-06-06 6:06 NA 0.25136984 B -7 7 2007-07-07 7:07 0.5445436 0.06318679 B -8 8 2008-08-08 8:08 0.5821416 NA C -9 9 2009-09-09 9:09 0.6174545 0.00000000 A -10 10 2010-10-10 10:10 0.6508541 0.00000000 A + V1 V2 V3 V4 V5 V6 V7 +1 1 2001-01-01 01:01:00.00 0.2058182 NA A 2001-01-01 01:01:01.01 +2 2 2002-02-02 02:02:00.00 0.2910708 NA B 2002-02-02 02:02:02.02 +3 3 2003-03-03 03:03:00.00 0.3564875 -0.84147098 C 2003-03-03 03:03:03.03 +4 4 2004-04-04 04:04:00.00 0.4116363 0.70807342 2004-04-04 04:04:04.04 +5 5 2005-05-05 05:05:00.00 0.4602234 0.50136797 A 2005-05-05 05:05:05.05 +6 6 2006-06-06 06:06:00.00 NA 0.25136984 B 2006-06-06 06:06:06.06 +7 7 2007-07-07 07:07:00.00 0.5445436 0.06318679 B 2007-07-07 07:07:07.07 +8 8 2008-08-08 08:08:00.00 0.5821416 NA C 2008-08-08 08:08:08.08 +9 9 2009-09-09 09:09:00.00 0.6174545 0.00000000 A 2009-09-09 09:09:09.09 +10 10 2010-10-10 10:10:00.00 0.6508541 0.00000000 A 2010-10-10 10:10:10.10 + V8 +1 36892.04 +2 37289.08 +3 37683.13 +4 38081.17 +5 38477.21 +6 38874.25 +7 39270.30 +8 39668.34 +9 40065.38 +10 40461.42 > -> example.4 <- read.xls(exampleFile, sheet=3, header=FALSE) # third worksheet by number +> example.4 <- read.xls(exampleFile, sheet=4, header=FALSE) # fourth worksheet by number > example.4 - V1 V2 V3 V4 V5 V6 -1 1 2001-01-01 1:01 0.2058182 NA A -2 2 2002-02-02 2:02 0.2910708 NA B -3 3 2003-03-03 3:03 0.3564875 -0.84147098 C -4 4 2004-04-04 4:04 0.4116363 0.70807342 -5 5 2005-05-05 5:05 0.4602234 0.50136797 A -6 6 2006-06-06 6:06 NA 0.25136984 B -7 7 2007-07-07 7:07 0.5445436 0.06318679 B -8 8 2008-08-08 8:08 0.5821416 NA C -9 9 2009-09-09 9:09 0.6174545 0.00000000 A -10 10 2010-10-10 10:10 0.6508541 0.00000000 A + V1 +1 This line contains text that would need to be skipped to get to the data +2 +3 +4 +5 +6 +7 + V2 V3 V4 V5 V6 V7 +1 +2 This line too! +3 D E F G Factor +4 FirstRow 1 <NA> <NA> <NA> Red +5 SecondRow 2 1 <NA> <NA> Green +6 ThirdRow 3 2 1 <NA> Red +7 FourthRow 4 3 2 1 Black > > if( 'XLSX' %in% xlsFormats() ) + { -+ example.x.1 <- read.xls(exampleFile2007, sheet=1) # default is first worksheet ++ example.x.1 <- read.xls(exampleFileX, sheet=1) # default is first worksheet + print(example.x.1) + -+ example.x.2 <- read.xls(exampleFile2007, sheet=2) # second worksheet by number ++ example.x.2 <- read.xls(exampleFileX, sheet=2) # second worksheet by number + print(example.x.2) + -+ example.x.3 <- read.xls(exampleFile2007, sheet=3, header=FALSE) # third worksheet by number ++ example.x.3 <- read.xls(exampleFileX, sheet=3, header=FALSE) # third worksheet by number + print(example.x.3) + -+ example.x.4 <- read.xls(exampleFile2007, sheet=3, header=FALSE) # third worksheet by number ++ example.x.4 <- read.xls(exampleFileX, sheet=4, header=FALSE) # fourth worksheet by number + print(example.x.4) + -+ data <- read.xls(exampleFile2007, sheet="Sheet Second") # and by name ++ data <- read.xls(exampleFileX, sheet="Sheet Second") # and by name + print(data) + + # load the third worksheet, skipping the first two non-data lines... -+ data <- read.xls(exampleFile2007, sheet="Sheet with initial text", skip=2) ++ data <- read.xls(exampleFileX, sheet="Sheet with initial text", skip=2) + print(data) + } A B C @@ -608,28 +624,44 @@ 2 SecondRow 2 1 NA NA Green 3 ThirdRow 3 2 1 NA Red 4 FourthRow 4 3 2 1 Black - V1 V2 V3 V4 V5 V6 -1 1 2001-01-01 1:01 0.2058182 NA A -2 2 2002-02-02 2:02 0.2910708 NA B -3 3 2003-03-03 3:03 0.3564875 -0.84147098 C -4 4 2004-04-04 4:04 0.4116363 0.70807342 -5 5 2005-05-05 5:05 0.4602234 0.50136797 A -6 6 2006-06-06 6:06 NA 0.25136984 B -7 7 2007-07-07 7:07 0.5445436 0.06318679 B -8 8 2008-08-08 8:08 0.5821416 NA C -9 9 2009-09-09 9:09 0.6174545 0.00000000 A -10 10 2010-10-10 10:10 0.6508541 0.00000000 A - V1 V2 V3 V4 V5 V6 -1 1 2001-01-01 1:01 0.2058182 NA A -2 2 2002-02-02 2:02 0.2910708 NA B -3 3 2003-03-03 3:03 0.3564875 -0.84147098 C -4 4 2004-04-04 4:04 0.4116363 0.70807342 -5 5 2005-05-05 5:05 0.4602234 0.50136797 A -6 6 2006-06-06 6:06 NA 0.25136984 B -7 7 2007-07-07 7:07 0.5445436 0.06318679 B -8 8 2008-08-08 8:08 0.5821416 NA C -9 9 2009-09-09 9:09 0.6174545 0.00000000 A -10 10 2010-10-10 10:10 0.6508541 0.00000000 A + V1 V2 V3 V4 V5 V6 V7 +1 1 2001-01-01 01:01:00.00 0.2058182 NA A 2001-01-01 01:01:01.01 +2 2 2002-02-02 02:02:00.00 0.2910708 NA B 2002-02-02 02:02:02.02 +3 3 2003-03-03 03:03:00.00 0.3564875 -0.84147098 C 2003-03-03 03:03:03.03 +4 4 2004-04-04 04:04:00.00 0.4116363 0.70807342 2004-04-04 04:04:04.04 +5 5 2005-05-05 05:05:00.00 0.4602234 0.50136797 A 2005-05-05 05:05:05.05 +6 6 2006-06-06 06:06:00.00 NA 0.25136984 B 2006-06-06 06:06:06.06 +7 7 2007-07-07 07:07:00.00 0.5445436 0.06318679 B 2007-07-07 07:07:07.07 +8 8 2008-08-08 08:08:00.00 0.5821416 NA C 2008-08-08 08:08:08.08 +9 9 2009-09-09 09:09:00.00 0.6174545 0.00000000 A 2009-09-09 09:09:09.09 +10 10 2010-10-10 10:10:00.00 0.6508541 0.00000000 A 2010-10-10 10:10:10.10 + V8 +1 36892.04 +2 37289.08 +3 37683.13 +4 38081.17 +5 38477.21 +6 38874.25 +7 39270.30 +8 39668.34 +9 40065.38 +10 40461.42 + V1 +1 This line contains text that would need to be skipped to get to the data +2 +3 +4 +5 +6 +7 + V2 V3 V4 V5 V6 V7 +1 +2 This line too! +3 D E F G Factor +4 FirstRow 1 <NA> <NA> <NA> Red +5 SecondRow 2 1 <NA> <NA> Green +6 ThirdRow 3 2 1 <NA> Red +7 FourthRow 4 3 2 1 Black X D E. F G Factor 1 FirstRow 1 NA NA NA Red 2 SecondRow 2 1 NA NA Green @@ -655,7 +687,7 @@ > > if( 'XLSX' %in% xlsFormats() ) + { -+ example.x.skip <- read.xls(exampleFile2007, sheet=2, blank.lines.skip=FALSE) ++ example.x.skip <- read.xls(exampleFileX, sheet=2, blank.lines.skip=FALSE) + example.x.skip + } X D E. F G Factor @@ -668,7 +700,7 @@ > > ## Check handing of fileEncoding for latin-1 characters > -> latin1File <- file.path(path.package('gdata'),'xls', 'latin-1.xls') +> latin1File <- file.path(path.package('gdata'),'xls', 'latin-1.xls' ) > latin1FileX <- file.path(path.package('gdata'),'xls', 'latin-1.xlsx') > > example.latin1 <- read.xls(latin1File, fileEncoding='latin1') @@ -679,7 +711,139 @@ + } > > +> ## Check handling of very wide file > +> wideFile <- file.path(path.package('gdata'),'xls', 'wide.xls' ) +> wideFileX <- file.path(path.package('gdata'),'xls', 'wide.xlsx') +> +> example.wide <- read.xls(wideFile) +> stopifnot(dim(example.wide)==c(0,256)) +> +> if( 'XLSX' %in% xlsFormats() ) ++ { ++ example.wide.x <- read.xls(wideFileX) ++ stopifnot(dim(example.wide.x)==c(0,16384)) ++ } +> +> ## Check handling of files with dates calulcated relative to +> ## 1900-01-01 and 1904-01-01 +> +> file.1900 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1900.xls' ) +> file.1904 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1904.xls' ) +> fileX.1900 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1900.xlsx') +> fileX.1904 <- file.path(path.package('gdata'),'xls', 'ExampleExcelFile_1904.xlsx') +> +> example.1900 <- read.xls(file.1900, sheet=3, header=FALSE) +> example.1900 + V1 V2 V3 V4 V5 V6 V7 +1 1 2001-01-01 01:01:00.00 0.2058182 NA A 2001-01-01 01:01:01.01 +2 2 2002-02-02 02:02:00.00 0.2910708 NA B 2002-02-02 02:02:02.02 +3 3 2003-03-03 03:03:00.00 0.3564875 -0.84147098 C 2003-03-03 03:03:03.03 +4 4 2004-04-04 04:04:00.00 0.4116363 0.70807342 2004-04-04 04:04:04.04 +5 5 2005-05-05 05:05:00.00 0.4602234 0.50136797 A 2005-05-05 05:05:05.05 +6 6 2006-06-06 06:06:00.00 NA 0.25136984 B 2006-06-06 06:06:06.06 +7 7 2007-07-07 07:07:00.00 0.5445436 0.06318679 B 2007-07-07 07:07:07.07 +8 8 2008-08-08 08:08:00.00 0.5821416 NA C 2008-08-08 08:08:08.08 +9 9 2009-09-09 09:09:00.00 0.6174545 0.00000000 A 2009-09-09 09:09:09.09 +10 10 2010-10-10 10:10:00.00 0.6508541 0.00000000 A 2010-10-10 10:10:10.10 + V8 +1 36892.04 +2 37289.08 +3 37683.13 +4 38081.17 +5 38477.21 +6 38874.25 +7 39270.30 +8 39668.34 +9 40065.38 +10 40461.42 +> +> example.1904 <- read.xls(file.1904, sheet=3, header=FALSE) +> example.1904 + V1 V2 V3 V4 V5 V6 V7 +1 1 2001-01-01 01:01:00.00 0.2058182 NA A 2001-01-01 01:01:01.01 +2 2 2002-02-02 02:02:00.00 0.2910708 NA B 2002-02-02 02:02:02.02 +3 3 2003-03-03 03:03:00.00 0.3564875 -0.84147098 C 2003-03-03 03:03:03.03 +4 4 2004-04-04 04:04:00.00 0.4116363 0.70807342 2004-04-04 04:04:04.04 +5 5 2005-05-05 05:05:00.00 0.4602234 0.50136797 A 2005-05-05 05:05:05.05 +6 6 2006-06-06 06:06:00.00 NA 0.25136984 B 2006-06-06 06:06:06.06 +7 7 2007-07-07 07:07:00.00 0.5445436 0.06318679 B 2007-07-07 07:07:07.07 +8 8 2008-08-08 08:08:00.00 0.5821416 NA C 2008-08-08 08:08:08.08 +9 9 2009-09-09 09:09:00.00 0.6174545 0.00000000 A 2009-09-09 09:09:09.09 +10 10 2010-10-10 10:10:00.00 0.6508541 0.00000000 A 2010-10-10 10:10:10.10 + V8 +1 35430.04 +2 35827.08 +3 36221.13 +4 36619.17 +5 37015.21 +6 37412.25 +7 37808.30 +8 38206.34 +9 38603.38 +10 38999.42 +> +> exampleX.1900 <- read.xls(file.1900, sheet=3, header=FALSE) +> exampleX.1900 + V1 V2 V3 V4 V5 V6 V7 +1 1 2001-01-01 01:01:00.00 0.2058182 NA A 2001-01-01 01:01:01.01 +2 2 2002-02-02 02:02:00.00 0.2910708 NA B 2002-02-02 02:02:02.02 +3 3 2003-03-03 03:03:00.00 0.3564875 -0.84147098 C 2003-03-03 03:03:03.03 +4 4 2004-04-04 04:04:00.00 0.4116363 0.70807342 2004-04-04 04:04:04.04 +5 5 2005-05-05 05:05:00.00 0.4602234 0.50136797 A 2005-05-05 05:05:05.05 +6 6 2006-06-06 06:06:00.00 NA 0.25136984 B 2006-06-06 06:06:06.06 +7 7 2007-07-07 07:07:00.00 0.5445436 0.06318679 B 2007-07-07 07:07:07.07 +8 8 2008-08-08 08:08:00.00 0.5821416 NA C 2008-08-08 08:08:08.08 +9 9 2009-09-09 09:09:00.00 0.6174545 0.00000000 A 2009-09-09 09:09:09.09 +10 10 2010-10-10 10:10:00.00 0.6508541 0.00000000 A 2010-10-10 10:10:10.10 + V8 +1 36892.04 +2 37289.08 +3 37683.13 +4 38081.17 +5 38477.21 +6 38874.25 +7 39270.30 +8 39668.34 +9 40065.38 +10 40461.42 +> +> exampleX.1904 <- read.xls(file.1904, sheet=3, header=FALSE) +> exampleX.1904 + V1 V2 V3 V4 V5 V6 V7 +1 1 2001-01-01 01:01:00.00 0.2058182 NA A 2001-01-01 01:01:01.01 +2 2 2002-02-02 02:02:00.00 0.2910708 NA B 2002-02-02 02:02:02.02 +3 3 2003-03-03 03:03:00.00 0.3564875 -0.84147098 C 2003-03-03 03:03:03.03 +4 4 2004-04-04 04:04:00.00 0.4116363 0.70807342 2004-04-04 04:04:04.04 +5 5 2005-05-05 05:05:00.00 0.4602234 0.50136797 A 2005-05-05 05:05:05.05 +6 6 2006-06-06 06:06:00.00 NA 0.25136984 B 2006-06-06 06:06:06.06 +7 7 2007-07-07 07:07:00.00 0.5445436 0.06318679 B 2007-07-07 07:07:07.07 +8 8 2008-08-08 08:08:00.00 0.5821416 NA C 2008-08-08 08:08:08.08 +9 9 2009-09-09 09:09:00.00 0.6174545 0.00000000 A 2009-09-09 09:09:09.09 +10 10 2010-10-10 10:10:00.00 0.6508541 0.00000000 A 2010-10-10 10:10:10.10 + V8 +1 35430.04 +2 35827.08 +3 36221.13 +4 36619.17 +5 37015.21 +6 37412.25 +7 37808.30 +8 38206.34 +9 38603.38 +10 38999.42 +> +> # all colmns should be identical +> stopifnot( na.omit(example.1900 == exampleX.1900) ) +> stopifnot( na.omit(example.1904 == exampleX.1904) ) +> +> # column 8 will differ by 1462 due to different date baselines (1900 vs 1904) +> stopifnot( na.omit(example.1900 [,-8] == example.1904 [,-8]) ) +> stopifnot( na.omit(exampleX.1900[,-8] == exampleX.1904[,-8]) ) +> +> stopifnot( na.omit(example.1900 [,8] - example.1904 [,8]) == 1462 ) +> stopifnot( na.omit(exampleX.1900[,8] - exampleX.1904[,8]) == 1462 ) +> > proc.time() user system elapsed - 10.072 1.468 12.094 + 12.406 0.727 13.299 Modified: trunk/gdata/tests/tests.write.fwf.Rout.save =================================================================== --- trunk/gdata/tests/tests.write.fwf.Rout.save 2014-08-28 05:22:50 UTC (rev 1882) +++ trunk/gdata/tests/tests.write.fwf.Rout.save 2014-08-28 15:01:51 UTC (rev 1883) @@ -1,7 +1,7 @@ -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 version 3.1.0 Patched (2014-05-26 r65771) -- "Spring Dance" +Copyright (C) 2014 The R Foundation for Statistical Computing +Platform: x86_64-apple-darwin13.1.0 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -231,4 +231,4 @@ > > proc.time() user system elapsed - 1.464 0.152 1.631 + 0.388 0.041 0.422 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |