Skip to content

Commit

Permalink
Remove magrittr pipes (issue #11) and fix more CMD check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
francisbarton committed Mar 26, 2024
1 parent 8db571c commit 724f882
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Imports:
janitor,
jsonlite,
lubridate,
magrittr,
pillar,
prompt,
ps,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ importFrom(dplyr,desc)
importFrom(dplyr,if_any)
importFrom(dplyr,if_else)
importFrom(dplyr,join_by)
importFrom(magrittr,"%>%")
importFrom(rlang,`:=`)
importFrom(tidyselect,all_of)
importFrom(tidyselect,any_of)
Expand Down
10 changes: 5 additions & 5 deletions R/get_latlon.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ get_latlon <- function(postcode) {

endpoint <- "https://www.doogal.co.uk/GetPostcode.ashx?postcode="

paste0(endpoint, postcode) %>%
utils::URLencode() %>%
rvest::read_html() %>%
rvest::html_node("p") %>%
rvest::html_text() %>%
paste0(endpoint, postcode) |>
utils::URLencode() |>
rvest::read_html() |>
rvest::html_node("p") |>
rvest::html_text() |>
readr::read_delim("\t", col_names = data_names)
}
3 changes: 1 addition & 2 deletions R/myrmidon-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
# roxygen namespace tags. Modify with care!
#' @importFrom assertthat assert_that
#' @importFrom dplyr across c_across desc if_any if_else join_by
#' @importFrom magrittr %>%
#' @importFrom rlang `:=`
#' @importFrom rlang `:=` .data
#' @importFrom tidyselect all_of any_of contains ends_with everything
#' @importFrom tidyselect last_col matches num_range starts_with
#' @importFrom usethis ui_info ui_stop ui_oops ui_nope ui_code
Expand Down
16 changes: 8 additions & 8 deletions R/order_along.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,30 @@ order_along.sf <- function(sf, order_along, sort_by, desc = FALSE) {

# gotta split🍌, and work without geometry on one fork🍴, otherwise
# the left_join later on will fail (can't `dplyr::*-join` two `sf` tbls)
sf2 <- sf %>%
sf2 <- sf |>
sf::st_drop_geometry()

cols <- colnames(sf2)

if (desc) {
sf2 <- sf2 %>%
sf2 <- sf2 |>
dplyr::arrange(desc({{ sort_by }}))
} else {
sf2 <- sf2 %>%
sf2 <- sf2 |>
dplyr::arrange({{ sort_by }})
}

sf2 %>%
sf2 |>
# create list of `order_along` variable, in order of appearance 😊
dplyr::select({{ order_along }}) %>%
dplyr::distinct() %>%
dplyr::select({{ order_along }}) |>
dplyr::distinct() |>

# now ordered along `order_along` and sorted by `sort_by` 😄
# not _necessary_ to stipulate `by`, but it avoids the join message 🤫.
dplyr::left_join(sf2, by = rlang::as_name(along)) %>%
dplyr::left_join(sf2, by = rlang::as_name(along)) |>

# quick way to restore the original column order 😙
dplyr::select(dplyr::all_of(cols)) %>%
dplyr::select(dplyr::all_of(cols)) |>

# `right_join()` saves the day by retrieving and joining to the original
# geometry without losing our carefully crafted sorting and ordering 😌
Expand Down
6 changes: 3 additions & 3 deletions R/prompts.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ prompt_rstudio <- function() {
rstd <- tryCatch(RStudio.Version()$release_name, error = \(e) NULL)
if (!is.null(rstd)) {
colour <- "myr_prompt_col3" |>
get0(.myr_prompt_env, ifnotfound = "darkslateblue")
get0(".myr_prompt_env", ifnotfound = "darkslateblue")
crayon::style(rstd, colour)
} else NULL
}
Expand All @@ -11,7 +11,7 @@ prompt_rstudio <- function() {

prompt_location <- function(unicode) {
colour <- "myr_prompt_col1" |>
get0(.myr_prompt_env, ifnotfound = "whitesmoke")
get0(".myr_prompt_env", ifnotfound = "whitesmoke")
location <- basename(getwd())
icon <- if (unicode) {
if (file.exists(here::here("DESCRIPTION"))) "\U1F4E6\u2009"
Expand All @@ -26,7 +26,7 @@ prompt_location <- function(unicode) {
prompt_git_branch <- function(unicode) {
if (prompt::is_git_dir()) {
colour <- "myr_prompt_col2" |>
get0(.myr_prompt_env, ifnotfound = "orange")
get0(".myr_prompt_env", ifnotfound = "orange")

if (unicode) {
paste0(
Expand Down

0 comments on commit 724f882

Please sign in to comment.