tidyverse / magrittr

Improve the readability of R code with the pipe
https://magrittr.tidyverse.org
Other
961 stars 157 forks source link

pipe does not work with .Last.value #139

Closed behrica closed 7 years ago

behrica commented 7 years ago

In normal R I can use .Last.value to retrieve the last value of an expression.

1+1
->2
.Last.value
->2

Doing the same with the pipe

 1 %>% `+`(2)
->2
.Last.value

returns something very strange. It seem to return the result of a ls() call, so a list of all variables in the current enironment.

In a fresh console it returns:

.Last.value
[1] ".Random.seed" ".Last"       

My use case is the classical .Last.value use case. Sometimes I execute a long piped expression without assigning it, and after seeing the result I change mind, and would like to assign it.

smbache commented 7 years ago

Hmm, I cannot replicate - it works on my machine.

behrica commented 7 years ago

I checked again. It's a problem of running R in ESS of Emacs. Apparently ESS runs from time to time 'ls()' in the background to update the auto completions ...