Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] assigning using := prints during source( , echo=TRUE) (but not from console) #2369

Closed
jan-glx opened this issue Sep 18, 2017 · 1 comment · Fixed by #3544
Closed

[bug] assigning using := prints during source( , echo=TRUE) (but not from console) #2369

jan-glx opened this issue Sep 18, 2017 · 1 comment · Fixed by #3544
Milestone

Comments

@jan-glx
Copy link
Contributor

jan-glx commented Sep 18, 2017

> dt <- data.table(a=1)
> dt[,a:=1]
> source('~/.active-rstudio-document', echo=TRUE)

> dt <- data.table(a=1)

> dt[,a:=1]
   a
1: 1

Related to #2319.

sessionInfo():

R version 3.4.1 RC (2017-06-22 r72854)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.10.5

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1   
@MichaelChirico
Copy link
Member

Confirming this is not RStudio-specific; command line code:

echo "library(data.table)
DT = data.table(a = 1)
DT[ , a := 1]
" > test.R
R
source('test.R', echo = TRUE)
#    a
# 1: 1
DT[ , a := 1]

Also related to #933

@mattdowle mattdowle added this to the 1.12.4 milestone May 11, 2019
aitap added a commit that referenced this issue Dec 3, 2024
aitap added a commit that referenced this issue Dec 5, 2024
Avoid breaking it again like in #6589
MichaelChirico added a commit that referenced this issue Dec 5, 2024
…knit_print` (#6589)

* Respect shouldPrint when auto-printing from knitr

Implementing a method for the knitr::knit_print generic makes it
possible to customise the behaviour without looking up the call stack.

The current solution only works on R >= 3.6.0 because that's where
delayed S3 registration has been introduced.

* Delay S3method(knit_print, data.table) for R < 3.6

Use setHook() to ensure that registerS3method() will be called in the
same session if 'knitr' is loaded later. Not needed on R >= 3.6.0 where
S3method(knitr::knit_print) will do the right thing by itself.

* ws-only style

* put setHook() in a branch

* Position comment on the same line

* Restore the still-required #2369 condition

* Regression test for #2369

Avoid breaking it again like in #6589

* NEWS entry

* Comment the .onLoad condition

Co-authored-by: Michael Chirico <chiricom@google.com>

* restore unconditional setHook()

---------

Co-authored-by: Michael Chirico <chiricom@google.com>
MichaelChirico added a commit that referenced this issue Dec 9, 2024
…6631)

* Respect shouldPrint when auto-printing from knitr

Implementing a method for the knitr::knit_print generic makes it
possible to customise the behaviour without looking up the call stack.

The current solution only works on R >= 3.6.0 because that's where
delayed S3 registration has been introduced.

* Delay S3method(knit_print, data.table) for R < 3.6

Use setHook() to ensure that registerS3method() will be called in the
same session if 'knitr' is loaded later. Not needed on R >= 3.6.0 where
S3method(knitr::knit_print) will do the right thing by itself.

* ws-only style

* put setHook() in a branch

* Position comment on the same line

* Restore the still-required #2369 condition

* Use identical(,print) to check for autoprint

* Add tests, including updating broken test

* add comment

* test withAutoprint() behavior too

* NEWS entry

* blank line in correct place?

---------

Co-authored-by: Ivan K <krylov.r00t@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants