Introduction to R

Topic: Getting Started

Advertisement

Introduction

R is a powerful programming language and environment for statistical computing and graphics. It is widely used by statisticians, data scientists, and researchers for data analysis, visualization, and modeling.

What is R?

R is both a language and an environment for statistical computing. It provides a wide variety of statistical and graphical techniques, including linear and nonlinear modeling, classical statistical tests, time-series analysis, clustering, and more.

Why Learn R?

  1. Open Source: Free to use and modify
  2. Extensive Packages: Over 18,000 packages available
  3. Statistical Power: Built by statisticians, for statisticians
  4. Visualization: Excellent graphics capabilities
  5. Community: Strong support and resources

Installing R and RStudio

# Check R version
version

# Install R from CRAN (https://cran.r-project.org/)
# Install RStudio from RStudio (https://rstudio.com/)

Your First R Session

# Print hello world
print("Hello, R!")

# Simple calculation
2 + 2

# Create a variable
x <- 5
y <- 10
x + y

R as a Calculator

# Basic operations
10 + 5       # Addition
10 - 5       # Subtraction
10 * 5       # Multiplication
10 / 5       # Division
10 ^ 2       # Exponentiation
10 %% 3      # Modulus

Working Directory

# Get current working directory
getwd()

# Set working directory
setwd("C:/Users/Documents/RProjects")

# List files in directory
list.files()

Summary

R is an essential tool for data science and statistical analysis. Start with the basics, practice regularly, and gradually explore its vast capabilities.

Advertisement

Advertisement

Need More Practice?

Get personalized R programming help from ChatWhole's AI-powered platform.

Get Expert Help →