Working Environment and Programming Logic
2026-01-22
Started working on Homework #2
If you made at least one submission to github, you have some points for homework #2 in Canvas
Computer take things literally
Every step needs to be explained
tolower, str_to_lower)stri_replace)packages/libraries
stringr, stringirefunctions
tolower, stri_reverse, stri_sub_all.lower(), [::-1], re.submake at least one submission to Github
Review function writing: section 13
Code chunks in quarto documents
Create some palindromes with topics from the R tidyverse
ChatGPT said:
Sure, I can get creative with that! Here are some palindromes inspired by the R tidyverse package:
ggplot palindrome:
“plot, ggplot, ggplot, top, lg”
dplyr palindrome:
“pipe, dep, ed, epip”
tidyr palindrome:
“tidy, rid, id, ydit”
stringr palindrome:
“strings, r, r, sgnirts” tibble palindrome:
The first one is not a palindrome
ChatGPT said:
You’re absolutely right! My bad on that one. A palindrome needs to read the same backward and forward. Let me fix that for you! Here’s a proper one:
For ggplot:
“ggplot, tol, log, gg”
That works better as a true palindrome. Thanks for catching that! Would you like more examples, or should I tweak any of the others?
When you execute the same code multiple times, you should wrap the code into a function:
Can you establish how fast your function palindrome is?
Which is faster? R or python? - You might have to make multiple calls to the functions to capture differences
There are some things we should not (ever) do in R Markdown (or quarto) documents:
Install a package
Print a full data set
“Step on no p-values”
…
Review