Absolutely! Here's a beginner-friendly introduction to R with examples:

What is R?

R is a programming language and environment for statistical computing and graphics. It's widely used by statisticians, data analysts, and researchers to analyze data and create visualizations.

# Assigning values to variables x <- 10 y <- 5 # Using variables in operations z <- x + y z # This will print the value of z, which is 15

Example 3: Vectors

Vectors are sequences of elements of the same data type.

Example

# Creating a numeric vector numbers <- c(1, 2, 3, 4, 5) # Creating a character vector fruits <- c("apple", "banana", "orange")

Example 4: Functions

R comes with many built-in functions.

Example

# Square root function sqrt(25) # This will return the square root of 25, which is 5 # Mean function mean(c(1, 2, 3, 4, 5)) # This will return the mean of the vector, which is 3

Example 5: 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

These examples cover some basic concepts in R to get you started. As you continue learning, you can explore more advanced topics such as data manipulation, plotting, statistical analysis, and machine learning. R has a vast community and plenty of resources available online for further learning.