Working Environment and Programming Logic
2025-01-30
Worked on Homework #2
Identified several useful functions and packages:
packages/libraries
stringr
, stringi
re
functions
tolower
, stri_reverse
, stri_sub_all
.lower()
, [::-1]
, re.sub
If you made at least one submission to github, you have some points for homework #2 in Canvas
make 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:
…
Review
Coming up: Self Assessment quiz