Chatty rando

Chatty rando

Hashnode's premium ChatGPT feature test case

Table of contents

No heading

No headings in the article.

So, I stumbled across found and that it offered inexpensive ChatGPT 4.0 integrated into an editor and blog publisher. Here is an unpolished test drive.

I hang out on the Posit board for recreational puzzle solving, and sometimes what seems a simple problem begins to turn into a time sink, like this one. So, why not use these as an exercise in prompt-sharpening? So, I asked in the editor window:

Generate a script in the R programming language that takes an index of column names of a data frame, each of which columns in the form of a character string that looks like "1,0" and creates two new columns with numeric variables. Make generous use of functions.

And received a nice code block that worked, even though it can be improved.

# R programming language
process_columns <- function(data_frame, column_indexes) {
  for (index in column_indexes) {
    # Split the character string in the column by ","
    split_values <- strsplit(as.character(data_frame[[index]]), split = ",")

    # Create two new columns with numeric variables
    data_frame[[paste0("Column_", index, "_A")]] <- as.numeric(sapply(split_values, "[[", 1))
    data_frame[[paste0("Column_", index, "_B")]] <- as.numeric(sapply(split_values, "[[", 2))
  }
  return(data_frame)
}

# Example usage
data_frame <- data.frame(A = c("1,0", "2,3", "4,5"), B = c("6,7", "8,9", "10,11"))
column_indexes <- c(1, 2)
new_data_frame <- process_columns(data_frame, column_indexes)
print(new_data_frame)

This was exactly what I asked for, although not quite what I needed. I could either edit or reprompt. Or apply a kludge, which is what did to get the column names in the form I wanted, since for me, this is a one-off. Nor did I remove the spurious comments or fix the ridiculous print statement.

All-in-all, it reminds me of a bright, well-educated first-year associate at a law firm—get's the job done consciencously but can't be trusted with an unreviewed task. And much less expensive.

Here is the AI summary of the foregoing for some more tire kicking, which is also not bad.

This article examines the use of ChatGPT 4.0, a cost-effective editor and blog publisher, to generate a script in R that creates two new columns with numeric variables. The code block generated worked, but could be improved. The author applied a kludge to get the column names in the desired form. The author concluded that the AI was like a bright, well-educated first-year associate at a law firm, but much more cost-effective.

In my style, if I had to summarize for an audience with the attention span of a gifted gnat, I'd edit this to

Hashnode offers a blogging platform with optional ChatGPT 4.0. I tested the AI by prompting for an R script to create two new columns for each existing columns by splitting. The AI returned a code block that worked, although I applied a kludge for touch-up. It worked as well as first-year associate at a law firm, but at much lower cost.

I also checked out the SEO tool for suggested titles. I thought it did a great job at making clickbait. I guess that shouldn't be surprising.