Open MichaelChirico opened 4 years ago
These observations are correct, but I don't see a bug here.
With default source(file, echo = FALSE), output of str() is still displayed because str() writes directly to the console.
With source(file, echo = TRUE), parsed expressions are printed with truncation at 'max.deparse.length' (default 150) characters and this is documented in help(source). If keep.source=TRUE (as per default in interactive sessions), each chunk consists of comment lines and one expression, and truncation works on the whole chunk. The default value of 150 characters hasn't changed since its introduction in r22, and essentially ∼2*80) allows for one comment line and a single-line expression. Truncation can be disabled by setting max.deparse.length=Inf.
A simple reproducible example follows:
file <- tempfile() cat("## comments are merged with the next parsed expression", "head(iris, 1)", "## shorter", "head(iris, 1)", sep = "\n", file = file)
source(file, echo = TRUE, max.deparse.length = 30)
## To avoid truncation, simply increase max.deparse.length source(file, echo = TRUE, max.deparse.length = Inf)
Created attachment 1754 [details] This is a script file, used as argument for source() function.
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 1.3
year 2015
month 03
day 09
svn rev 67962
language R
version.string R version 3.1.3 (2015-03-09) nickname Smooth Sidewalk
Windows 7 Home Premium Intel Core i3 CPU 64-bit OS
when sourcing the script "bugreport.R" attached with this report, without echo=T, the output of the function str() is displayed on console (command on line 17 ). The output of other commands are not displayed.
when sourcing attached script "bugreport.R", with echo=T, The four comment lines at the top are truncated, and the command following this comment is not echoed, although the command is executed. Similarly comments on lines 12 to 15 are truncated, and the following command on line 16 is not echoed, but the output of the command is displayed. Same effect repeated later in the script. The truncation of comment lines seem to suppress echo of following command. If comment line(s) are not truncated, the following command is echoed, as expected.
METADATA