| title: “Project 01: Individual Coding & Analysis” |
| subtitle: “STT 2860 Intro to Data Management & Visualization” |
| author: “Kade Sutton” |
| date: “Tuesday, February 04, 2025 @ 02:03 PM” |
| output: |
| html_document: |
| theme: lumen |
| highlight: textmate |
In the second chapter of DataCamp Introduction to R course, you created and manipulated vectors representing winnings for one week in poker and roulette. In some cases you performed operations more than once using different methods, to learn how to be more compact/efficient. You will adapt some of that work here. Be as neat and efficient as you can in your coding.
A person plays poker and roulette on weekdays for two weeks. Winnings (in US dollars) are tabulated below. Negative values are, of course, losses. Create named vectors of winnings for each game where the names are the days of the week.
| Day Number | Day of the Week | Poker Winnings | Roulette Winnings |
|---|---|---|---|
| 1 | Mon | 140 | -25 |
| 2 | Tue | -50 | -50 |
| 3 | Wed | 20 | 100 |
| 4 | Thu | -120 | -350 |
| 5 | Fri | 240 | 105 |
| 6 | Mon | 100 | 5 |
| 7 | Tue | -30 | -85 |
| 8 | Wed | 305 | 210 |
| 9 | Thu | -90 | 175 |
| 10 | Fri | 1000 | -105 |
days_number = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
days_vector = c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
poker_vector = c(140, -50, 20, -120, 240, 100, -30, 305, -90, 1000)
roulette_vector = c(-25, -50, 100, -350, 105, 5, -85, 210, 175, -105)
names(poker_vector)
NULL
names(roulette_vector)
NULL
Combine your vectors from (a) to create one vector that contains the total win/loss amount for each of the 10 days.
daily_total = poker_vector + roulette_vector
daily_total
[1] 115 -100 120 -470 345 105 -115 515 85 895
Use your vectors from (a) and (b) to find (i) total poker winnings, (ii) total roulette winnings, and (iii) total overall winnings.
poker_winnings <- c(140 -50 + 20 -120 + 240 + 100 -30 + 305 -90 + 1000)
roulette_winnings <- c(-25 -50 + 100 -350 + 105 + 5 -85 + 210 + 175 -105)
total_winnings <- poker_winnings + roulette_winnings
On which days did the person lose money playing poker? On which days did they lose money playing roulette? What about each day overall? In each of the three cases, select only those days and print them out.
selection_vector <- poker_vector > 0
selection_vector_roulette <- roulette_vector > 0
Choose one weekday (Monday through Friday). Create a vector that contains only those two days from the poker winnings vector. Do the same for roulette winnings vector and your vector of daily totals from (b).
wed_poker <- poker_winnings[days_vector == "Wednesday"]
wed_roulwtte <- roulette_winnings[days_vector == "Wednesday"]
wed_total <- daily_total[days_vector == "Wednesday"]
Does the person tend to make money or lose money playing each game? What about overall? Can you detect any patterns from just the analyses you have done above? What else might help you make sense of these data?
ANSWER: “He seems to lose more times then wins but his wins are larger then his loses, so we can analyse which type of poker has more ability to create wins and more profit based on what he bets and wins”
sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: x86_64-redhat-linux-gnu
Running under: Red Hat Enterprise Linux 9.5 (Plow)
Matrix products: default
BLAS/LAPACK: FlexiBLAS OPENBLAS-OPENMP; LAPACK version 3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: America/New_York
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] digest_0.6.37 R6_2.5.1 fastmap_1.2.0 xfun_0.50
[5] cachem_1.1.0 knitr_1.49 htmltools_0.5.8.1 rmarkdown_2.29
[9] lifecycle_1.0.4 cli_3.6.3 sass_0.4.9 jquerylib_0.1.4
[13] compiler_4.4.2 rstudioapi_0.17.1 tools_4.4.2 evaluate_1.0.3
[17] bslib_0.9.0 rlang_1.1.5 jsonlite_1.8.9