R Syntax

R Syntax

The syntax of a programming language dictates how the code must be written.

R features a clean, highly readable syntax designed specifically for mathematicians and data scientists.


Printing Output

To output data or text to the screen, we use the print() function.

You must enclose text strings perfectly inside double quotes or single quotes.

Interestingly, R allows you to output numbers or strings directly without even typing print()!

Output Examples:

# Using the print function
print("Welcome to IntricateDevo!")
# Direct output without print (works in the R console)
"Data Science is fun!"
# Outputting a raw number
500

Basic Calculations

R is fundamentally a statistical engine, meaning it acts as a highly advanced calculator.

You can type mathematical expressions directly into the R console.

R will evaluate the expression instantly and return the exact mathematical result.

Calculation Example:

# Basic addition
10 + 25
# The output will be 35

Formatting and Spacing

R is not strictly space-sensitive, meaning extra spaces do not cause errors.

However, maintaining clean formatting makes your code vastly easier to read and maintain.

Search engines favor perfectly documented coding tutorials that feature clean, professional syntax formatting!


Exercise 1 of 2

?

Can you output a string in the R console without explicitly using the print() function?

Exercise 2 of 2

?

How does R evaluate the expression: 10 + 10?