Skip to content

Commit d8eb945

Browse files
fix some lints (#6050)
1 parent 633e350 commit d8eb945

40 files changed

+85
-85
lines changed

R/annotation-logticks.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
165165

166166
names(xticks)[names(xticks) == "value"] <- x_name # Rename to 'x' for coordinates$transform
167167
xticks <- coord$transform(xticks, panel_params)
168-
xticks = xticks[xticks$x <= 1 & xticks$x >= 0,]
168+
xticks <- xticks[xticks$x <= 1 & xticks$x >= 0,]
169169

170170
if (outside)
171171
xticks$end = -xticks$end
@@ -203,7 +203,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
203203

204204
names(yticks)[names(yticks) == "value"] <- y_name # Rename to 'y' for coordinates$transform
205205
yticks <- coord$transform(yticks, panel_params)
206-
yticks = yticks[yticks$y <= 1 & yticks$y >= 0,]
206+
yticks <- yticks[yticks$y <= 1 & yticks$y >= 0,]
207207

208208
if (outside)
209209
yticks$end = -yticks$end
@@ -238,7 +238,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
238238
# - start: on the other axis, start position of the line (usually 0)
239239
# - end: on the other axis, end position of the line (for example, .1, .2, or .3)
240240
calc_logticks <- function(base = 10, ticks_per_base = base - 1,
241-
minpow = 0, maxpow = minpow + 1, start = 0, shortend = .1, midend = .2, longend = .3) {
241+
minpow = 0, maxpow = minpow + 1, start = 0, shortend = 0.1, midend = 0.2, longend = 0.3) {
242242

243243
# Number of blocks of tick marks
244244
reps <- maxpow - minpow

R/bin.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ bin_vector <- function(x, bins, weight = NULL, pad = FALSE) {
165165
}
166166

167167
# Add row for missings
168-
if (any(is.na(bins))) {
168+
if (anyNA(bins)) {
169169
bin_count <- c(bin_count, sum(is.na(bins)))
170170
bin_widths <- c(bin_widths, NA)
171171
bin_x <- c(bin_x, NA)

R/compat-plyr.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ rename <- function(x, replace) {
5454
id_var <- function(x, drop = FALSE) {
5555
if (length(x) == 0) {
5656
id <- integer()
57-
n = 0L
57+
n <- 0L
5858
} else if (!is.null(attr(x, "n")) && !drop) {
5959
return(x)
6060
} else if (is.factor(x) && !drop) {
6161
x <- addNA(x, ifany = TRUE)
6262
id <- as.integer(x)
63-
n <- length(levels(x))
63+
n <- nlevels(x)
6464
} else {
6565
levels <- sort(unique0(x), na.last = TRUE)
6666
id <- match(x, levels)

R/coord-polar.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ CoordPolar <- ggproto("CoordPolar", Coord,
137137
ret[[n]]$sec.labels <- out$sec.labels
138138
}
139139

140-
details = list(
140+
details <- list(
141141
x.range = ret$x$range, y.range = ret$y$range,
142142
x.major = ret$x$major, y.major = ret$y$major,
143143
x.minor = ret$x$minor, y.minor = ret$y$minor,

R/coord-sf.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ sf_rescale01 <- function(x, x_range, y_range) {
416416

417417
# different limits methods
418418
calc_limits_bbox <- function(method, xlim, ylim, crs, default_crs) {
419-
if (any(!is.finite(c(xlim, ylim))) && method != "geometry_bbox") {
419+
if (!all(is.finite(c(xlim, ylim))) && method != "geometry_bbox") {
420420
cli::cli_abort(c(
421421
"Scale limits cannot be mapped onto spatial coordinates in {.fn coord_sf}.",
422422
"i" = "Consider setting {.code lims_method = \"geometry_bbox\"} or {.code default_crs = NULL}."
@@ -585,7 +585,7 @@ coord_sf <- function(xlim = NULL, ylim = NULL, expand = TRUE,
585585
}
586586

587587
parse_axes_labeling <- function(x) {
588-
labs = unlist(strsplit(x, ""))
588+
labs <- unlist(strsplit(x, ""))
589589
list(top = labs[1], right = labs[2], bottom = labs[3], left = labs[4])
590590
}
591591

R/facet-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ find_panel <- function(table) {
678678
}
679679
#' @rdname find_panel
680680
#' @export
681-
panel_cols = function(table) {
681+
panel_cols <- function(table) {
682682
panels <- table$layout[grepl("^panel", table$layout$name), , drop = FALSE]
683683
unique0(panels[, c('l', 'r')])
684684
}

R/facet-grid-.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ FacetGrid <- ggproto("FacetGrid", Facet,
319319
if (length(missing_facets) > 0) {
320320
to_add <- unique0(layout[missing_facets])
321321

322-
data_rep <- rep.int(1:nrow(data), nrow(to_add))
323-
facet_rep <- rep(1:nrow(to_add), each = nrow(data))
322+
data_rep <- rep.int(seq_len(nrow(data)), nrow(to_add))
323+
facet_rep <- rep(seq_len(nrow(to_add)), each = nrow(data))
324324

325325
data <- unrowname(data[data_rep, , drop = FALSE])
326326
facet_vals <- unrowname(vec_cbind(

R/facet-wrap.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ FacetWrap <- ggproto("FacetWrap", Facet,
242242

243243
to_add <- unique0(layout[missing_facets])
244244

245-
data_rep <- rep.int(1:nrow(data), nrow(to_add))
246-
facet_rep <- rep(1:nrow(to_add), each = nrow(data))
245+
data_rep <- rep.int(seq_len(nrow(data)), nrow(to_add))
246+
facet_rep <- rep(seq_len(nrow(to_add)), each = nrow(data))
247247

248248
data <- data[data_rep, , drop = FALSE]
249249
facet_vals <- vec_cbind(

R/fortify-spatial.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fortify.Polygons <- function(model, data, ...) {
7171
})
7272
pieces <- vec_rbind0(!!!pieces)
7373

74-
pieces$order <- 1:nrow(pieces)
74+
pieces$order <- seq_len(nrow(pieces))
7575
pieces$id <- model@ID
7676
pieces$piece <- factor(pieces$piece)
7777
pieces$group <- interaction(pieces$id, pieces$piece)
@@ -89,7 +89,7 @@ fortify.Polygon <- function(model, data, ...) {
8989

9090
df <- as.data.frame(model@coords)
9191
names(df) <- c("long", "lat")
92-
df$order <- 1:nrow(df)
92+
df$order <- seq_len(nrow(df))
9393
df$hole <- model@hole
9494
df
9595
}
@@ -124,7 +124,7 @@ fortify.Lines <- function(model, data, ...) {
124124
})
125125
pieces <- vec_rbind0(!!!pieces)
126126

127-
pieces$order <- 1:nrow(pieces)
127+
pieces$order <- seq_len(nrow(pieces))
128128
pieces$id <- model@ID
129129
pieces$piece <- factor(pieces$piece)
130130
pieces$group <- interaction(pieces$id, pieces$piece)
@@ -142,7 +142,7 @@ fortify.Line <- function(model, data, ...) {
142142

143143
df <- as.data.frame(model@coords)
144144
names(df) <- c("long", "lat")
145-
df$order <- 1:nrow(df)
145+
df$order <- seq_len(nrow(df))
146146
df
147147
}
148148

R/geom-dotplot.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,25 +197,25 @@ GeomDotplot <- ggproto("GeomDotplot", Geom,
197197

198198
# Set up the stacking function and range
199199
if (is.null(params$stackdir) || params$stackdir == "up") {
200-
stackdots <- function(a) a - .5
200+
stackdots <- function(a) a - 0.5
201201
stackaxismin <- 0
202202
stackaxismax <- 1
203203
} else if (params$stackdir == "down") {
204-
stackdots <- function(a) -a + .5
204+
stackdots <- function(a) -a + 0.5
205205
stackaxismin <- -1
206206
stackaxismax <- 0
207207
} else if (params$stackdir == "center") {
208208
stackdots <- function(a) a - 1 - max(a - 1) / 2
209-
stackaxismin <- -.5
210-
stackaxismax <- .5
209+
stackaxismin <- -0.5
210+
stackaxismax <- 0.5
211211
} else if (params$stackdir == "centerwhole") {
212212
stackdots <- function(a) a - 1 - floor(max(a - 1) / 2)
213-
stackaxismin <- -.5
214-
stackaxismax <- .5
213+
stackaxismin <- -0.5
214+
stackaxismax <- 0.5
215215
}
216216

217217
# Fill the bins: at a given x (or y), if count=3, make 3 entries at that x
218-
data <- data[rep(1:nrow(data), data$count), ]
218+
data <- data[rep(seq_len(nrow(data)), data$count), ]
219219

220220
# Next part will set the position of each dot within each stack
221221
# If stackgroups=TRUE, split only on x (or y) and panel; if not stacking, also split by group
@@ -231,7 +231,7 @@ GeomDotplot <- ggproto("GeomDotplot", Geom,
231231

232232
# Within each x, or x+group, set countidx=1,2,3, and set stackpos according to stack function
233233
data <- dapply(data, plyvars, function(xx) {
234-
xx$countidx <- 1:nrow(xx)
234+
xx$countidx <- seq_len(nrow(xx))
235235
xx$stackpos <- stackdots(xx$countidx)
236236
xx
237237
})
@@ -281,11 +281,11 @@ GeomDotplot <- ggproto("GeomDotplot", Geom,
281281
binaxis <- ifelse(binaxis == "x", "y", "x")
282282

283283
if (binaxis == "x") {
284-
stackaxis = "y"
284+
stackaxis <- "y"
285285
dotdianpc <- dotsize * tdata$binwidth[1] / (max(panel_params$x.range) - min(panel_params$x.range))
286286

287287
} else if (binaxis == "y") {
288-
stackaxis = "x"
288+
stackaxis <- "x"
289289
dotdianpc <- dotsize * tdata$binwidth[1] / (max(panel_params$y.range) - min(panel_params$y.range))
290290
}
291291

0 commit comments

Comments
 (0)