Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkenwg committed Sep 11, 2024
1 parent 0beab1a commit 384c449
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion R/add-blk-to-lon-lat.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fwa_add_blk_to_lon_lat <- function(x, tolerance = 5000, limit = 1,

x |>
dplyr::as_tibble() |>
dplyr::mutate(..fwa_id = 1:dplyr::n()) |>
dplyr::mutate(..fwa_id = seq_len(dplyr::n())) |>
group_split_sf(.data$..fwa_id) |>
lapply(add_blk_to_lon_lat, tolerance = tolerance, limit = limit, epsg = epsg, nocache = nocache) |>
dplyr::bind_rows() |>
Expand Down
2 changes: 1 addition & 1 deletion R/add-collection-to-polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fwa_add_collection_to_polygon <- function(

x <- x |>
dplyr::mutate(
..fwa_id = 1:dplyr::n(),
..fwa_id = seq_len(dplyr::n()),
..fwa_intersect = intersect
) |>
group_split_sf(.data$..fwa_id) |>
Expand Down
2 changes: 1 addition & 1 deletion R/add-gm-elevation-to-point.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fwa_add_gm_elevation_to_point <- function(x, chunk_size = 300L, digits = 7,
return(x)
}

x$..fwa_chunk <- 1:nrow(x) %/% chunk_size
x$..fwa_chunk <- seq_len(nrow(x)) %/% chunk_size

x |>
group_split_sf(.data$..fwa_chunk) |>
Expand Down
2 changes: 1 addition & 1 deletion R/add-rms-to-blk.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fwa_add_rms_to_blk <- function(
..fwa_interval = interval,
..fwa_start = start,
..fwa_end = end,
..fwa_id = 1:dplyr::n()
..fwa_id = seq_len(dplyr::n())
) |>
group_split_sf(.data$blk) |>
lapply(add_rms_to_blk, epsg = epsg, nocache = nocache) |>
Expand Down
2 changes: 1 addition & 1 deletion R/add-watershed-to-blk.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fwa_add_watershed_to_blk <- function(x,
dplyr::as_tibble() |>
dplyr::mutate(
..fwa_exclude = exclude,
..fwa_id = 1:dplyr::n()
..fwa_id = seq_len(dplyr::n())
) |>
group_split_sf(.data$blk) |>
lapply(add_watershed_to_blk, epsg = epsg, nocache = nocache) |>
Expand Down
2 changes: 1 addition & 1 deletion R/convert-stream-network-to-rms.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fwa_convert_stream_network_to_rms <- function(x, interval = 5, tolerance = 0.1)

x |>
add_parent_blk_rm() |>
dplyr::mutate(..fwa_id = 1:dplyr::n()) |>
dplyr::mutate(..fwa_id = seq_len(dplyr::n())) |>
group_split_sf(.data$..fwa_id) |>
lapply(convert_stream_segment_to_rms, interval = interval) |>
dplyr::bind_rows() |>
Expand Down
2 changes: 1 addition & 1 deletion R/snap-rm-to-point.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fwa_snap_rm_to_point <- function(x, rm, ...) {
dplyr::select(rm, "blk", "rm", ...)

x |>
dplyr::mutate(..fwa_id = 1:dplyr::n()) |>
dplyr::mutate(..fwa_id = seq_len(dplyr::n())) |>
group_split_sf(.data$blk, ...) |>
lapply(snap_rm_to_point, rm = rm) |>
dplyr::bind_rows() |>
Expand Down
6 changes: 3 additions & 3 deletions R/snap-rm-to-rms.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ reallocate_blocks <- function(x, rms) {
if (!nrow(df)) return(x)

xrev <- x
for (i in nrow(df):1) {
for (i in rev(seq_len(nrow(df)))) {
xrev <- interpolate_block(xrev, start = df$start[i], end = df$end[i])
}
for (i in 1:nrow(df)) {
for (i in seq_len(nrow(df))) {
x <- interpolate_block(x, start = df$start[i], end = df$end[i])
indices <- df$start[i]:df$end[i]
x$rm[indices] <- pmean(x$rm[indices], xrev$rm[indices])
Expand Down Expand Up @@ -255,7 +255,7 @@ fwa_snap_rm_to_rms <- function(x, rm, snap_mouths = FALSE) {

x |>
dplyr::arrange("blk", "rm") |>
dplyr::mutate(..fwa_id = 1:dplyr::n()) |>
dplyr::mutate(..fwa_id = seq_len(dplyr::n())) |>
dplyr::rename(
..fwa_provided_new_rm = "new_rm",
..fwa_x_rm = "rm"
Expand Down
2 changes: 1 addition & 1 deletion R/snap-rms-to-rms.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ resolve_multijoins <- function(rm) {

prev_new_rm <- 0
rm$..fwa_keep <- TRUE
for (i in 1:nrow(df)) {
for (i in seq_len(nrow(df))) {
indices <- df$start[i]:df$end[i]
rm[indices, ] <- select_closest(rm[indices, ], prev_new_rm)
prev_new_rm <- rm$new_rm[indices][rm$..fwa_keep[indices]]
Expand Down
8 changes: 4 additions & 4 deletions R/swap-branches-rms.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parent_blk <- function(x, blk, defined = FALSE, trib = NA) {
if (length(x) > 1) {
abort_chk("`parent_blk` is inconsistent for blk ", blk, " in `x`")
}
if (defined & is.na(x)) {
if (defined && is.na(x)) {
abort_chk("`parent_blk` is undefined for blk ", blk, " in `x`")
}
x
Expand All @@ -34,7 +34,7 @@ parent_rm <- function(x, blk, defined = FALSE, trib = NA) {
if (length(x) > 1) {
abort_chk("`parent_rm` is inconsistent for blk ", blk, " in `x`")
}
if (defined & is.na(x)) {
if (defined && is.na(x)) {
abort_chk("`parent_rm` is undefined for blk ", blk, " in `x`")
}
x
Expand Down Expand Up @@ -115,7 +115,7 @@ adjust_points_blk <- function(x, blk) {
mutate(rm = y$rm)

new_y <- y |>
dplyr::slice(1L:length(seq)) |>
dplyr::slice(seq_along(seq)) |>
dplyr::mutate(rm = seq)

X <- approx(coordinates$rm, coordinates$X, new_y$rm)$y
Expand Down Expand Up @@ -174,7 +174,7 @@ fwa_swap_branches_rms <- function(x, y, adjust_points = TRUE) {
chk_data(x)
chk_data(y)
chk_flag(adjust_points)
if (!(vld_false(adjust_points) | vld_s3_class(x, "sf"))) {
if (!(vld_false(adjust_points) || vld_s3_class(x, "sf"))) {
chkor_vld(vld_false(adjust_points), vld_s3_class(x, "sf"))
}

Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ sample_linestring <- function(x, interval, end) {

sample_linestrings <- function(x, interval, end) {
x <- x |>
dplyr::mutate(..fwa_id = 1:dplyr::n()) |>
dplyr::mutate(..fwa_id = seq_len(dplyr::n())) |>
dplyr::group_split(.data$..fwa_id) |>
purrr::map(sample_linestring, interval, end = end) |>
dplyr::bind_rows() |>
Expand Down

0 comments on commit 384c449

Please sign in to comment.