From 2faf7764323c42164fbf0f090eb225aee824e0bf Mon Sep 17 00:00:00 2001 From: USATVIKA Date: Sun, 21 Dec 2025 16:00:12 -0600 Subject: [PATCH] plots --- ...doc.5bd52e1c-f157-48ff-8b8a-ad7c39a8e6d4.r | 1193 +++++++++++++++++ ...doc.7bf7dc5e-991f-4d5f-a4b2-14cfcfe0f54c.r | 1193 +++++++++++++++++ ...doc.dcdb4b81-a2f0-4d7f-a8b4-5a8d4349a48a.r | 1193 +++++++++++++++++ .../introduction-to-python/tutorial.Rmd | 265 +++- 4 files changed, 3835 insertions(+), 9 deletions(-) create mode 100644 inst/tutorials/introduction-to-python/.vdoc.5bd52e1c-f157-48ff-8b8a-ad7c39a8e6d4.r create mode 100644 inst/tutorials/introduction-to-python/.vdoc.7bf7dc5e-991f-4d5f-a4b2-14cfcfe0f54c.r create mode 100644 inst/tutorials/introduction-to-python/.vdoc.dcdb4b81-a2f0-4d7f-a8b4-5a8d4349a48a.r diff --git a/inst/tutorials/introduction-to-python/.vdoc.5bd52e1c-f157-48ff-8b8a-ad7c39a8e6d4.r b/inst/tutorials/introduction-to-python/.vdoc.5bd52e1c-f157-48ff-8b8a-ad7c39a8e6d4.r new file mode 100644 index 0000000..590ca10 --- /dev/null +++ b/inst/tutorials/introduction-to-python/.vdoc.5bd52e1c-f157-48ff-8b8a-ad7c39a8e6d4.r @@ -0,0 +1,1193 @@ +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +library(learnr) +library(tutorial.helpers) +library(knitr) + +knitr::opts_chunk$set(echo = FALSE) +knitr::opts_chunk$set(out.width = '90%') +options(tutorial.exercise.timelimit = 60, + tutorial.storage = "local") +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 2) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +include_graphics("images/codespaces-1.png") +# +# +# +# +# +include_graphics("images/codespaces-2.png") +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 15) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 7) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 8) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 3) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 3) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 20) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 20) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# diff --git a/inst/tutorials/introduction-to-python/.vdoc.7bf7dc5e-991f-4d5f-a4b2-14cfcfe0f54c.r b/inst/tutorials/introduction-to-python/.vdoc.7bf7dc5e-991f-4d5f-a4b2-14cfcfe0f54c.r new file mode 100644 index 0000000..590ca10 --- /dev/null +++ b/inst/tutorials/introduction-to-python/.vdoc.7bf7dc5e-991f-4d5f-a4b2-14cfcfe0f54c.r @@ -0,0 +1,1193 @@ +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +library(learnr) +library(tutorial.helpers) +library(knitr) + +knitr::opts_chunk$set(echo = FALSE) +knitr::opts_chunk$set(out.width = '90%') +options(tutorial.exercise.timelimit = 60, + tutorial.storage = "local") +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 2) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +include_graphics("images/codespaces-1.png") +# +# +# +# +# +include_graphics("images/codespaces-2.png") +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 15) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 7) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 8) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 3) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 3) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 20) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 20) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# diff --git a/inst/tutorials/introduction-to-python/.vdoc.dcdb4b81-a2f0-4d7f-a8b4-5a8d4349a48a.r b/inst/tutorials/introduction-to-python/.vdoc.dcdb4b81-a2f0-4d7f-a8b4-5a8d4349a48a.r new file mode 100644 index 0000000..590ca10 --- /dev/null +++ b/inst/tutorials/introduction-to-python/.vdoc.dcdb4b81-a2f0-4d7f-a8b4-5a8d4349a48a.r @@ -0,0 +1,1193 @@ +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +library(learnr) +library(tutorial.helpers) +library(knitr) + +knitr::opts_chunk$set(echo = FALSE) +knitr::opts_chunk$set(out.width = '90%') +options(tutorial.exercise.timelimit = 60, + tutorial.storage = "local") +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 2) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +include_graphics("images/codespaces-1.png") +# +# +# +# +# +include_graphics("images/codespaces-2.png") +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 15) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 7) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 8) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 3) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 3) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 20) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 5) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 10) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +question_text(NULL, +answer(NULL, correct = TRUE), +allow_retry = TRUE, +try_again_button = "Edit Answer", +incorrect = NULL, +rows = 20) +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# diff --git a/inst/tutorials/introduction-to-python/tutorial.Rmd b/inst/tutorials/introduction-to-python/tutorial.Rmd index 66b8117..3eb8073 100644 --- a/inst/tutorials/introduction-to-python/tutorial.Rmd +++ b/inst/tutorials/introduction-to-python/tutorial.Rmd @@ -169,7 +169,7 @@ This is the Python "shell" or "interpreter" or "console." It allows us to work w ### Exercise 5 -At the Console, type `2 + 2` and hit `enter/return`. +At the Console, type `2 + 2` and hit `enter/return`. Remember, the Console is just the Python shell opened up in the terminal after typing "Python" in. CP/CR. @@ -979,12 +979,264 @@ shape: (176, 4) └────────────┴──────┴────────┴─────┘ >>> ``` +The `sort()` method sorts the rows of a DataFrame. By default, it sorts in ascending order. +### Exercise 8 -The `sort()` method sorts the rows of a DataFrame. By default, it sorts in ascending order. +Before we can create plots, we need to import the plotnine library. Run: `from plotnine import ggplot, aes, geom_point, labs, theme_minimal, ggsave` + +```{r method-chaining-and-plots-8} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### + +**plotnine** is Python's implementation of the Grammar of Graphics, similar to R's **ggplot2**. We import the specific functions we'll need for creating and customizing our plot. + +### Exercise 9 + +First, let's create our filtered dataset and assign it to a variable called `dinner_data`. Use the chain from Exercise 7. Run:`dinner_data = tips.filter(pl.col("time") == "Dinner").select(["total_bill", "tip", "sex", "day"]).sort("tip")` + +```{r method-chaining-and-plots-9} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +>>> dinner_data = tips.filter(pl.col("time") == "Dinner").select(["total_bill", "tip", "sex", "day"]).sort("tip") +>>> dinner_data +shape: (176, 4) +┌────────────┬──────┬────────┬─────┐ +│ total_bill ┆ tip ┆ sex ┆ day │ +│ --- ┆ --- ┆ --- ┆ --- │ +│ f64 ┆ f64 ┆ str ┆ str │ +╞════════════╪══════╪════════╪═════╡ +│ 3.07 ┆ 1.0 ┆ Female ┆ Sat │ +│ 5.75 ┆ 1.0 ┆ Female ┆ Fri │ +│ 7.25 ┆ 1.0 ┆ Female ┆ Sat │ +│ 12.6 ┆ 1.0 ┆ Male ┆ Sat │ +│ 16.99 ┆ 1.01 ┆ Female ┆ Sun │ +│ … ┆ … ┆ … ┆ … │ +│ 28.17 ┆ 6.5 ┆ Female ┆ Sat │ +│ 48.27 ┆ 6.73 ┆ Male ┆ Sat │ +│ 39.42 ┆ 7.58 ┆ Male ┆ Sat │ +│ 48.33 ┆ 9.0 ┆ Male ┆ Sat │ +│ 50.81 ┆ 10.0 ┆ Male ┆ Sat │ +└────────────┴──────┴────────┴─────┘ +>>> Assigning our filtered data to a variable makes it easier to reuse and keeps our plotting code cleaner. + +### Exercise 10 + +Now let's start building our plot. The basic structure uses `ggplot()` with the data and `aes()` (aesthetics) to map variables to visual properties. Run:`ggplot(dinner_data, aes(x="total_bill", y="tip"))` + +```{r method-chaining-and-plots-10} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> ggplot(dinner_data, aes(x="total_bill", y="tip")) +
+>>> +``` +This creates a blank plot with axes set up. We've told **plotnine** that `total_bill` should be on the x-axis and `tip` on the y-axis, but we haven't added any geometric objects (points, lines, etc.) yet. + +### Exercise 11 + +Use the up arrow to retrieve to previous code. +Add a geometry layer to actually display the data points. Use the `+` operator to add `geom_point()`. Run: +`ggplot(dinner_data, aes(x="total_bill", y="tip")) + geom_point()` + +```{r method-chaining-and-plots-11} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> ggplot(dinner_data, aes(x="total_bill", y="tip")) + geom_point() +
+>>> +``` + +Now you should see a scatter plot showing the relationship between total bill and tip amounts. The plot shows a general positive correlation. + +### Exercise 12 + +Let's add color to distinguish between male and female customers. Add `color="sex"` inside the `aes()` function. Run: +`ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point()` + +```{r method-chaining-and-plots-12} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point() +
+>>> +``` + +The points are now colored by sex, with a legend automatically added. - +### Exercise 13 + +Let's customize the appearance of the points. Add `size=3` and `alpha=0.6` as arguments to `geom_point()`. Run: +`ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6)` + +```{r method-chaining-and-plots-13} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` +### + +``` +>>> ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6) +
+>>> +``` + +The `size` parameter makes the points bigger, and `alpha` controls transparency (0.6 means 60% opaque), which helps when points overlap. + +### Exercise 14 + +Add labels to make the plot more informative. Add `labs()` with a title and axis labels. Run: +`ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6) + labs(title="Tips vs Total Bill for Dinner", x="Total Bill ($)", y="Tip ($)", color="Sex")` + +```{r method-chaining-and-plots-14} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6) + labs(title="Tips vs Total Bill for Dinner", x="Total Bill ($)", y="Tip ($)", color="Sex") +
+>>> +``` + +The `labs()` function adds a title and customizes the axis labels and legend title. + +### Exercise 15 + +Apply a cleaner theme to the plot. Add `theme_minimal()` to the chain. Run: +`ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6) + labs(title="Tips vs Total Bill for Dinner", x="Total Bill ($)", y="Tip ($)", color="Sex") + theme_minimal()` + +```{r method-chaining-and-plots-15} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6) + labs(title="Tips vs Total Bill for Dinner", x="Total Bill ($)", y="Tip ($)", color="Sex") + theme_minimal() +
+>>> +``` +The minimal theme removes the gray background and gives the plot a cleaner, more modern look. + +### Exercise 16 + +Now let's save our plot to a variable so we can reuse it. Assign the entire plot to a variable called `plot`. Run: +`plot = ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6) + labs(title="Tips vs Total Bill for Dinner", x="Total Bill ($)", y="Tip ($)", color="Sex") + theme_minimal()` + +```{r method-chaining-and-plots-16} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> plot = ggplot(dinner_data, aes(x="total_bill", y="tip", color="sex")) + geom_point(size=3, alpha=0.6) + labs(title="Tips vs Total Bill for Dinner", x="Total Bill ($)", y="Tip ($)", color="Sex") + theme_minimal() +>>> +``` + +The plot is now stored in the `plot` variable. Nothing displays yet because we haven't printed it. + +### Exercise 17 + +Save the plot to a file using `ggsave()`. This function takes the plot object, filename, and optional parameters for resolution and size. Run: +`ggsave(plot, "dinner_tips.png", dpi=300, width=8, height=6)` + +```{r method-chaining-and-plots-17} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> ggsave(plot, "dinner_tips.png", dpi=300, width=8, height=6) +
+>>> +``` + +The plot has been saved as "dinner_tips.png" in your current working directory. The `dpi=300` ensures high resolution, and `width=8, height=6` sets the dimensions in inches. + +### Exercise 18 + +Finally, display the plot in the console by using `print()`. Run: +`print(plot)` + +```{r method-chaining-and-plots-18} +question_text(NULL, + answer(NULL, correct = TRUE), + allow_retry = TRUE, + try_again_button = "Edit Answer", + incorrect = NULL, + rows = 10) +``` + +### +``` +>>> print(plot) +
+>>> +The plot is now displayed. In VS Code or Codespaces, this will typically open in a plot viewer window. You can now view the saved image file by clicking on "dinner_tips.png" in your file explorer. +``` ## Generative AI ### @@ -1145,12 +1397,7 @@ p.display() Note: -* AI tools are great at generating visualizations, but you should understand the code they provide -* Different AI tools may suggest different approaches - compare and learn from them -* Always test the code and make sure you understand what each line does -* You can ask the AI to explain any part of the code you don't understand - -The key is practice. Use AI every day! +* AI tools are great at generating code and visualizations, but you should always own your work and understand everything in it ## Summary ###