Skip to content

Commit 2786dcf

Browse files
committed
Remove iris data use
1 parent 714b884 commit 2786dcf

File tree

6 files changed

+30
-29
lines changed

6 files changed

+30
-29
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Suggests:
3838
htmlwidgets,
3939
mirai,
4040
nanoparquet,
41+
palmerpenguins,
4142
quarto,
4243
rapidoc,
4344
readr,

README.Rmd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,36 @@ function(msg) {
6767
)
6868
}
6969

70-
#* Plot out data from the iris dataset
70+
#* Plot out data from the palmer penguins dataset
7171
#*
7272
#* @get /plot
7373
#*
74-
#* @query spec:enum|setosa, versicolor, virginica| If provided, filter the
74+
#* @query spec:enum|Adelie, Chinstrap, Gentoo| If provided, filter the
7575
#* data to only this species
7676
#*
7777
#* @serializer png{width = 700, height = 500}
7878
#* @serializer jpeg{width = 700, height = 500}
7979
#*
8080
#* @async
8181
function(query) {
82-
myData <- iris
82+
myData <- palmerpenguins::penguins
8383
title <- "All Species"
8484

8585
# Filter if the species was specified
8686
if (!is.null(query$spec)){
8787
title <- paste0("Only the '", query$spec, "' Species")
88-
myData <- subset(iris, Species == query$spec)
88+
myData <- subset(myData, species == query$spec)
8989
if (nrow(myData) == 0) {
9090
abort_internal_error("Missing data for {query$spec}")
9191
}
9292
}
9393

9494
plot(
95-
myData$Sepal.Length,
96-
myData$Petal.Length,
95+
myData$flipper_length_mm,
96+
myData$bill_length_mm,
9797
main=title,
98-
xlab="Sepal Length",
99-
ylab="Petal Length"
98+
xlab="Flipper Length (mm)",
99+
ylab="Bill Length (mm)"
100100
)
101101
}
102102
```

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,36 @@ function(msg) {
5858
)
5959
}
6060

61-
#* Plot out data from the iris dataset
61+
#* Plot out data from the palmer penguins dataset
6262
#*
6363
#* @get /plot
6464
#*
65-
#* @query spec:enum|setosa, versicolor, virginica| If provided, filter the
65+
#* @query spec:enum|Adelie, Chinstrap, Gentoo| If provided, filter the
6666
#* data to only this species
6767
#*
6868
#* @serializer png{width = 700, height = 500}
6969
#* @serializer jpeg{width = 700, height = 500}
7070
#*
7171
#* @async
7272
function(query) {
73-
myData <- iris
73+
myData <- palmerpenguins::penguins
7474
title <- "All Species"
7575

7676
# Filter if the species was specified
7777
if (!is.null(query$spec)){
7878
title <- paste0("Only the '", query$spec, "' Species")
79-
myData <- subset(iris, Species == query$spec)
79+
myData <- subset(myData, species == query$spec)
8080
if (nrow(myData) == 0) {
8181
abort_internal_error("Missing data for {query$spec}")
8282
}
8383
}
8484

8585
plot(
86-
myData$Sepal.Length,
87-
myData$Petal.Length,
86+
myData$flipper_length_mm,
87+
myData$bill_length_mm,
8888
main=title,
89-
xlab="Sepal Length",
90-
ylab="Petal Length"
89+
xlab="Flipper Length (mm)",
90+
ylab="Bill Length (mm)"
9191
)
9292
}
9393
```

vignettes/files/apis/01-01-quickstart.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ function(msg) {
1010
)
1111
}
1212

13-
#* Plot out data from the iris dataset
13+
#* Plot out data from the palmer penguins dataset
1414
#*
1515
#* @get /plot
1616
#*
1717
#* @query spec:string If provided, filter the data to only this species
18-
#* (e.g. 'setosa')
18+
#* (e.g. 'Adelie')
1919
#*
2020
#* @serializer png
2121
#*
2222
function(query) {
23-
myData <- iris
23+
myData <- palmerpenguins::penguins
2424
title <- "All Species"
2525

2626
# Filter if the species was specified
2727
if (!is.null(query$spec)){
2828
title <- paste0("Only the '", query$spec, "' Species")
29-
myData <- subset(iris, Species == query$spec)
29+
myData <- subset(myData, species == query$spec)
3030
}
3131

3232
plot(
33-
myData$Sepal.Length,
34-
myData$Petal.Length,
33+
myData$flipper_length_mm,
34+
myData$bill_length_mm,
3535
main=title,
36-
xlab="Sepal Length",
37-
ylab="Petal Length"
36+
xlab="Flipper Length (mm)",
37+
ylab="Bill Length (mm)"
3838
)
3939
}

vignettes/plumber.qmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ res <- papi$test_request(req)
6666
code_chunk(res$body, "json")
6767
```
6868

69-
The `/plot` endpoint will show you a simple plot of some data from the iris dataset.
69+
The `/plot` endpoint will show you a simple plot of some data from the palmerpenguins dataset.
7070

7171
```{r}
7272
#| echo: false
@@ -81,18 +81,18 @@ If you see something like the above: congratulations! You've just created your f
8181

8282
## Specifying the Inputs
8383

84-
You may have noticed that the functions that define our endpoints accept parameters. These parameters allow us to customize the behavior of our endpoints. In the example above we use two different ways of specifying the outputs. For the `/echo/...` handler we take a variable part of the path and use this as an argument. You can see above that "test" is used in the resulting json object and had we provided a different path, e.g. `/echo/plumber` then "plumber" would have been used instead. In the other handler we rely on the "query string" to pass in an optional argument. If you visit <http://localhost:8080/plot?spec=setosa>, you should see a similar graph to the one you saw before, but now the dataset has been filtered to only include the "setosa" species in the iris dataset.
84+
You may have noticed that the functions that define our endpoints accept parameters. These parameters allow us to customize the behavior of our endpoints. In the example above we use two different ways of specifying the outputs. For the `/echo/...` handler we take a variable part of the path and use this as an argument. You can see above that "test" is used in the resulting json object and had we provided a different path, e.g. `/echo/plumber` then "plumber" would have been used instead. In the other handler we rely on the "query string" to pass in an optional argument. If you visit <http://localhost:8080/plot?spec=Adelie>, you should see a similar graph to the one you saw before, but now the dataset has been filtered to only include the "Adelie" species in the palmerpenguins dataset.
8585

8686
```{r}
8787
#| echo: false
8888
#| results: asis
89-
req <- fiery::fake_request("http://localhost:8080/plot?spec=setosa")
89+
req <- fiery::fake_request("http://localhost:8080/plot?spec=Adelie")
9090
res <- papi$test_request(req)
9191
9292
cat('<img src="data:image/png;base64,', base64enc::base64encode(res$body), '">')
9393
```
9494

95-
As you might have guessed, the `spec=setosa` portion of the URL sets the `spec` element in `query` to `setosa`. More details on how Plumber processes inputs are available in the [Routing & Input article](./routing-and-input.html).
95+
As you might have guessed, the `spec=Adelie` portion of the URL sets the `spec` element in `query` to `Adelie`. More details on how Plumber processes inputs are available in the [Routing & Input article](./routing-and-input.html).
9696

9797
## Customizing The Output
9898

vignettes/routing-and-input.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ The following details the mapping of the scalar type names that you can use in y
346346

347347
You can also specify any of the above as an array, by enclosing it in `[...]`, (e.g. `[integer]` for an array of integers). Arrays can even be nested (e.g. `[[integer]]` for an array of arrays of integers).
348348

349-
Lastly, it is possible to specify "object", which will be cast to lists in R. The syntax for this is `{name:Type, ...}` and allows you to provide concise specifications for very complex data structures (e.g. the specification for the iris dataset is `{Sepal.Length:number,Sepal.Width:number,Petal.Length:number,Petal.Width:number,Species:string}`. It is unlikely that you'll need objects for path and query parameters, but request bodies will often be in the form of an object.
349+
Lastly, it is possible to specify "object", which will be cast to lists in R. The syntax for this is `{name:Type, ...}` (e.g. `{eruptions:[number], waiting:[number]}` for the `faithful` dataset) and allows you to provide concise specifications for very complex data structures. It is unlikely that you'll need objects for path and query parameters, but request bodies will often be in the form of an object.
350350

351351
### Defaults
352352

0 commit comments

Comments
 (0)