
Your Success, Our Mission!
6000+ Careers Transformed.
The R Console is where R executes commands immediately. When you type a command and press Enter, R processes it and shows the output.
Example:
| 2 + 3 |
Output appears instantly in the console.
Use cases of Console:
However, console commands are not saved automatically.
An R Script is a file (with .R extension) where you write and save R code.
Advantages of scripts:
Example script:
| x <- 10 y <- 5 x + y |
Best practice:
Use scripts for actual analysis and the console for quick testing.
Variables store values in memory. R commonly uses the assignment operator <-.
Example:
| age <- 21 name <- "alex" |
You can also use = but <- is preferred in R programming.
The different Data Types in R are :
| height <- 5.8 |
| count <- 10 |
| city <- "Mumbai" |
| is_student <- TRUE |
We can check a variable’s type using:
| class(age) |
Understanding data types is crucial because R behaves differently based on the type of data.
Operators allow R to perform computations and comparisons.
1. Arithmetic Operators
Used for mathematical calculations.
Operator | Meaning |
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| ^ | Power |
Example:
| 10 + 5 2 ^ 3 |
2. Relational Operators
Used for comparisons.
Operator | Meaning |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal to |
| <= | Less than or equal to |
| == | Equal to |
| != | Not equal to |
Example:
| age > 18 |
3. Logical Operators
Logical operators are used to combine, compare, or negate conditions. They always return a logical value: TRUE or FALSE.
Operator | Name | Description | Example |
| ! | Logical NOT | Flips the result (TRUE to FALSE) | !(5 == 5) |
| & | Element-wise AND | TRUE if both conditions are TRUE | x > 5 & x < 10 |
| | | Element-wise OR | TRUE if at least one is TRUE | x == 1 | x == 2 |
| && | Logical AND | TRUE if both conditions are TRUE (single comparison) | if (a && b) |
| || | Logical OR | TRUE if one is TRUE (single comparison) | if(a || b) |
Example:
| age > 18 & is_student == TRUE |
4. Assignment Operator
Used to assign values:
| x <- 100 |
Top Tutorials
CNN in Deep Learning 2026
A beginner-friendly guide to CNNs: understand deep learning essentials, create Python-based models, and explore advanced applications.
Breaking The Limits: Scaling Databases with MySQL Partitioning
Learn MySQL partitioning with examples. Improve query performance, scalability, and data management using RANGE, LIST, HASH, KEY, and composite techniques.
ML in Action: Hands-On Guide to Deploying and Serving Models
Learn model deployment and serving—from concepts to real-world architectures, tools, APIs, containers, and cloud workflows for production-ready ML.
All Courses (6)
Master's Degree (2)
Fellowship (2)
Certifications (2)