View source: R/parseBotResponse.R
extractCode | R Documentation |
This function parses the agents answer and returns the text and code as single blocks. The results can be used for code execution and might be useful for displaying purposes later on.
extractCode(text, delimiter = "```")
text |
A character string containing the text with embedded code blocks. |
delimiter |
A character string representing the delimiter used to enclose the code blocks (default: "“'"). |
A list with two elements: 'code' and 'text'. 'code' contains the concatenated code blocks, and 'text' contains the remaining text with code blocks removed.
text <- "\n\nThe following, normalize the table and do PCA.
\n\n```\ndata <- read.table(\"test.txt\", header = TRUE, sep = \"\\t\")\n```"
result <- extractCode(text)
print(result$code)
print(result$text)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.