Experiment-1
Install and configure R, set working directory.
---
1. Objective
The objective of this experiment is to:
Understand the process of installing R, an open-source programming language and
environment widely used for statistical computing and graphics.
Learn how to configure the working directory in R to streamline file management and
script execution for various data analysis tasks.
Test the environment to ensure everything is set up correctly.
---
2. Steps
Step 1: Installation of R
Download R:
Visit the official R Project website and download the installer suitable for your operating
system (Windows, macOS, or Linux).
Windows: Download the .exe file.
macOS: Download the .pkg file.
Linux: Use package managers like apt-get or yum.
Run the Installer:
Follow the prompts during installation:
Accept the license agreement.
Select the installation directory.
Complete the installation process.
Step 2: Installation of RStudio (Optional but Recommended)
Download RStudio:
RStudio provides a user-friendly interface for working with R. Download it from
RStudio's website.
Install RStudio:
Ensure R is already installed.
Run the RStudio installer and follow the setup instructions.
Step 3: Setting the Working Directory
Definition of Working Directory:
The working directory is the folder where R looks for files to load or save by default.
Set the Directory:
Open R or RStudio.
Use the setwd() function to specify your desired folder, e.g.,
setwd("C:/Users/YourName/Documents/R_Projects")
To check the current working directory, use the getwd() function:
getwd()
Step 4: Testing the Setup
Run basic R commands to ensure the environment is functional, such as:
print("Hello, R!")
Create a sample file and save it in the working directory to confirm the setup.
---
3. Observation
Successful Installation:
Both R and RStudio were installed without errors, indicating a correctly functioning
setup process.
Working Directory Verified:
The working directory was set using the setwd() function and confirmed using the
getwd() function.
Test Commands Executed Successfully:
Basic commands such as print() were executed without issues, verifying that R and
RStudio are operational.
---
4. Conclusion
The experiment demonstrated the installation of R and RStudio and the configuration of
a working directory. This setup is essential for efficient project management and script
execution in R. By completing these steps, the environment is ready for statistical
analysis, data visualization, and other programming tasks.
---