Translate Python to R

Imagine you are a code translator. Your task is to convert the following Python code to R. [Insert code]

Using ChatGPT?

Save all chats, add your notes, categorize and search your chat history.