Let us now set up a new project that we will use throughout the book. We will create an R project, script, custom function, and save an image of the global environment. Follow the steps given below:
- Open RStudio.
- Navigate to File | New Project to start a new project:
- Start with a new directory and save it in a place on your computer that makes sense to you.
- Save the project with the name IntroToDSwRCourse.
- Check the working directory using the getwd() function and be sure it's the same folder you chose to save your project in.
- Start a new script. Save the script with the filename lesson1_exercise.R.
- Write a custom function, area_rectangle(), which calculates the area of a rectangle, with the following code: