Creating code for HR data analysis? ChatGPT helped us in three ways

22.08.2023

In the world of analysis and coding, efficiency and accuracy are essential. Fortunately, AI technology such as ChatGPT offers a solution for streamlining these processes. In this blog post, we explore the unique capabilities of ChatGPT ourselves in three crucial areas: writing code from scratch, translating code from one language to another, and solving those annoying “errors” that statistical software always throws in your way.

Written by Lotte Van der Sijpt

Even if you are not an AI expert or do not closely follow the latest developments, chances are that you are already familiar with ChatGPT. This advanced language model, based on OpenAI’s GPT-3.5 architecture, is known for its impressive capabilities in natural language processing. This means that ChatGPT understands human language at a deeper level.

Unlike popular search engines such as Google, it can not only answer your questions, but also provide complex insights and effortlessly hold realistic conversations. As we already mentioned in a previous blog post, ChatGPT is even a powerful tool in the HR world. But how strong is it as your new HR analytics assistant?

1. Coding magic: ChatGPT’s ability to create code

With the power of ChatGPT, users can generate complex code to address their specific research questions. All that is required is a clear and precise description of the desired analysis. This includes the required version of the programme, the packages or extensions used in your software, and relevant variable names. ChatGPT can then propose code with a high degree of accuracy that is perfectly tailored to your business question.

Code genereren

ChatGPT, OpenAI. (2023). Screenshot from chat.openai.com. OpenAI – Converting a simple analysis question into R code.

Tips for optimal use:

  • Provide as much detailed information as possible about your requirements (e.g. software version and variable names), so that ChatGPT can provide you with the most relevant code.
  • Make it easy for yourself by using the same names for variables, as ChatGPT will automatically adopt them.
  • Specify the programming language you are working in and, if applicable, the software version to avoid compatibility issues.

2. Seamless language transition: ChatGPT’s ability to translate code

Does your colleague prefer working with SPSS, while your training mainly taught you to code in RStudio? Then you are faced with a language barrier between SPSS syntax and R scripts. ChatGPT bridges the gap between different coding languages by translating code from one language to another. This allows researchers to convert their code with a single simple request, saving time and effort when adapting analyses to different environments.

Code vertalen

ChatGPT, OpenAI. (2023). Screenshot from chat.openai.com. OpenAI – Translating SPSS syntax into R code.

Tips for optimal use:

  • Make sure you clearly indicate the source and target language, and if possible, the versions of the programmes used.
  • Always carefully review the translated code to ensure that the functionality and logic remain intact.
  • Mention “if possible” so that ChatGPT is prompted to indicate when one coding language is more capable than the other.

3. Bug-Buster: ChatGPT’s ability to detect errors

A final remarkable quality of ChatGPT is its ability to detect and correct programming errors. As a user, you can sometimes no longer see the wood for the trees and, when you type code manually, even the smallest typing mistakes can be heavily penalised.

Some programmes help you by identifying where your error is. But often the errors are a language of their own and there is usually no “AutoCorrect” button that offers suggestions. When you present your code, ChatGPT can identify possible errors and make recommendations to improve them.

You can also simply copy and paste the error directly into ChatGPT and ask what it exactly means or what the next steps are. Moreover, ChatGPT adapts itself as it learns more from your interactions, making it increasingly accurate and effective in providing useful solutions.

Code verbeteren

ChatGPT, OpenAI. (2023). Screenshot from chat.openai.com. OpenAI – Detecting and solving an error in existing R code.

Tips for optimal use:

  • There is no need to provide sensitive data to ChatGPT. The programme always creates its own dummy data (sample data) to test its solutions.
  • Carefully review the suggested corrections and understand the reason behind the changes in order to improve your own programming skills.
  • Be patient and provide feedback to ChatGPT when necessary, so that it can better adapt to your specific needs. (Yes, sometimes it is only the 3rd solution that actually works!)

Conclusion

ChatGPT has proven itself to be a valuable tool for analysis and coding, with unique capabilities to generate code, translate it, and improve both you and itself.

The advantages in terms of time savings, error detection and personal support far outweigh some possible disadvantages. By this, we mainly mean the fact that ChatGPT is less familiar with the menu and navigation layout of certain programmes (which can lead you to search for buttons that do not exist) and that ChatGPT tends to always provide an answer (even when that answer is incorrect).

ChatGPT tends to always provide an answer (even if it is wrong).

A golden tip? Start a new chat and rephrase your question when you notice that ChatGPT’s answers are not going in the direction you want. You can keep going back and forth for a while, but chances are that some miscommunication has crept into your conversation and ChatGPT keeps getting stuck on it. So learn from the conversation yourself and simply ask the question in a different way in a new chat.

We recommend always remaining critical, but with the right guidance and detailed instructions as precautionary measures, ChatGPT can become an indispensable tool for researchers and programmers who want to take their analytical capabilities to new heights.

Want to know more?

Would you like to try this powerful language model yourself? Then you can create a free account via OpenAI and visit ChatGPT yourself.

Would you like even more inspiration on HR analytics and AI in HR? Then be sure to subscribe to our bi-monthly newsletter for tips and trends or contact us.