# ------------------------------------------------------------------
# File name: sequences.R
#
# seq() function is used to generate a vector with specified patterns
# Below are common usages of seq() and some shortcuts for generating sequences
#
# Version: 2.1
# Authors: H. Kocak, University of Miami and B. Koc, Stetson University
# References:
# https://www.r-project.org
# ------------------------------------------------------------------
# To generate a sequence with fixed increments and assign it to variable x
x = seq(from = 0, to = 10, by = 0.5)
print(x)
# The construction above can be shorten as
x = seq(0, 10, 0.5)
print(x)
# The same sequence above can be generated by specifying the number of entries
x = seq(from = 0, to = 10, length = 21)
print(x)
# To generate a sequence with increment 1 (by = 1) can be shorten as
x = seq(0, 10)
print(x)
# The sequence above can be shorten further as
x = 0:10
print(x)
# : operator has higher predecence than the arithmetical operations.
# Note the difference in the two sequences below
sequence_1 = 0 : 10 - 2
print(sequence_1)
sequence_2 = 0 : (10 - 2)
print(sequence_2)