ChatGPT can Create Datasets, Program in R… and when it makes an Error it can Fix that too!


ChatGPT from OpenAI leaves me speechless over and over again. I have been in the AI industry for many decades now and it has been a long time since I last had this feeling of utter fascination mixed with disbelief mixed with anxiety.

This is only a quick post in the context of R programming which I wanted to share with you, so read on!

So, I asked ChatGPT to create a sample dataset and write some R code to analyze it:

As you can see the code comes fully documented already!

The table looks nice but I wanted to have it in csv format:

When I ran the code, I encountered an error, so I asked ChatGPT to fix it:

After that the code ran without any problems:

# Load the data into R
crm_data <- read.csv("data/crm_data.csv", header = TRUE)

# View the first few rows of the data
head(crm_data)
##   Customer_ID  Name       Address          City State Zip_Code Phone_Number
## 1           1  John  123 Main St.      New York    NY    10001 555-555-5555
## 2           2  Jane 456 Park Ave.   Los Angeles    CA    90001 555-555-5556
## 3           3   Sam   789 Elm St.       Chicago    IL    60601 555-555-5557
## 4           4 Sarah  987 Main St. San Francisco    CA    94102 555-555-5558
## 5           5  Mike 321 Park Ave.      New York    NY    10001 555-555-5559
##             Email Purchased_Product Purchase_Date
## 1  john@gmail.com       Apple Watch    01/01/2022
## 2  jane@gmail.com         iPhone 12    01/02/2022
## 3   sam@gmail.com       AirPods Pro    01/03/2022
## 4 sarah@gmail.com       MacBook Pro    01/04/2022
## 5  mike@gmail.com          iPad Pro    01/05/2022

# View the number of rows and columns in the data
dim(crm_data)
## [1]  5 10

# View the summary statistics of the data
summary(crm_data)
##   Customer_ID     Name             Address              City          
##  Min.   :1    Length:5           Length:5           Length:5          
##  1st Qu.:2    Class :character   Class :character   Class :character  
##  Median :3    Mode  :character   Mode  :character   Mode  :character  
##  Mean   :3                                                            
##  3rd Qu.:4                                                            
##  Max.   :5                                                            
##     State              Zip_Code     Phone_Number          Email          
##  Length:5           Min.   :10001   Length:5           Length:5          
##  Class :character   1st Qu.:10001   Class :character   Class :character  
##  Mode  :character   Median :60601   Mode  :character   Mode  :character  
##                     Mean   :52941                                        
##                     3rd Qu.:90001                                        
##                     Max.   :94102                                        
##  Purchased_Product  Purchase_Date     
##  Length:5           Length:5          
##  Class :character   Class :character  
##  Mode  :character   Mode  :character  
##                                       
##                                       
## 

# Create a bar plot showing the number of purchases by state
barplot(table(crm_data$State))

# Create a pie chart showing the percentage of purchases by product
pie(table(crm_data$Purchased_Product), main = "Percentage of Purchases by Product")

# Convert the Purchase_Date column to a date format
crm_data$Purchase_Date <- as.Date(crm_data$Purchase_Date, format = "%m/%d/%Y")

# Create a scatterplot showing the relationship between purchase date and zip code
plot(crm_data$Purchase_Date, crm_data$Zip_Code, xlab = "Purchase Date", ylab = "Zip Code")

Ok, that’s it for today… this is just unbelievable, isn’t it? Please share your thoughts and experience with this tool in the comments below!


UPDATE December 14, 2022
I created a video where I test ChatGPT with real exam questions (in German):


UPDATE December 22, 2022
To understand the general principle that underlies the inner workings of Large Language Models (LLMs) like ChatGPT, read my new post here: Create Texts with a Markov Chain Text Generator… and what this has to do with ChatGPT!.

14 thoughts on “ChatGPT can Create Datasets, Program in R… and when it makes an Error it can Fix that too!”

  1. One can always look for something that the model can´t do, but in the end this is – for me – next level.
    It is really close to be a really comprehensive and powerful chatbot which could be in some way
    life-changing. I could imagine this to be the next Google. “If you want to know something – GPT it! ;)”

    It doesn´t matter that it is not a capable to do math operations. People will find out when to use chatbots and when to use something different as you also do it today.

    We maybe highly overestimate the impact of consciousness or general intelligence on powerful models.

Leave a Reply to Learning Machines Cancel reply

Your email address will not be published. Required fields are marked *

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.

This site uses Akismet to reduce spam. Learn how your comment data is processed.