We now know how to use a function using the parenthesis sign
(), but we are also interested in the output of a function.
In RStudio we use the assignment operator ← for creating or updating existing objects. If we wanted to save the results of
sum(1,2,3), we would have to use the assignment operator
the line above created a new object called (mysum) in our environment and saves the result of the
sum(1, 2, 3)
Assignment operator shortcut
Windows: “Alt” + “-”
Mac: “Option” + “-”
If you look at the Environment pane in RStudio you will see mysum
If you want to delete objects from the environment, you can use the broom button.
You may give to your objects any name you like but let’s admit it, some names are just bad names… You may find below some examples of good names and bad names
Avoid using names such as:
|Good names||Bad names|
|model1||data, function (i.e. same name as commands )|