[Rd] capture.output() duplicates last line unless newline (R-devel bug)

peter dalgaard pdalgd at gmail.com
Fri Aug 14 11:30:50 CEST 2015


The fix for PR#16481 had a side effect involving capture.output(), so this may be transient, please recheck whether the issue has disappeared in the meantime.

-pd

On 14 Aug 2015, at 11:09 , Henrik Bengtsson <henrik.bengtsson at ucsf.edu> wrote:

> 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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-devel mailing list