

- #WHEN OPEN RSTUDIO HOW TO CLEAR ENVIRONMENT IN R WINDOWS 10#
- #WHEN OPEN RSTUDIO HOW TO CLEAR ENVIRONMENT IN R CODE#
- #WHEN OPEN RSTUDIO HOW TO CLEAR ENVIRONMENT IN R SERIES#
stats graphics grDevices utils datasets methods base LC_NUMERIC=C LC_TIME=English_United States.1252 LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252

#WHEN OPEN RSTUDIO HOW TO CLEAR ENVIRONMENT IN R WINDOWS 10#
Running under: Windows 10 圆4 (build 18362)
#WHEN OPEN RSTUDIO HOW TO CLEAR ENVIRONMENT IN R CODE#
Notice how the assignment of M does not stand out as well in the second example given the recurrence of = on the same line of code (unless, of course, if you benefit from colored syntax). The alternative would be: M = lm(y ~ x, data = dat, weights = wt) The <- operator makes it easier to spot assignments during a quick visual scan of an R script, more so than the = operator which is also used in functions when assigning variables to function parameters as in: M <- lm(y ~ x, data = dat, weights = wt) An advantage in using <- instead of = is in readability. However, this option is not widely adopted in the R community. Note that, in most cases, you can also use the = to assign values as in: x = c(1,2,3,4) Given that the assignment operator will be used frequently in an R script, it may be worthwhile to learn its shortcut: Alt+ - on Windows and Option + - on a Mac. The assignment operator is constructed by combining the less then character, <, with the dash character,. In the preceding example, the values 1,2,3,4 were being assigned to x.

When assigning values or output from operations to a variable, the assignment operator, <-, is placed between the variable name and the value(s) being assigned to that variable. The lines are run one at a time using the Ctrl+Enter keys and the output is displayed in the console window. In the following example, the R script file has three lines of code: two assignment operations and one regression analysis. Or, you can run the entire R script by pressing Ctrl+Alt+R in Windows or Command+Option+R on a Mac. You can also run an entire block of code by selecting all lines to be run then pressing the shortcut keys Ctrl+Enter/ Command+Enter. In RStudio, you can run a line of code of a R script file by placing a cursor anywhere on that line (while being careful not to highlight any subset of that line) and pressing the shortcut keys Ctrl+Enter on a Windows keyboard or Command+Enter on a Mac.
#WHEN OPEN RSTUDIO HOW TO CLEAR ENVIRONMENT IN R SERIES#
If you intend on typing more than a few lines of code in a command prompt environment, or if you wish to save a series of commands as part of a project’s analysis, it is probably best that you write and store the commands in an R script file.
