From ripley at stats.ox.ac.uk  Fri Aug 14 11:24:16 2015
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 14 Aug 2015 10:24:16 +0100
Subject: [Rd] capture.output() duplicates last line unless newline
 (R-devel bug)
In-Reply-To: <CAFDcVCRzEdS2Bs7bUuoMw1ZVq4qRTukaw4Y1KVgtFmeDAF7=Ow@mail.gmail.com>
References: <CAFDcVCRzEdS2Bs7bUuoMw1ZVq4qRTukaw4Y1KVgtFmeDAF7=Ow@mail.gmail.com>
Message-ID: <55CDB3C0.7040201@stats.ox.ac.uk>

But it was changed over 24h ago in R-devel, 2 commits later ....

See e.g. https://cran.r-project.org/bin/windows/base/rdevel.html for 
when not to report on 'R (Under Development)' (and you really should 
have known that, as a Windows user).

On 14/08/2015 10:09, Henrik Bengtsson 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


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK



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