Spaces:
Sleeping
Sleeping
File size: 3,414 Bytes
8f7fb71 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
make_plot_prompt <- '
Runs R code to make a plot with base R graphics.
Args:
code: R code to run
Returns:
Binary image data
Details:
`code` should be R code that begins with e.g. `png(filename)` and ends with `dev.off()`.
Always use the variable `filename` instead of an actual file name.
Example: User requests "Plot x (1,2,3) and y (10,20,30)", then `code` is:
png(filename)
x <- c(1, 2, 3)
y <- c(10, 20, 30)
plot(x, y)
dev.off()
Example: User requests "Give me a 8.5x11 inch PDF of y = x^2 from -1 to 1, large font, titled with the function", then `code` is:
pdf(filename, width = 8.5, height = 11)
par(cex = 2)
x <- seq(-1, 1, length.out = 100)
y <- x^2
plot(x, y, type = "l")
title(main = quote(y == x^2))
dev.off()
Example: User requests "Plot radius_worst (y) vs radius_mean (x) from https://zenodo.org/records/3608984/files/breastcancer.csv?download=1", then `code` is:
png(filename)
df <- read.csv("https://zenodo.org/records/3608984/files/breastcancer.csv?download=1")
plot(df$radius_mean, df$radius_worst, xlab = "radius_worst", ylab = "radius_mean")
dev.off()
Example: User requests "Plot radius_worst (y) vs radius_mean (x)" and [Uploaded File: "/tmp/uploads/breast-cancer.csv"], then `code` is:
png(filename)
df <- read.csv("/tmp/uploads/breast-cancer.csv")
plot(df$radius_mean, df$radius_worst, xlab = "radius_worst", ylab = "radius_mean")
dev.off()
'
make_ggplot_prompt <- '
Runs R code to make a plot with ggplot/ggplot2.
Args:
code: R code to run
Returns:
Binary image data
Details:
`code` should be R code that begins with `library(ggplot2)` and ends with `ggsave(filename, device = "png")`.
Example: User requests "ggplot wt vs mpg from mtcars", then `code` is:
library(ggplot2)
ggplot(mtcars, aes(mpg, wt)) +
geom_point()
ggsave(filename, device = "png")
Example: User requests "ggplot wt vs mpg from mtcars as pdf", then `code` is:
library(ggplot2)
ggplot(mtcars, aes(mpg, wt)) +
geom_point()
ggsave(filename, device = "pdf")
Important notes:
- `code` must end with ggsave(filename, device = ) with a specified device.
- Use `device = "png"` unless the user requests a different format.
- Always use the variable `filename` instead of an actual file name.
'
help_topic_prompt <- '
Gets documentation for a dataset, function, or other topic.
Args:
topic: Topic or function to get help for.
Returns:
Documentation text. May include runnable R examples.
Examples:
- Show the arguments of the `lm` function: help_topic("lm").
- Show the format of the `airquality` dataset: help_topic("airquality").
- Get variables in `Titanic`: help_topic("Titanic").
'
help_package_prompt <- '
Summarizes datasets and functions in an R package.
Args:
package: Package to get help for.
Returns:
Documentation text. Includes a package description and index of functions and datasets.
Examples:
- Get the names of R datasets: help_package("datasets").
- List graphics functions in base R: help_package("graphics").
'
run_visible_prompt <- '
Runs R code and returns the result.
Does not make plots.
Args:
code: R code to run.
Returns:
Result of R code execution.
'
run_hidden_prompt <- '
Run R code without returning the result.
Does not make plots.
Args:
code: R code to run.
Returns:
Nothing.
NOTE: Choose this tool if:
- The user asks to save the result in a variable, or
- You are performing intermediate calculations before making a plot.
'
|