Skip to content

Commit 411f17b

Browse files
Add set.seed() before runif(), rnorm(), and rpois() (#4844)
1 parent 68987fb commit 411f17b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+46
-0
lines changed

R/aes-colour-fill-alpha.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
#'
8383
#' # For large datasets with overplotting the alpha
8484
#' # aesthetic will make the points more transparent.
85+
#' set.seed(1)
8586
#' df <- data.frame(x = rnorm(5000), y = rnorm(5000))
8687
#' p <- ggplot(df, aes(x,y))
8788
#' p + geom_point()

R/aes-position.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#'
6666
#' # You can also use geom_segment() to recreate plot(type = "h")
6767
#' # from base R:
68+
#' set.seed(1)
6869
#' counts <- as.data.frame(table(x = rpois(100, 5)))
6970
#' counts$x <- as.numeric(as.character(counts$x))
7071
#' with(counts, plot(x, Freq, type = "h", lwd = 10))

R/coord-transform.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#' geom_smooth(method = "lm")
6969
#'
7070
#' # Also works with discrete scales
71+
#' set.seed(1)
7172
#' df <- data.frame(a = abs(rnorm(26)),letters)
7273
#' plot <- ggplot(df,aes(a,letters)) + geom_point()
7374
#'

R/geom-boxplot.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#' \donttest{
9191
#' # It's possible to draw a boxplot with your own computations if you
9292
#' # use stat = "identity":
93+
#' set.seed(1)
9394
#' y <- rnorm(100)
9495
#' df <- data.frame(
9596
#' x = 1,

R/geom-point.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#'
7878
#' # geom_point warns when missing values have been dropped from the data set
7979
#' # and not plotted, you can turn this off by setting na.rm = TRUE
80+
#' set.seed(1)
8081
#' mtcars2 <- transform(mtcars, mpg = ifelse(runif(32) < 0.2, NA, mpg))
8182
#' ggplot(mtcars2, aes(wt, mpg)) +
8283
#' geom_point()

R/geom-polygon.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#' # Which seems like a lot of work, but then it's easy to add on
5151
#' # other features in this coordinate system, e.g.:
5252
#'
53+
#' set.seed(1)
5354
#' stream <- data.frame(
5455
#' x = cumsum(runif(50, max = 0.1)),
5556
#' y = cumsum(runif(50,max = 0.1))

R/geom-segment.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#' xlim(0.5, 2)
6262
#'
6363
#' # You can also use geom_segment to recreate plot(type = "h") :
64+
#' set.seed(1)
6465
#' counts <- as.data.frame(table(x = rpois(100,5)))
6566
#' counts$x <- as.numeric(as.character(counts$x))
6667
#' with(counts, plot(x, Freq, type = "h", lwd = 10))

R/geom-spoke.r

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#' @export
1111
#' @examples
1212
#' df <- expand.grid(x = 1:10, y=1:10)
13+
#'
14+
#' set.seed(1)
1315
#' df$angle <- runif(100, 0, 2*pi)
1416
#' df$speed <- runif(100, 0, sqrt(0.1 * df$x))
1517
#'

R/geom-tile.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#' \donttest{
4141
#' # Justification controls where the cells are anchored
4242
#' df <- expand.grid(x = 0:5, y = 0:5)
43+
#' set.seed(1)
4344
#' df$z <- runif(nrow(df))
4445
#' # default is compatible with geom_tile()
4546
#' ggplot(df, aes(x, y, fill = z)) +

R/limits.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#' # There are two ways of setting the axis limits: with limits or
5757
#' # with coordinate systems. They work in two rather different ways.
5858
#'
59+
#' set.seed(1)
5960
#' last_month <- Sys.Date() - 0:59
6061
#' df <- data.frame(
6162
#' date = last_month,

R/plot.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#' @examples
3939
#' # Generate some sample data, then compute mean and standard deviation
4040
#' # in each group
41+
#' set.seed(1)
4142
#' df <- data.frame(
4243
#' gp = factor(rep(letters[1:3], each = 10)),
4344
#' y = rnorm(30)

R/position-stack.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#' geom_histogram(binwidth = 500, position = "fill")
6060
#'
6161
#' # Stacking is also useful for time series
62+
#' set.seed(1)
6263
#' series <- data.frame(
6364
#' time = c(rep(1, 4),rep(2, 4), rep(3, 4), rep(4, 4)),
6465
#' type = rep(c('a', 'b', 'c', 'd'), 4),

R/quick-plot.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#' qplot(mpg, wt, data = mtcars, facets = vs ~ am)
3232
#'
3333
#' \donttest{
34+
#' set.seed(1)
3435
#' qplot(1:10, rnorm(10), colour = runif(10))
3536
#' qplot(1:10, letters[1:10])
3637
#' mod <- lm(mpg ~ wt, data = mtcars)

R/scale-continuous.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#'
4545
#' # Typically you'll pass a function to the `labels` argument.
4646
#' # Some common formats are built into the scales package:
47+
#' set.seed(1)
4748
#' df <- data.frame(
4849
#' x = rnorm(10) * 100000,
4950
#' y = seq(0, 1, length.out = 10)

R/scale-date.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#' @seealso [sec_axis()] for how to specify secondary axes
3535
#' @examples
3636
#' last_month <- Sys.Date() - 0:29
37+
#' set.seed(1)
3738
#' df <- data.frame(
3839
#' date = last_month,
3940
#' price = runif(30)

R/scale-gradient.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#' @rdname scale_gradient
2424
#' @export
2525
#' @examples
26+
#' set.seed(1)
2627
#' df <- data.frame(
2728
#' x = runif(100),
2829
#' y = runif(100),

R/scale-steps.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#' @family colour scales
2121
#' @export
2222
#' @examples
23+
#' set.seed(1)
2324
#' df <- data.frame(
2425
#' x = runif(100),
2526
#' y = runif(100),

R/stat-ecdf.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#' }
2727
#' @export
2828
#' @examples
29+
#' set.seed(1)
2930
#' df <- data.frame(
3031
#' x = c(rnorm(100, 0, 3), rnorm(100, 0, 10)),
3132
#' g = gl(2, 100)

R/stat-summary.r

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ summarise_by_x <- function(data, summary, ...) {
236236
#' @name hmisc
237237
#' @examples
238238
#' if (requireNamespace("Hmisc", quietly = TRUE)) {
239+
#' set.seed(1)
239240
#' x <- rnorm(100)
240241
#' mean_cl_boot(x)
241242
#' mean_cl_normal(x)
@@ -285,6 +286,7 @@ median_hilow <- wrap_hmisc("smedian.hilow")
285286
#' }
286287
#' @export
287288
#' @examples
289+
#' set.seed(1)
288290
#' x <- rnorm(100)
289291
#' mean_se(x)
290292
mean_se <- function(x, mult = 1) {

R/utilities-break.r

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#' table(cut_interval(1:100, 10))
1616
#' table(cut_interval(1:100, 11))
1717
#'
18+
#' set.seed(1)
19+
#'
1820
#' table(cut_number(runif(1000), 10))
1921
#'
2022
#' table(cut_width(runif(1000), 0.1))

man/aes_colour_fill_alpha.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/aes_position.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/coord_trans.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/cut_interval.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_boxplot.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_point.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_polygon.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_segment.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_spoke.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_tile.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ggplot.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/hmisc.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/lims.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mean_se.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/position_stack.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/qplot.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scale_continuous.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scale_date.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scale_gradient.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scale_steps.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/stat_ecdf.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)