![]() So, in a fit of pique following one to many reconfiguration sessions of Emacs+ESS, I went in search of some greener grass. Also, fiddling with this stuff just wasn’t fun any more. Configuring Emacs+ESS was becoming much more of a chore, and rather unhelpfully, my problems coincided with my having less and less time to devote to tinkering with my computer setups. Rmd was hit and miss, and polymode was just a mystery to me. More recently, however, my go-to methods for configuring Emacs+ESS were failing indentation was all over the shop, the smart _ stopped working or didn’t work as it had for over a decade, syntax highlighting of R-related files, like. For years this has served me well, though I wouldn’t call myself an Emacs expert not even close! With a bit of help from some R Core coding standards document I got indentation working how I like it, I learned to contort my fingers in weird and wonderful ways to execute a small set of useful shortcuts, and I even committed some of those shortcuts to memory. I’ve done so for nigh on a couple of decades now, ever since I switched full time to running Linux as my daily OS. ![]() ![]() In RStudio, typing Alt + - (push Alt, the key next to your space bar at the same time as the - key) will write <- in a single keystroke.Whenever I’m developing R code or writing data wrangling or analysis scripts for research projects that I work on I use Emacs and its add-on package Emacs Speaks Statistics ( ESS). = should only be used to specify the values of arguments in functions, see below. You can also use = for assignments but not in all contexts so it is good practice to use <- for assignments. So, after executing x <- 3, the value of x is 3. It assigns values on the right to objects on the left. Anything to the right of a # is ignored by R. If you’re in RStudio and this happens, click inside the console window and press Esc this should help you out of trouble. This is because you have not ‘closed’ a parenthesis or quotation. It means that you haven’t finished entering a complete command. If R is still waiting for you to enter more data because it isn’t complete yet, the console will show a + prompt. If it receives a command (by typing, copy-pasting or sent from the script editor using Ctrl-Enter), R will try to execute it, and when ready, show the results and come back with a new >-prompt to wait for new commands. If R is ready to accept commands, the R console shows a > prompt. RStudio provides the Ctrl-1 and Ctrl-2 shortcuts allow you to jump between the script and the console windows. You can type these commands directly in the console. You can copy-paste into the R console, but the Rstudio script editor allows you to ‘send’ the current line or the currently selected text to the R console using the Ctrl-Enter shortcut.Īt some point in your analysis you may want to check the content of variable or the structure of an object, without necessarily keep a record of it in your script. ![]() This way, you have a complete record of what you did, you can easily show others how you did it and you can do it again later on if needed. It is better to enter the commands in the script editor, and save the script. You can type commands directly into the console, but they will be forgotten when you close the session. The console window (in RStudio, the bottom left panel) is the place where R is waiting for you to tell it what to do, and where it will show the results of a command. There are two main ways of interacting with R: using the console or by using script files (plain text files that contain your code). RStudio provides an environment that allows you to do that
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |