Skip to content

Commit 928a6bf

Browse files
committed
tidy column length on examples
1 parent 06b8ea9 commit 928a6bf

20 files changed

+116
-88
lines changed

R/AddPoints.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
#' quantile.breaks = TRUE, add = FALSE)
131131
#'
132132
#' z <- as.factor(rep(c("dog", "cat", "ant", "pig", "bat"),
133-
#' length.out = n))
133+
#' length.out = n))
134134
#' bg <- GetColors(nlevels(z), scheme = "bright", alpha = 0.8)
135135
#' AddPoints(x, z = z, bg = bg, add = FALSE)
136136
#'

R/FindOptimalSubset.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@
113113
#' }
114114
#' \dontrun{
115115
#' out <- FindOptimalSubset(n, k, Fitness, numbers, run = 10,
116-
#' monitor = GA::gaislMonitor,
117-
#' seed = seed)
116+
#' monitor = GA::gaislMonitor, seed = seed)
118117
#' plot(out[["ga_output"]])
119118
#' summary(out[["ga_output"]])
120119
#' print(out[["solution"]])

R/GetRegionOfInterest.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@
5454
#' r <- sqrt(stats::runif(n, 0.25^2, 0.50^2))
5555
#' x <- sp::SpatialPoints(cbind(0.5 + r * cos(theta), 0.5 + r * sin(theta)),
5656
#' proj4string = sp::CRS("+init=epsg:32610"))
57-
#' sp::plot(GetRegionOfInterest(x, alpha = 0.1, width = 0.05), col = "green")
58-
#' sp::plot(GetRegionOfInterest(x, alpha = 0.1), col = "yellow", add = TRUE)
57+
#' sp::plot(GetRegionOfInterest(x, alpha = 0.1, width = 0.05),
58+
#' col = "green")
59+
#' sp::plot(GetRegionOfInterest(x, alpha = 0.1),
60+
#' col = "yellow", add = TRUE)
5961
#' sp::plot(x, add = TRUE)
6062
#' }
6163
#'

R/Grid2Polygons.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@
123123
#' m <- m[nrow(m):1, ncol(m):1]
124124
#' x <- seq(from = 2667405, length.out = ncol(m), by = 10)
125125
#' y <- seq(from = 6478705, length.out = nrow(m), by = 10)
126-
#' r <- raster::raster(m, xmn = min(x), xmx = max(x), ymn = min(y), ymx = max(y),
127-
#' crs = "+init=epsg:27200")
126+
#' r <- raster::raster(m, xmn = min(x), xmx = max(x), ymn = min(y),
127+
#' ymx = max(y), crs = "+init=epsg:27200")
128128
#' plys <- Grid2Polygons(r, level = TRUE)
129129
#' cols <- GetColors(length(plys), scheme = "DEM screen")
130130
#' sp::plot(plys, col = cols, border = "#515151")

R/PlotCrossSection.R

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,20 @@
8080
#' m <- m[nrow(m):1, ncol(m):1]
8181
#' x <- seq(from = 2667405, length.out = ncol(m), by = 10)
8282
#' y <- seq(from = 6478705, length.out = nrow(m), by = 10)
83-
#' r1 <- raster::raster(m, xmn = min(x), xmx = max(x), ymn = min(y), ymx = max(y),
84-
#' crs = "+init=epsg:27200")
83+
#' r1 <- raster::raster(m, xmn = min(x), xmx = max(x), ymn = min(y),
84+
#' ymx = max(y), crs = "+init=epsg:27200")
8585
#' r2 <- min(r1[]) - r1 / 10
8686
#' r3 <- r1 - r2
8787
#' rs <- raster::stack(r1, r2, r3)
8888
#' names(rs) <- c("r1", "r2", "r3")
89-
#' xy <- rbind(c(2667508, 6479501), c(2667803, 6479214), c(2667508, 6478749))
90-
#' transect <- sp::SpatialLines(list(sp::Lines(list(sp::Line(xy)), ID = "Transect")),
89+
#' xy <- rbind(c(2667508, 6479501),
90+
#' c(2667803, 6479214),
91+
#' c(2667508, 6478749))
92+
#' transect <- sp::Lines(list(sp::Line(xy)), ID = "Transect")
93+
#' transect <- sp::SpatialLines(list(transect),
9194
#' proj4string = raster::crs(rs))
92-
#' xy <- rbind(c(2667705, 6478897), c(2667430, 6479178))
95+
#' xy <- rbind(c(2667705, 6478897),
96+
#' c(2667430, 6479178))
9397
#' p <- sp::SpatialPoints(xy, proj4string = raster::crs(rs))
9498
#' d <- data.frame("label" = c("Peak", "Random"))
9599
#' features <- sp::SpatialPointsDataFrame(p, d, match.ID = TRUE)
@@ -98,10 +102,13 @@
98102
#' PlotMap(r1, bg.image = bg.image,
99103
#' pal = GetColors(scheme = "DEM screen", alpha = 0.8),
100104
#' scale.loc = "top", arrow.loc = "topright",
101-
#' contour.lines = list("col" = "#1F1F1FA6"), "useRaster" = TRUE)
105+
#' contour.lines = list("col" = "#1F1F1FA6"),
106+
#' useRaster = TRUE)
102107
#' lines(transect)
103-
#' raster::text(as(transect, "SpatialPoints"), labels = c("A", "BEND", "A'"),
104-
#' halo = TRUE, cex = 0.7, pos = c(3, 4, 1), offset = 0.1, font = 4)
108+
#' raster::text(as(transect, "SpatialPoints"),
109+
#' labels = c("A", "BEND", "A'"),
110+
#' halo = TRUE, cex = 0.7, pos = c(3, 4, 1),
111+
#' offset = 0.1, font = 4)
105112
#' points(features, pch = 19)
106113
#' raster::text(features, labels = features@data$label, halo = TRUE,
107114
#' cex = 0.7, pos = 4, offset = 0.5, font = 4)
@@ -110,16 +117,18 @@
110117
#' asp <- 5
111118
#' unit <- "METERS"
112119
#' explanation <- "Vertical thickness between layers, in meters."
113-
#' PlotCrossSection(transect, rs, geo.lays = c("r1", "r2"), val.lays = "r3",
114-
#' ylab = "Elevation", asp = asp, unit = unit,
115-
#' explanation = explanation, features = features,
116-
#' max.feature.dist = 100, bg.col = "#E1E1E1",
117-
#' bend.label = "BEND IN\nSECTION", scale.loc = NULL)
120+
#' PlotCrossSection(transect, rs, geo.lays = c("r1", "r2"),
121+
#' val.lays = "r3", ylab = "Elevation", asp = asp,
122+
#' unit = unit, explanation = explanation,
123+
#' features = features, max.feature.dist = 100,
124+
#' bg.col = "#E1E1E1", bend.label = "BEND IN\nSECTION",
125+
#' scale.loc = NULL)
118126
#' AddScaleBar(unit = unit, vert.exag = asp, inset = 0.05)
119127
#'
120-
#' val <- PlotCrossSection(transect, rs, geo.lays = c("r1", "r2"), val.lays = "r3",
121-
#' ylab = "Elevation", asp = 5, unit = "METERS",
122-
#' explanation = explanation, file = "Rplots.png")
128+
#' val <- PlotCrossSection(transect, rs, geo.lays = c("r1", "r2"),
129+
#' val.lays = "r3", ylab = "Elevation", asp = 5,
130+
#' unit = "METERS", explanation = explanation,
131+
#' file = "Rplots.png")
123132
#' print(val)
124133
#'
125134
#' graphics.off()

R/PlotGraph.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@
105105
#' scientific = FALSE, conversion.factor = 3.28)
106106
#'
107107
#' y <- data.frame(lapply(1:3, function(i) sample(n, replace = TRUE)))
108-
#' PlotGraph(x, y, ylab = "Random number", pch = 1, seq.date.by = "days",
109-
#' scientific = TRUE)
108+
#' PlotGraph(x, y, ylab = "Random number", pch = 1,
109+
#' seq.date.by = "days", scientific = TRUE)
110110
#'
111-
#' y <- sapply(1:3, function(i) sample((1:100) + i * 100, n, replace = TRUE))
111+
#' y <- sapply(1:3, function(i) {
112+
#' sample((1:100) + i * 100, n, replace = TRUE)
113+
#' })
112114
#' m <- cbind(as.numeric(x), y)
113115
#' col <- GetColors(3, scheme = "bright")
114116
#' PlotGraph(m, xlab = "Number", ylab = "Random number", type = "b",

R/PlotMap.R

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
#' r[51:100] <- 2L
152152
#' r[3:6, 1:5] <- 8L
153153
#' r <- raster::ratify(r)
154-
#' rat <- cbind(raster::levels(r)[[1]], land.cover = c("Pine", "Oak", "Meadow"))
154+
#' rat <- cbind(raster::levels(r)[[1]],
155+
#' land.cover = c("Pine", "Oak", "Meadow"))
155156
#' levels(r) <- rat
156157
#' PlotMap(r)
157158
#'
@@ -160,23 +161,26 @@
160161
#' sp::proj4string(meuse.grid) <- sp::CRS("+init=epsg:28992")
161162
#' sp::gridded(meuse.grid) <- TRUE
162163
#' meuse.grid <- raster::raster(meuse.grid, layer = "soil")
163-
#' model <- gstat::gstat(id = "zinc", formula = zinc~1, locations = ~x+y, data = meuse)
164+
#' model <- gstat::gstat(id = "zinc", formula = zinc~1,
165+
#' locations = ~x+y, data = meuse)
164166
#' r <- raster::interpolate(meuse.grid, model)
165167
#' r <- raster::mask(r, meuse.grid)
166168
#' Pal <- function(n) GetColors(n, stops=c(0.3, 0.9))
167169
#' breaks <- seq(0, 2000, by = 200)
168170
#' credit <- paste("Data collected in a flood plain of the river Meuse,",
169171
#' "near the village of Stein (Netherlands),",
170-
#' "\nand iterpolated on a grid with 40-meter by 40-meter spacing",
172+
#' "\nand iterpolated on a grid with 40m by 40m spacing",
171173
#' "using inverse distance weighting.")
172-
#' PlotMap(r, breaks = breaks, pal = Pal, dms.tick = TRUE, bg.lines = TRUE,
173-
#' contour.lines = list("col" = "#1F1F1F"), credit = credit,
174-
#' draw.key = FALSE, simplify = 0)
175-
#' AddScaleBar(unit = c("KILOMETER", "MILES"), conv.fact = c(0.001, 0.000621371),
174+
#' PlotMap(r, breaks = breaks, pal = Pal, dms.tick = TRUE,
175+
#' bg.lines = TRUE, contour.lines = list("col" = "#1F1F1F"),
176+
#' credit = credit, draw.key = FALSE, simplify = 0)
177+
#' AddScaleBar(unit = c("KILOMETER", "MILES"),
178+
#' conv.fact = c(0.001, 0.000621371),
176179
#' loc = "bottomright", inset = c(0.1, 0.05))
177180
#' AddGradientLegend(breaks, Pal, at = breaks,
178-
#' title = "Topsoil zinc\nconcentration\n(ppm)", loc = "topleft",
179-
#' inset = c(0.05, 0.1), strip.dim = c(2, 20))
181+
#' title = "Topsoil zinc\nconcentration\n(ppm)",
182+
#' loc = "topleft", inset = c(0.05, 0.1),
183+
#' strip.dim = c(2, 20))
180184
#'
181185
#' m <- datasets::volcano
182186
#' m <- m[nrow(m):1, ncol(m):1]

R/PrintPackageHelp.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
#' " toc_float: true",
4343
#' "---",
4444
#' sep = "\n", file = "test-help.Rmd")
45-
#' PrintPackageHelp("inlmisc", file = "test-help.Rmd",
46-
#' toc = TRUE, title_to_name = TRUE,
47-
#' notrun = FALSE)
45+
#' PrintPackageHelp("inlmisc", file = "test-help.Rmd", toc = TRUE,
46+
#' title_to_name = TRUE, notrun = FALSE)
4847
#' rmarkdown::render("test-help.Rmd")
4948
#' url <- file.path("file:/", getwd(), "test-help.html")
5049
#' utils::browseURL(url)

R/PrintTable.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@
7171
#' digits <- c(0, 1, 1, 1, 1)
7272
#' title <- "Measurements of sepal length and width and petal
7373
#' length and width for three species of Iris flower."
74-
#' headnotes <- "\\textbf{Species of Iris}: includes setosa, versicolor, and virginica.
74+
#' headnotes <- "\\textbf{Iris Species}: setosa, versicolor, and virginica.
7575
#' \\textbf{Abbreviations}: cm, centimeters"
7676
#' levels(d[[1]]) <- sprintf("%s\\footnotemark[%d]", levels(d[[1]]), 1:3)
77-
#' footnotes <- paste(sprintf("\\footnotemark[%d] Common name is %s iris.", 1:3,
78-
#' c("Wild Flag", "Blue Flag", "Virginia")),
79-
#' collapse = "\\\\")
77+
#' footnotes <- sprintf("\\footnotemark[%d] Common name is %s iris.",
78+
#' 1:3, c("Wild Flag", "Blue Flag", "Virginia"))
79+
#' footnotes <- paste(footnotes, collapse = "\\\\")
8080
#' hline <- utils::tail(which(!duplicated(d[[1]])), -1) - 1L
8181
#' PrintTable(d, colheadings, align, digits, title = title,
8282
#' headnotes = headnotes, footnotes = footnotes,

R/ReadCodeChunks.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#' @export
2424
#'
2525
#' @examples
26-
#' file <- system.file("misc/knitr-markdown.Rmd",
27-
#' package = "inlmisc")
26+
#' file <- system.file("misc/knitr-markdown.Rmd", package = "inlmisc")
2827
#' chunks <- ReadCodeChunks(file)
2928
#' print(chunks)
3029
#' attr(chunks, "path")

0 commit comments

Comments
 (0)