-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnteringData.R
73 lines (49 loc) · 1.41 KB
/
EnteringData.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# COLON OPERATOR ###########################################
# Assigns number 0 through 10 to x1
x1 <- 0:10
x1
#[1] 0 1 2 3 4 5 6 7 8 9 10
# Descending order
x2 <- 10:0
x2
# [1] 10 9 8 7 6 5 4 3 2 1 0
# SEQ ######################################################
?seq # R help on seq
# Ascending values (duplicates 1:10)
(x3 <- seq(10))
# [1] 1 2 3 4 5 6 7 8 9 10
# Specify change in values
(x4 <- seq(30, 0, by = -3))
# [1] 30 27 24 21 18 15 12 9 6 3 0
# ENTER MULTIPLE VALUES WITH C #############################
# c = concatenate (or combine or collect)
?c # R help on c
x5 <- c(5, 4, 1, 6, 7, 2, 2, 3, 2, 8)
x5
# [1] 5 4 1 6 7 2 2 3 2 8
# SCAN #####################################################
?scan # R help on scan
x6 <- scan() # After running this command, go to console
# Hit return after each number
# Hit return twice to stop
x6
#numeric(0)
# REP ######################################################
?rep # R help on rep
x7 <- rep(TRUE, 5)
x7
#[1] TRUE TRUE TRUE TRUE TRUE
# Repeats set
x8 <- rep(c(TRUE, FALSE), 5)
x8
#[1] TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
# Repeats items in set
x9 <- rep(c(TRUE, FALSE), each = 5)
x9
#[1] TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
# CLEAN UP #################################################
# Clear environment
rm(list = ls())
# Clear console
cat("\014") # ctrl+L
# Clear mind :)