Data Science Desktop Survival Guide
by Graham Williams |
|||||
Variables |
# Add two numbers and assign the result into a variable.
v <- sum(1, 2)
We can access the value stored in the variable (or actually stored in
the computer's memory that the variable name refers to) simply by
requesting through the R Console that R “run” the
command v. We do so below with a line containing just
|
# Print the value stored in a variable.
v
print(v)
By indexing the variable with |
# Access a particular value from a vector of data.
v[1]
v[2]
|