Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

R Get Started


Sure, getting started with R is pretty straightforward. Here's a simple guide with examples:

1. Install R and RStudio

2. Open R or RStudio

Once installed, open R or RStudio on your computer.

3. Start with Basic Arithmetic

Let's start with some simple arithmetic operations:

Example

# Addition
3 + 5

# Subtraction
10 - 2

# Multiplication
4 * 6

# Division
20 / 5

4. Assign Values to Variables

You can store values in variables:

Example

# Assigning values to variables
x <- 10
y <- 5

# Using variables in operations
z <- x + y
z

5. Working with Vectors

Vectors are sequences of elements. Here's how you can create and work with vectors:

Example

# Creating a numeric vector
numbers <- c(1, 2, 3, 4, 5)

# Creating a character vector
fruits <- c("apple", "banana", "orange")

# Accessing elements of a vector
numbers[3] # This will print the third element of the vector "numbers"

6. Using Functions

R comes with many built-in functions:

Example

# Square root function
sqrt(25)

# Mean function
mean(c(1, 2, 3, 4, 5))

7. Working with Data Frames

Data frames are used to store tabular data:

Example

# Creating a data frame
df <- data.frame(
Name = c("Alice", "Bob", "Charlie"),
Age = c(25, 30, 35),
Sex = c("Female", "Male", "Male")
)

# Viewing the data frame
df

8. Further Learning

This is just the beginning! As you become more comfortable with these basics, you can explore more advanced topics like data visualization, statistical analysis, and machine learning. There are plenty of online tutorials, courses, and resources available to help you learn and master R.


Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java