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,

0 commit comments

Comments
 (0)