-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.R
167 lines (122 loc) · 4.25 KB
/
main.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
X <- 42
X
my_apples <- 5
my_oranges <- "six"
my_apples + my_oranges
my_fruit = my_apples + my_oranges
my_fruit
my_numeric <- 42
my_character <- "universe"
my_logical = FALSE
class(my_numeric)
class(my_character)
class(my_logical)
numeric_vector <- c(1, 10, 49)
character_vector <- c("a", "b", "c")
boolean_vector <- c(TRUE, FALSE, TRUE)
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50,100, -350, 10)
some_vector <- c("John Doe", "poker player")
names(some_vector) <- c("Name", "Profession")
some_vector["Name"]
some_vector["Profession"]
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50,100, -350, 10)
names(poker_vector) <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(roulette_vector) <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
poker_vector["Monday"]
roulette_vector["Thursday"]
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50,100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- c(days_vector)
names(roulette_vector) <- c(days_vector)
poker_vector[days_vector]
roulette_vector[days_vector]
c(1, 2,3) + c(4, 5, 6)
c(1 + 4, 2 + 5, 3 + 6)
c(5, 7, 9)
a <- c(1, 2, 3)
b <- c(4, 5, 6)
c <- c(a + b)
c
A_vector <- c(1, 2, 3)
B_vector <- c(4, 5, 6)
total_vector <- c(A_vector + B_vector)
total_vector
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50,100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- c(days_vector)
names(roulette_vector) <- c(days_vector)
total_daily <- c(poker_vector + roulette_vector)
total_daily
total_poker <- sum(poker_vector)
total_poker
total_roulette <- sum(roulette_vector)
total_roulette
total_week <- c(total_poker + total_roulette)
total_week
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50,100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- c(days_vector)
names(roulette_vector) <- c(days_vector)
total_daily <- c(poker_vector + roulette_vector)
total_daily
total_poker <- sum(poker_vector)
total_poker
total_roulette <- sum(roulette_vector)
total_roulette
total_poker > total_roulette
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50,100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- c(days_vector)
names(roulette_vector) <- c(days_vector)
poker_wednesday <- c(poker_vector[3])
poker_wednesday
poker_vector[c(1, 5)]
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50, 100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- days_vector
names(roulette_vector) <- days_vector
poker_midweek <- poker_vector[c(2, 3, 4)]
poker_midweek
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50, 100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- days_vector
names(roulette_vector) <- days_vector
roulette_selection_vector <- roulette_vector[c(2:5)]
roulette_selection_vector
poker_vector[c("Monday", "Tuesday")]
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50, 100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- days_vector
names(roulette_vector) <- days_vector
poker_vector[c("Monday", "Tuesday", "Wednesday")]
poker_start <- poker_vector[c("Monday", "Tuesday", "Wednesday")]
poker_start
mean(poker_start)
c(4, 5, 6) > 5
poker_vector <- c(140, -50, 20, -120, 240)
roulette_vector <- c(-24, -50, 100, -350, 10)
days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
names(poker_vector) <- days_vector
names(roulette_vector) <- days_vector
selection_vector <- c(poker_vector > 1)
selection_vector
poker_vector[selection_vector]
poker_winning_days <- poker_vector[selection_vector]
poker_winning_days
matrix(1:9, byrow = TRUE, nrow = 3)
matrix(1:9, byrow = FALSE, nrow = 3)
new_hope <- c(460.998, 314.4)
empire_strikes <- c(290.475, 247.900)
return_jedi <- c(309.306, 165.8)
box_office <- c(new_hope, empire_strikes, return_jedi)
stars_wars_matrix <- matrix(box_office, nrow = 3, byrow = TRUE)
stars_wars_matrix