R Syntax

Expression Structure

R evaluates each line as a statement or expression. It can include calculations, function calls, or variable assignments.

Loading...
Output:

Assignment Operators

You can assign values using <- (preferred in R) or =.

x <- 10
y = 20

Comments

Use # to write single-line comments:

# This is a comment
x <- 42  # Assign 42 to x

Code Execution

Code runs top-down in R. You can run scripts from:

  • R Console
  • RScript (command line)
  • RStudio

Case Sensitivity

Variable names are case-sensitive in R:

value <- 10
Value <- 20
print(value)  # 10
print(Value)  # 20

Print and Output

Use print() or just the variable name to display output:

Loading...
Output:

Need Help?

Ask the AI if you need help understanding or want to dive deeper in any topic