Running ‘runRUnitTests.R’ [1s/1s]
  Running ‘test.humanReadable.R’ [1s/1s]
  Comparing ‘test.humanReadable.Rout’ to ‘test.humanReadable.Rout.save’ ... OK
  Running ‘test.read.xls.R’ [22s/26s]
  Comparing ‘test.read.xls.Rout’ to ‘test.read.xls.Rout.save’ ... OK
  Running ‘test.reorder.factor.R’ [1s/1s]
  Comparing ‘test.reorder.factor.Rout’ to ‘test.reorder.factor.Rout.save’ ... OK
  Running ‘test.write.fwf.eol.R’ [1s/1s]
  Running ‘tests.write.fwf.R’ [1s/1s]
Running the tests in ‘tests/runRUnitTests.R’ failed.
Complete output:
  > ### runRUnitTests.R
  > ###------------------------------------------------------------------------
  > ### What: Run RUnit tests (the core)- R code
  > ### $Id$
  > ### Time-stamp: <2008-12-30 12:52:51 ggorjan>
  > ###------------------------------------------------------------------------
  > 
  > ## The setup seems to be quite messy, but it is so to enable use of this in
  > ## several ways as shown bellow.
  > 
  > ## "R CMD check" way should be the most authoritative way to run the RUnit
  > ## tests for a developer. RUnit tests are issued during R CMD check of the
  > ## package due to example section of .runRUnitTests() function. If any test
  > ## fails (failure) or if there are any R errors during RUnit testing, R CMD
  > ## check fails. These are variable values specific for this way:
  > ##  - .path DEVEL/PATH/PKG.Rcheck/PKG/unitTests
  > ##  - .way  function
  > 
  > ## ".runRUnitTests()" way from within R after library(PKG) is handy for
  > ## package useRs, since it enables useRs to be sure that all tests pass for
  > ## their installation. This is just a convenient wrapper function to run
  > ## the RUnit testing suite. These are variable values specific for this
  > ## way:
  > ##  - .path INSTALL/PATH/PKG/unitTests
  > ##  - .way  function
  > 
  > ## "Shell" way is another possibility mainly for a developer in order to
  > ## skip possibly lengthy R CMD check and perform just RUnit testing with an
  > ## installed version of a pcakage. These are variable values specific for
  > ## this way:
  > ##  - .path DEVEL/PATH/PKG/inst/unitTests
  > ##  - .way  shell
  > ##
  > ## Rscript runRUnitTests.R
  > ## R CMD BATCH runRUnitTests.R
  > ## make
  > ## make all
  > 
  > PKG  <- 'gdata'
  > 
  > if(require("RUnit", quietly=TRUE))
  + {
  + 
  +     path <- normalizePath("unitTests")
  + 
  +     cat("\nRunning unit tests\n")
  +     print(list(pkg=PKG, getwd=getwd(), pathToUnitTests=path))
  + 
  +     library(package=PKG, character.only=TRUE)
  + 
  +     testFileRegexp <- "^runit.+\\.[rR]$"
  + 
  +     ## Debugging echo
  +     cat("\nRunning RUnit tests\n")
  +     print(list(pkg=PKG,
  +                getwd=getwd(),
  +                pathToRUnitTests=path))
  + 
  +     ## Define tests
  +     testSuite <- defineTestSuite(name=paste(PKG, "RUnit testing"),
  +                                  dirs=path,
  +                                  testFileRegexp=testFileRegexp
  +                                  )
  + 
  +     ## Run
  +     tests <- runTestSuite(testSuite)
  + 
  +     if(file.access(path, 02) != 0)
  +         {
  +             ## cannot write to path -> use writable one
  +             tdir <- tempfile(paste(PKG, "RUnitTests", sep="_"))
  +             dir.create(tdir)
  +             pathReport <- file.path(tdir, "report")
  +         }
  +     else
  +         {
  +             pathReport <- file.path(path, "report")
  +         }
  + 
  +     ## Print results:
  +     printTextProtocol(tests)
  +     printTextProtocol(tests,
  +                       fileName=paste(pathReport, ".txt", sep=""))
  + 
  +     ## Print HTML Version of results:
  +     printHTMLProtocol(tests,
  +                       fileName=paste(pathReport, ".html", sep=""))
  + 
  +     cat("\nRUnit reports also written to\n",
  +         pathReport, ".(txt|html)\n\n", sep="")
  + 
  +     ## Return stop() to cause R CMD check stop in case of
  +     ##  - failures i.e. FALSE to RUnit tests or
  +     ##  - errors i.e. R errors
  +     tmp <- getErrors(tests)
  +     if(tmp$nFail > 0 || tmp$nErr > 0)
  +         {
  +             stop(paste("\n\nRUnit testing failed:\n",
  +                        " - #test failures: ", tmp$nFail, "\n",
  +                        " - #R errors: ",  tmp$nErr, "\n\n", sep="")
  +                  )
  +         }
  + } else {
  + 
  +     cat("R package 'RUnit' cannot be loaded - no unit tests run\n",
  +         "for package", PKG,"\n")
  + 
  + }
  
  Running unit tests
  $pkg
  [1] "gdata"
  
  $getwd
  [1] "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests"
  
  $pathToUnitTests
  [1] "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests"
  
  gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
  
  gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
  
  Attaching package: 'gdata'
  
  The following object is masked from 'package:stats':
  
      nobs
  
  The following object is masked from 'package:utils':
  
      object.size
  
  The following object is masked from 'package:base':
  
      startsWith
  
  
  Running RUnit tests
  $pkg
  [1] "gdata"
  
  $getwd
  [1] "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests"
  
  $pathToRUnitTests
  [1] "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests"
  
  
  
  Executing test function test.bindData  ... Error in bindData(x = 1:10, y = 1:10) : 'x' must be a data frame
  Error in bindData(x = matrix(1:10), y = matrix(1:10)) : 
    'x' must be a data frame
   done successfully.
  
  
  
  Executing test function test.cbindX  ...  done successfully.
  
  
  
  Executing test function test.drop.levels  ...  done successfully.
  
  
  
  Executing test function test.getDay  ... Error in getDay.default(x = num) : 
    'getDay' can only be used on objects of a date/time class
  Error in getDay.default(x = cha) : 
    'getDay' can only be used on objects of a date/time class
  Error in getDay.default(x = fac) : 
    'getDay' can only be used on objects of a date/time class
   done successfully.
  
  
  
  Executing test function test.getHour  ... Error in getHour.default(x = num) : 
    'getHour' can only be used on objects of a date/time class
  Error in getHour.default(x = cha) : 
    'getHour' can only be used on objects of a date/time class
  Error in getHour.default(x = fac) : 
    'getHour' can only be used on objects of a date/time class
   done successfully.
  
  
  
  Executing test function test.getMin  ... Error in getMin.default(x = num) : 
    'getMin' can only be used on objects of a date/time class
  Error in getMin.default(x = cha) : 
    'getMin' can only be used on objects of a date/time class
  Error in getMin.default(x = fac) : 
    'getMin' can only be used on objects of a date/time class
   done successfully.
  
  
  
  Executing test function test.getMonth  ... Error in getMonth.default(x = num) : 
    'getMonth' can only be used on objects of a date/time class
  Error in getMonth.default(x = cha) : 
    'getMonth' can only be used on objects of a date/time class
  Error in getMonth.default(x = fac) : 
    'getMonth' can only be used on objects of a date/time class
   done successfully.
  
  
  
  Executing test function test.getSec  ... Error in getSec.default(x = num) : 
    'getSec' can only be used on objects of a date/time class
  Error in getSec.default(x = cha) : 
    'getSec' can only be used on objects of a date/time class
  Error in getSec.default(x = fac) : 
    'getSec' can only be used on objects of a date/time class
   done successfully.
  
  
  
  Executing test function test.getYear  ... Error in getYear.default(x = num) : 
    'getYear' can only be used on objects of a date/time class
  Error in getYear.default(x = cha) : 
    'getYear' can only be used on objects of a date/time class
  Error in getYear.default(x = fac) : 
    'getYear' can only be used on objects of a date/time class
   done successfully.
  
  
  
  Executing test function test.cLevelsMap  ... Error in c.listLevelsMap(x, sort = sort, recursive = TRUE) : 
    can not combine integer "levelsMaps"
   done successfully.
  
  
  
  Executing test function test.checkLevelsMap  ... Error in gdata:::.checkLevelsMap(x = "A", method = "raw") : 
    '"A"' must be  a named list
  Error in gdata:::.checkLevelsMap(x = list("A"), method = "raw") : 
    'list("A")' must be  a named list
  Error in gdata:::.checkLevelsMap(x = fMapInt, method = "class") : 
    'fMapInt' must be a "levelsMap"
  Error in gdata:::.checkListLevelsMap(x = map, method = "class") : 
    'map' must be a "listLevelsMap"
  Error in gdata:::.checkListLevelsMap(x = map1, method = "class") : 
    'map1' must be also a list of "levelsMap"
   done successfully.
  
  
  
  Executing test function test.mapLevels  ... Error in mapLevels.default(1:3) : 
    mapLevels can only be used on "factor" and "character" atomic 'x'
  Error in mapLevels.default(1.5) : 
    mapLevels can only be used on "factor" and "character" atomic 'x'
  Error in mapLevels.list(l, combine = TRUE) : 
    can not combine integer "levelsMaps"
  Error in mapLevels.default(X[[i]], ...) : 
    mapLevels can only be used on "factor" and "character" atomic 'x'
  Error in mapLevels.default(X[[i]], ...) : 
    mapLevels can only be used on "factor" and "character" atomic 'x'
   done successfully.
  
  
  
  Executing test function test.mapLevels<-  ... Error in `mapLevels<-.default`(1.1, value = 2) : 
    'x' must be either: "integer", "character", "factor"
  Error in `mapLevels<-.default`(complex(1.1), value = 2) : 
    'x' must be either: "integer", "character", "factor"
  Error in `mapLevels<-.default`(as.character(f), value = fMapInt) : 
    can not apply integer "levelsMap" to "character"
  Error in is.levelsMap(x) : object 'chaMapCha' not found
  Error in `mapLevels<-.default`(as.character(f), value = fMapFuzz) : 
    all components of 'value' must be of the same class
  Error in `mapLevels<-.default`(as.integer(f), value = fMapFuzz) : 
    all components of 'value' must be of the same class
   done successfully.
  
  
  
  Executing test function test.uniqueLevelsMap  ...  done successfully.
  
  
  
  Executing test function test.nPairs  ... Error in nPairs(x = x) : 'x' must be a data.frame or a matrix
  Error in nPairs(x = table(x)) : 'x' must be a data.frame or a matrix
   done successfully.
  
  
  
  Executing test function test.reorder.factor  ...  done successfully.
  
  
  
  Executing test function test.trim  ...  done successfully.
  
  
  
  Executing test function test.trimSum  ... Error in trimSum(matrix(1:10)) : 'x' must be a vector - for now
  Error in trimSum(data.frame(1:10)) : 'x' must be a vector - for now
  Error in trimSum(list(1:10)) : 'x' must be a vector - for now
  Error in trimSum(letters) : 'x' must be numeric
  Error in trimSum(x = 1:10, n = 11) : 
    'n' must be smaller than the length of x
  Error in trimSum(x = 1, n = 1) : 'n' must be smaller than the length of x
   done successfully.
  
  
  
  Executing test function test.NAToUnknown  ... Error in NAToUnknown.default(xInt, unknown = unkC) : 
    'unknown' must be a single value
  In addition: Warning message:
  new level is introduced: notAvail 
  Error in NAToUnknown.default(xInt, unknown = unkL) : 
    'unknown' must be a single value
  Error in NAToUnknown.default(xCha, unknown = chaUnk1) : 
    'x' already has value "-"
  Error in NAToUnknown.factor(xFac, unknown = facLev) : 
    'x' already has level "A"
  Error in NAToUnknown.default(x = dots[[1L]][[3L]], unknown = dots[[2L]][[3L]],  : 
    'unknown' must be a single value
  In addition: There were 11 warnings (use warnings() to see them)
  Error in NAToUnknown.default(x = dots[[1L]][[3L]], unknown = dots[[2L]][[3L]],  : 
    'unknown' must be a single value
  Error in .unknownList(x = x, unknown = unknown) : 
    can not propely recycle named 'unknown'
  In addition: There were 16 warnings (use warnings() to see them)
  Error in .unknownList(x = x, unknown = unknown) : 
    can not propely recycle named 'unknown'
  In addition: Warning messages:
  1: 'unknown' should be "integer" for "integer" 'x' - will try to coerce 
  2: 'unknown' should be "numeric" for "numeric" 'x' - will try to coerce 
  3: new level is introduced: notAvail 
  Error in .unknownList(x = x, unknown = unknown) : 
    can not propely recycle named 'unknown'
  In addition: Warning messages:
  1: 'unknown' should be "integer" for "integer" 'x' - will try to coerce 
  2: 'unknown' should be "numeric" for "numeric" 'x' - will try to coerce 
  3: new level is introduced: notAvail 
  Error in .unknownList(x = x, unknown = unknown) : 
    name(s) '' not in names of 'x'
  In addition: There were 16 warnings (use warnings() to see them)
   done successfully.
  
  
  
  Executing test function test.isUnknown  ... Error in .unknownList(x = x, unknown = unknown) : 
    name(s) '' not in names of 'x'
  In addition: Warning message:
  'unknown' should be "matrix" for "matrix" 'x' - will try to coerce 
   done successfully.
  
  
  
  Executing test function test.unknownToNA  ... Error in .unknownList(x = x, unknown = unknown) : 
    can not propely recycle named 'unknown'
  Error in .unknownList(x = x, unknown = unknown) : 
    can not propely recycle named 'unknown'
  Error in .unknownList(x = x, unknown = unknown) : 
    can not propely recycle named 'unknown'
  Error in .unknownList(x = x, unknown = unknown) : 
    name(s) '' not in names of 'x'
   done successfully.
  
  
  
  Executing test function test.wideByFactor  ... Error in wideByFactor(x = 1:10) : 'x' must be a data frame
  Error in wideByFactor(x = matrix(1:10)) : 'x' must be a data frame
  Error in wideByFactor(x = tmp, factor = c("f1", "f2")) : 
    'factor' can be only of length one
  Error in wideByFactor(x = tmp, factor = "c1") : 
    column defined in 'factor' must be a factor
   done successfully.
  
  
  
  Executing test function test.write.fwf  ... Error in write.fwf(1:10) : 'x' must be a data.frame or matrix
  Error in write.fwf(list(1:10)) : 'x' must be a data.frame or matrix
  Error in write.fwf(data.frame(1:10, letters[1:10]), na = c("", " ")) : 
    only single value can be defined for 'na'
  num1 num2
   1    
   2 1.0
   3 1.5
   4 2.0
   5 2.5
   6 3.0
   7 3.5
   8 4.0
   9 4.5
  10 5.0
     5.5
  num1 num2
   1    
   2 1.0
   3 1.5
   4 2.0
   5 2.5
   6 3.0
   7 3.5
   8 4.0
   9 4.5
  10 5.0
     5.5
  Timing stopped at: 0.023 0 0.023
  Error in `[<-.data.frame`(`*tmp*`, test, i, value = "   ") : 
    replacement has 1 row, data has 0
   done successfully.
  
  RUNIT TEST PROTOCOL -- Sun Oct 21 21:06:05 2018 
  *********************************************** 
  Number of test functions: 23 
  Number of errors: 1 
  Number of failures: 0 
  
   
  1 Test Suite : 
  gdata RUnit testing - 23 test functions, 1 error, 0 failures
  ERROR in test.write.fwf: Error in `[<-.data.frame`(`*tmp*`, test, i, value = "   ") : 
    replacement has 1 row, data has 0
  
  
  
  Details 
  *************************** 
  Test Suite: gdata RUnit testing 
  Test function regexp: ^test.+ 
  Test file regexp: ^runit.+\.[rR]$ 
  Involved directory: 
  /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests 
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.bindData.R 
  test.bindData: (11 checks) ... OK (0.07 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.cbindX.R 
  test.cbindX: (5 checks) ... OK (0.02 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.drop.levels.R 
  test.drop.levels: (3 checks) ... OK (0.01 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.getDateTimeParts.R 
  test.getDay: (6 checks) ... OK (0 seconds)
  test.getHour: (3 checks) ... OK (0 seconds)
  test.getMin: (3 checks) ... OK (0 seconds)
  test.getMonth: (6 checks) ... OK (0 seconds)
  test.getSec: (3 checks) ... OK (0 seconds)
  test.getYear: (6 checks) ... OK (0 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.mapLevels.R 
  test.cLevelsMap: (8 checks) ... OK (0.01 seconds)
  test.checkLevelsMap: (5 checks) ... OK (0 seconds)
  test.mapLevels: (26 checks) ... OK (0.01 seconds)
  test.mapLevels<-: (19 checks) ... OK (0.01 seconds)
  test.uniqueLevelsMap: (1 checks) ... OK (0 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.nPairs.R 
  test.nPairs: (8 checks) ... OK (0.01 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.reorder.factor.R 
  test.reorder.factor: (5 checks) ... OK (0.01 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.trim.R 
  test.trim: (5 checks) ... OK (0 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.trimSum.R 
  test.trimSum: (10 checks) ... OK (0 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.unknown.R 
  test.NAToUnknown: (44 checks) ... OK (0.07 seconds)
  test.isUnknown: (38 checks) ... OK (0.01 seconds)
  test.unknownToNA: (40 checks) ... OK (0.01 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.wideByFactor.R 
  test.wideByFactor: (10 checks) ... OK (0.02 seconds)
  --------------------------- 
  Test file: /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/runit.write.fwf.R 
  test.write.fwf: ERROR !! 
  Error in `[<-.data.frame`(`*tmp*`, test, i, value = "   ") : 
    replacement has 1 row, data has 0
  
  RUnit reports also written to
  /home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/gdata.Rcheck/tests/unitTests/report.(txt|html)
  
  Error: 
  
  RUnit testing failed:
   - #test failures: 0
   - #R errors: 1
  
  Execution halted
Running the tests in ‘tests/test.write.fwf.eol.R’ failed.
Complete output:
  > library(gdata)
  gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
  
  gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
  
  Attaching package: 'gdata'
  
  The following object is masked from 'package:stats':
  
      nobs
  
  The following object is masked from 'package:utils':
  
      object.size
  
  The following object is masked from 'package:base':
  
      startsWith
  
  > saveto <- tempfile(pattern = "test.txt", tmpdir = tempdir())
  > 
  > write.fwf(x = data.frame(a=1:length(LETTERS), b=LETTERS),
  +           file=saveto, eol="\r\n")
  Error in `[<-.data.frame`(`*tmp*`, test, i, value = "  ") : 
    replacement has 1 row, data has 0
  Calls: write.fwf -> [<- -> [<-.data.frame
  Execution halted
Running the tests in ‘tests/tests.write.fwf.R’ failed.
Complete output:
  > ### tests.write.fwf.R
  > ###------------------------------------------------------------------------
  > ### What: Tests for write.fwf
  > ### $Id: tests.write.fwf.R 1300 2008-08-05 11:47:18Z ggorjan $
  > ### Time-stamp: <2008-08-05 12:25:05 ggorjan>
  > ###------------------------------------------------------------------------
  > 
  > library(gdata)
  gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
  
  gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
  
  Attaching package: 'gdata'
  
  The following object is masked from 'package:stats':
  
      nobs
  
  The following object is masked from 'package:utils':
  
      object.size
  
  The following object is masked from 'package:base':
  
      startsWith
  
  > 
  > ## --- Test data ---
  > 
  > num <- round(c(733070.345678, 1214213.78765456, 553823.798765678,
  +                1085022.8876545678,  571063.88765456, 606718.3876545678,
  +                1053686.6, 971024.187656, 631193.398765456, 879431.1),
  +              digits=3)
  > 
  > testData <- data.frame(num1=c(1:10, NA),
  +                        num2=c(NA, seq(from=1, to=5.5, by=0.5)),
  +                        num3=c(NA, num),
  +                        int1=c(as.integer(1:4), NA, as.integer(4:9)),
  +                        fac1=factor(c(NA, letters[1:9], "hjh")),
  +                        fac2=factor(c(letters[6:15], NA)),
  +                        cha1=c(letters[17:26], NA),
  +                        cha2=c(NA, "longer", letters[25:17]),
  +                        stringsAsFactors=FALSE)
  > levels(testData$fac1) <- c(levels(testData$fac1), "unusedLevel")
  > testData$Date <- as.Date("1900-1-1")
  > testData$Date[2] <- NA
  > testData$POSIXt <- as.POSIXct(strptime("1900-1-1 01:01:01", format="%Y-%m-%d %H:%M:%S"))
  > testData$POSIXt[5] <- NA
  > 
  > ## --- Tests ---
  > 
  > ## Default
  > write.fwf(testData)
  num1 num2 num3 int1 fac1 fac2 cha1 cha2 Date POSIXt
   1               1     f q        1900-01-01 1900-01-01 01:01:01
   2 1.0  733070.3 2 a   g r longer            1900-01-01 01:01:01
   3 1.5 1214213.8 3 b   h s y      1900-01-01 1900-01-01 01:01:01
   4 2.0  553823.8 4 c   i t x      1900-01-01 1900-01-01 01:01:01
   5 2.5 1085022.9   d   j u w      1900-01-01                    
   6 3.0  571063.9 4 e   k v v      1900-01-01 1900-01-01 01:01:01
   7 3.5  606718.4 5 f   l w u      1900-01-01 1900-01-01 01:01:01
   8 4.0 1053686.6 6 g   m x t      1900-01-01 1900-01-01 01:01:01
   9 4.5  971024.2 7 h   n y s      1900-01-01 1900-01-01 01:01:01
  10 5.0  631193.4 8 i   o z r      1900-01-01 1900-01-01 01:01:01
     5.5  879431.1 9 hjh     q      1900-01-01 1900-01-01 01:01:01
  > 
  > ## NA should be -
  > write.fwf(x=testData, na="-")
  num1 num2 num3 int1 fac1 fac2 cha1 cha2 Date POSIXt
   1   -         - 1 -   f q -      1900-01-01 1900-01-01 01:01:01
   2 1.0  733070.3 2 a   g r longer -          1900-01-01 01:01:01
   3 1.5 1214213.8 3 b   h s y      1900-01-01 1900-01-01 01:01:01
   4 2.0  553823.8 4 c   i t x      1900-01-01 1900-01-01 01:01:01
   5 2.5 1085022.9 - d   j u w      1900-01-01 -                  
   6 3.0  571063.9 4 e   k v v      1900-01-01 1900-01-01 01:01:01
   7 3.5  606718.4 5 f   l w u      1900-01-01 1900-01-01 01:01:01
   8 4.0 1053686.6 6 g   m x t      1900-01-01 1900-01-01 01:01:01
   9 4.5  971024.2 7 h   n y s      1900-01-01 1900-01-01 01:01:01
  10 5.0  631193.4 8 i   o z r      1900-01-01 1900-01-01 01:01:01
   - 5.5  879431.1 9 hjh - - q      1900-01-01 1900-01-01 01:01:01
  > ## NA should be -NA-
  > write.fwf(x=testData, na="-NA-")
  num1 num2 num3 int1 fac1 fac2 cha1 cha2 Date POSIXt
     1 -NA-      -NA-    1 -NA- f    q    -NA-   1900-01-01 1900-01-01 01:01:01
     2  1.0  733070.3    2 a    g    r    longer -NA-       1900-01-01 01:01:01
     3  1.5 1214213.8    3 b    h    s    y      1900-01-01 1900-01-01 01:01:01
     4  2.0  553823.8    4 c    i    t    x      1900-01-01 1900-01-01 01:01:01
     5  2.5 1085022.9 -NA- d    j    u    w      1900-01-01 -NA-               
     6  3.0  571063.9    4 e    k    v    v      1900-01-01 1900-01-01 01:01:01
     7  3.5  606718.4    5 f    l    w    u      1900-01-01 1900-01-01 01:01:01
     8  4.0 1053686.6    6 g    m    x    t      1900-01-01 1900-01-01 01:01:01
     9  4.5  971024.2    7 h    n    y    s      1900-01-01 1900-01-01 01:01:01
    10  5.0  631193.4    8 i    o    z    r      1900-01-01 1900-01-01 01:01:01
  -NA-  5.5  879431.1    9 hjh  -NA- -NA- q      1900-01-01 1900-01-01 01:01:01
  > 
  > ## Some other separator than space
  > write.fwf(testData[, 1:4], sep="-mySep-")
  num1-mySep-num2-mySep-num3-mySep-int1
   1-mySep-   -mySep-         -mySep-1
   2-mySep-1.0-mySep- 733070.3-mySep-2
   3-mySep-1.5-mySep-1214213.8-mySep-3
   4-mySep-2.0-mySep- 553823.8-mySep-4
   5-mySep-2.5-mySep-1085022.9-mySep- 
   6-mySep-3.0-mySep- 571063.9-mySep-4
   7-mySep-3.5-mySep- 606718.4-mySep-5
   8-mySep-4.0-mySep-1053686.6-mySep-6
   9-mySep-4.5-mySep- 971024.2-mySep-7
  10-mySep-5.0-mySep- 631193.4-mySep-8
    -mySep-5.5-mySep- 879431.1-mySep-9
  > 
  > ## Justify right for character columns
  > write.fwf(testData, justify="right")
  num1 num2 num3 int1 fac1 fac2 cha1 cha2 Date POSIXt
   1               1     f q        1900-01-01 1900-01-01 01:01:01
   2 1.0  733070.3 2   a g r longer            1900-01-01 01:01:01
   3 1.5 1214213.8 3   b h s      y 1900-01-01 1900-01-01 01:01:01
   4 2.0  553823.8 4   c i t      x 1900-01-01 1900-01-01 01:01:01
   5 2.5 1085022.9     d j u      w 1900-01-01                    
   6 3.0  571063.9 4   e k v      v 1900-01-01 1900-01-01 01:01:01
   7 3.5  606718.4 5   f l w      u 1900-01-01 1900-01-01 01:01:01
   8 4.0 1053686.6 6   g m x      t 1900-01-01 1900-01-01 01:01:01
   9 4.5  971024.2 7   h n y      s 1900-01-01 1900-01-01 01:01:01
  10 5.0  631193.4 8   i o z      r 1900-01-01 1900-01-01 01:01:01
     5.5  879431.1 9 hjh          q 1900-01-01 1900-01-01 01:01:01
  > 
  > ## Justify right for character columns, track na values
  > write.fwf(testData, justify="right", na="!")
  num1 num2 num3 int1 fac1 fac2 cha1 cha2 Date POSIXt
   1   !         ! 1   ! f q      ! 1900-01-01 1900-01-01 01:01:01
   2 1.0  733070.3 2   a g r longer          ! 1900-01-01 01:01:01
   3 1.5 1214213.8 3   b h s      y 1900-01-01 1900-01-01 01:01:01
   4 2.0  553823.8 4   c i t      x 1900-01-01 1900-01-01 01:01:01
   5 2.5 1085022.9 !   d j u      w 1900-01-01                   !
   6 3.0  571063.9 4   e k v      v 1900-01-01 1900-01-01 01:01:01
   7 3.5  606718.4 5   f l w      u 1900-01-01 1900-01-01 01:01:01
   8 4.0 1053686.6 6   g m x      t 1900-01-01 1900-01-01 01:01:01
   9 4.5  971024.2 7   h n y      s 1900-01-01 1900-01-01 01:01:01
  10 5.0  631193.4 8   i o z      r 1900-01-01 1900-01-01 01:01:01
   ! 5.5  879431.1 9 hjh ! !      q 1900-01-01 1900-01-01 01:01:01
  > 
  > ## With quotes
  > write.fwf(testData, quote=TRUE)
  "num1" "num2" "num3" "int1" "fac1" "fac2" "cha1" "cha2" "Date" "POSIXt"
  " 1" "   " "         " "1" "   " "f" "q" "      " "1900-01-01" "1900-01-01 01:01:01"
  " 2" "1.0" " 733070.3" "2" "a  " "g" "r" "longer" "          " "1900-01-01 01:01:01"
  " 3" "1.5" "1214213.8" "3" "b  " "h" "s" "y     " "1900-01-01" "1900-01-01 01:01:01"
  " 4" "2.0" " 553823.8" "4" "c  " "i" "t" "x     " "1900-01-01" "1900-01-01 01:01:01"
  " 5" "2.5" "1085022.9" " " "d  " "j" "u" "w     " "1900-01-01" "                   "
  " 6" "3.0" " 571063.9" "4" "e  " "k" "v" "v     " "1900-01-01" "1900-01-01 01:01:01"
  " 7" "3.5" " 606718.4" "5" "f  " "l" "w" "u     " "1900-01-01" "1900-01-01 01:01:01"
  " 8" "4.0" "1053686.6" "6" "g  " "m" "x" "t     " "1900-01-01" "1900-01-01 01:01:01"
  " 9" "4.5" " 971024.2" "7" "h  " "n" "y" "s     " "1900-01-01" "1900-01-01 01:01:01"
  "10" "5.0" " 631193.4" "8" "i  " "o" "z" "r     " "1900-01-01" "1900-01-01 01:01:01"
  "  " "5.5" " 879431.1" "9" "hjh" " " " " "q     " "1900-01-01" "1900-01-01 01:01:01"
  > 
  > ## With rownames
  > write.fwf(testData, rownames=TRUE)
  Error in `[<-.data.frame`(`*tmp*`, test, i, value = "  ") : 
    replacement has 1 row, data has 0
  Calls: write.fwf -> [<- -> [<-.data.frame
  Execution halted