Κανονικές αλληλουχίες

# How to produce regular sequences with the : operator
1:5
5:1
-1:-5
-5:-1
-1:5
1:-5

0:10
0:10 / 10
0:20 / 20
0:40 / 20

# The seq function can be used to produce a sequence
seq(1, 5)
seq(5, 1)

# The by option, control the step of the sequence
seq(0, 1, by = 0.1)
seq(-1, 1, by = 0.5)
seq(0, 1, by = -0.1) # no, this not possible
seq(1, 0, by = -0.1)

# The length.out option, control the size of the vector
seq(0, 10, by = 2)
seq(0, 10, length.out = 6)
seq(0, 10, length.out = 7)
seq(0, 10, by = 10/6)
seq(0, 10, by = 5/3)

# Options can be given in any order
seq(from = 0, to = 10, by = 2)  
seq(from = 0, to = 10, length.out = 5) 
seq(to = 1, length.out = 5, from = 0)

# Replication, sequence with the same values
rep(1, 5)
rep(1, times = 5)
rep(c(1, 2), times = 5)
rep(c(1, 2), each = 5)
rep(NA, times = 5)

# not possible, a sequence to Infinity cannot be produced
seq(0, Inf)

Συνδεθείτε για περισσότερες δυνατότητες αλληλεπίδρασης,
σχολιασμοί, εξωτερικοί σύνδεσμοι, βοήθεια, ψηφοφορίες, αρχεία, κτλ.

Creative Commons License
Εκπαιδευτικό υλικό από τον Αθανάσιο Σταυρακούδη σας παρέχετε κάτω από την άδεια Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.
Σας παρακαλώ να ενημερωθείτε για κάποιους επιπλέον περιορισμούς
http://stavrakoudis.econ.uoi.gr/stavrakoudis/?iid=401.