print("Hello, World!")[1] "Hello, World!"
print("Hello, World!")[1] "Hello, World!"
3 + 5 # Addition[1] 8
10 - 4 # Subtraction[1] 6
6 * 7 # Multiplication[1] 42
8 / 2 # Division[1] 4
2^3 # Exponentiation (2 raised to the power of 3)[1] 8
#. Any text following # will be ignored by R when executing commands.x <- 10 # Assign the value 10 to the variable x
y <- 5 # Assign the value 5 to the variable yresult <- x + y # Add x and y, store the result in a new variable 'result'
result[1] 15
<-, which assigns a value to a variable.sqrt(25)[1] 5
numbers <- c(1, 2, 3, 4, 5) # Create a vector of numbers
sum(numbers)[1] 15
mean() – Calculates the average of a set of numbers.length() – Returns the number of elements in a vector or list.min() and max() – Returns the smallest or largest value from a vector.sqrt() and sum(), are powerful tools for performing calculations in R.