This is just a RStudio interface question:
When scrolling back through the console to see my work and outputs I can only scroll back so far. Is there a way to open up the console and scroll back through everything I have done?
Sometimes I want to check results of a very long list, or I forget to write code in the script box instead of the console and want to scroll back to review it.
Cheers,
In addition to the excellent comments of others, if you have a data.frame called df with 2000 rows and 2 columns, to view all of them, type on the console:
utils::View(df) # opens a new separate window to view all the records.
In order to view just 500:1000 records of the data.frame just do:
utils::View(df[500:1000,])
To build on jbaums's comment, I personally got really tired of typing .Last.value
whenever I wanted to grab a temporary variable (especially when in Matlab its just ans
and in Python its _
.)
So as a workaround you can bind ans
to Last.value
to save yourself some time typing: makeActiveBinding("ans", function(){.Last.value}, .GlobalEnv)
.
As a super-lame example of how this could be super-helpful at times:
> runif(5) # Oh no! I forgot to assign my function output to a variable!
[1] 0.1905214 0.2175722 0.1140303 0.2645469 0.8298856
> ans # Oh wait, we're good :)
[1] 0.1905214 0.2175722 0.1140303 0.2645469 0.8298856
To make it a bit more permanent, save that in a file named .Rprofile
. If you use Rstudio projects a lot, you can save it to the project working directory and it will load every time you boot up Rstudio. Otherwise you can put that line of code in the Rprofile.site
file in your R directory (mine's located in \Program Files\R\R-3.2.0\etc
) and R should load it by default, though I'm not 100% sure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With