Skip to content

Commit 005bcc8

Browse files
committed
updates for chapter 12
1 parent 98492c4 commit 005bcc8

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"activeTab": 1
2+
"activeTab": 2
33
}

Chapter12/plumber_api.R

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
1-
# plumber and Excel
2-
31
#* Plot out data from a random normal distribution
4-
#* @param .mean The mean of the standard normal deviation
2+
#* @param .mean The mean of the standard normal distribution
53
#* @get /plot
64
#* @serializer png
75
function(.mean) {
86
mu <- as.numeric(.mean)
97
hist(rnorm(n = 1000, mean = mu, sd = 1))
10-
}
11-
12-
#* Plot out data from the iris dataset
13-
#* @param spec If provided, filter the data to only this species (e.g. 'setosa')
14-
#* @get /irisplot
15-
#* @serializer png
16-
function(spec){
17-
myData <- iris
18-
title <- "All Species"
19-
20-
# Filter if the species was specified
21-
if (!missing(spec)){
22-
title <- paste0("Only the '", spec, "' Species")
23-
myData <- subset(iris, Species == spec)
24-
}
25-
26-
plot(myData$Sepal.Length, myData$Petal.Length,
27-
main=title, xlab="Sepal Length", ylab="Petal Length")
288
}

0 commit comments

Comments
 (0)