Yes, you read that correctly—300% faster! That’s the remarkable leap in speed I’ve experienced in tackling my most common R programming challenges ever since I enlisted the help of a certain robotic companion to think alongside me.
That companion, as you might have guessed, is none other than ChatGPT. It’s become a trusted ally in various aspects of my research. While its prowess in aiding writing tasks has been widely discussed, I stumbled upon its true strength in assisting with my all-to-common R-isuses.
Let me start with a disclaimer: I consider myself fairly decent in R, but I’m perhaps a bit old-fashioned when it comes to embracing new ideas. My focus tends to be on results, sometimes neglecting code cleanliness or efficiency. These days, I find myself using R much less frequently than during my PhD, mainly for data manipulation, while also doing a lot of debugging of student code.
So, what magic does that friendly robot perform for me?
- First off, ChatGPT is surprisingly adept at coding. Describe an issue, and it often churns out a correct, clear, and concise solution. For example, filtering a dataset based on specific criteria and then calculating averages across factor levels—a task more proficient R users might do from memory, but one I often find myself looking up the functions for.
- Sure, I could turn to traditional help files and forums, but with ChatGPT, everything I need is in one place. I can formulate queries easily and get immediate responses, bypassing the need to scour forums or craft elaborate forum posts myself.
- It gets even better when faced with a series of tasks. ChatGPT remembers previous actions within the same conversation, offering suggestions that build upon each other, simplifying code integration throughout a workflow.
- When you get a suggestion back from ChatGPT that does not do exactly what you want it to do, you can simply describe where or what is not according to expectations, and ChatGPT immediately provides an alternative. I can even paste error codes directly from R, providing the robot with the context it needs to troubleshoot effectively. This way you can truly get into conversation with the robot, slowly but steadily molding and improving the code into your wishes.
- If you provide the dataset and column names in your queries – or even snippets of your own code – the R-code generated by ChatGPT uses these names immediately when generating code, making it much easier to see what goes where.
- Many of the tasks I encounter in R are ones I’ve tackled before. But digging through files to find previous solutions takes time, whereas ChatGPT provides guidance swiftly and efficiently.
- I’ve noticed my students increasingly relying on ChatGPT as well, empowering them to resolve issues independently, reducing dependency on my assistance and time.
Fabulous, no? To me, this works pretty fluently, and allowed me to effectively speed up some daunting R-tasks, especially regarding data wrangling.
I also see very few drawbacks:
- One concern is plagiarism, though in coding, this seems less of an issue compared to academic writing. Personally, I’ve borrowed code snippets without explicit credit before, though I do ensure proper attribution for packages used, so that has not changed much by switching to the robot.
- There is a minor drawback that ChatGPT would not include the most recent developments in R. However, for most general tasks, for example regarding data wrangling, it does have access to everything we need.
- There’s also the minor drawback of potentially limiting oneself to popular R packages, as ChatGPT may not be well-versed in lesser-known ones. But given my pragmatic approach to coding, as long as I achieve the desired outcomes, this limitation isn’t a major concern to me.
In conclusion, integrating ChatGPT into my coding workflow has streamlined my R programming endeavors, particularly in data wrangling. There might of course be a lot more to say about this, but I thought it might be beneficial to many to at least get the conversation going.
Now, I’m curious—have you used ChatGPT for your coding issues, and if so, what has been your experience? Are there drawbacks that I have – perhaps in my naivety – overlooked?










Awesome!The drawback of bullet point 2, might be overcome by using Gemini from Google (It seems an up to date).
Thanks, Bedassa, that’s a great tip! Will see if it can help us out with some more recent and perhaps also less widely used packages!