To identify your current working directory:
This is relevant when you are reading or writing out data or programs. It becomes more important as you move from doing simple interactive sequences of commands to codifying your work in R functions, objects and packages. To change this directory, you can specify a different relative or absolute path:
R functions are the simplest building blocks that you are likely to use in development. They provide a mechanism for encapsulating a reusable sequence of commands. A simple example of how to create a function within an R session:
As you continue to work with a function, you will likely use an external editor. You can specify the editor that will be invoked.
The editor is then invoked whenever you want to modify code using the edit command.
Rather than starting with an interactive session, you can also start with a specific text file containing R source code. This approach more closely mirrors development in other programming languages. The file can be opened and executed as follows:
To run the function, simply call it with any relevant parameters - but make sure to include the parenthesis:
If you call a function without the parenthesis, a listing of the contents of the function will be displayed. This feature is useful when analyzing how functions provided in other R packages have been implemented.