In R-devel (2015-08-12 r69024), capture.output() incorrectly duplicates the last line unless it ends with a newline. I don't see this in R 3.2.2 RC (2015-08-13 r69049). It seems to have started fairily recently; I spotted this yesterday after starting to get errors in my R.utils check that use capture.output(), cf. https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-clang/R.utils-00check.html
Examples: > x <- "a" > cat(x) a> > capture.output(cat(x)) [1] "a" "a" > x <- "a\n" > cat(x) a > capture.output(cat(x)) [1] "a" > x <- "a\nb" > cat(x) a b> > capture.output(cat(x)) [1] "a" "b" "b" > x <- "a\nb\n" > cat(x) a b > capture.output(cat(x)) [1] "a" "b" > capture.output(cat(x)) [1] "a" "b" > x <- c("a", "b") > cat(x) a b> > capture.output(cat(x)) [1] "a b" "a b" > x <- c("a", "b\n") > cat(x) a b > capture.output(cat(x)) [1] "a b" > sessionInfo() R Under development (unstable) (2015-08-12 r69024) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] R.utils_2.1.0-9000 R.oo_1.19.0-9000 R.methodsS3_1.7.0-9000 loaded via a namespace (and not attached): [1] tools_3.3.0 /Henrik ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel