Executing R interactively through the R console

Once you have opened your favourite IDE (we are going to use RStudio), you should find an interactive console, which you should be able to recognize by the intermittent cursor you should find on it. Once you have located it, just try to perform a basic operation by typing the following words and pressing Enter, submitting the command to the console:

2+2

A new line will automatically appear, showing you the following unsurprising result:

4

Yes, just to reassure you, we are going to discuss more sophisticated mathematical computations; this was just an introductory example.

What I would like to stress with this is that within the console, you can interactively test small chunks of code. What is the disadvantage here? When you terminate your R session (shutting down your IDE), everything that you performed within the console will be lost. There are actually IDEs, such as RStudio, that store your console history, but that is intended as an audit trail rather than as a proper way to store your code:

In the next paragraph, we are going to see the proper way to store your console history. In the meantime, for the sake of completeness, let me clarify for you that the R language can perform all the basic mathematical operations, employing the following operators: +, -, *, /, ^, the last of which is employed when raising to a power.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset