From 02a520689861c3354f7c6b575e309280b2a3a172 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Sat, 14 Apr 2018 14:01:59 +0200 Subject: [PATCH] no longer importing dplyr. #24 --- DESCRIPTION | 5 +++-- NAMESPACE | 3 --- R/flag.R | 3 +-- R/keycap.R | 9 +++------ R/medal.R | 4 +--- R/moon.R | 10 ++++------ 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 896e903..0663921 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,7 +15,6 @@ Encoding: UTF-8 LazyData: true Imports: stringr, - dplyr, glue (>= 1.2.0.9000), crayon, utils, @@ -27,5 +26,7 @@ Imports: RoxygenNote: 6.0.1.9000 URL: https://github.com/hadley/emo BugReports: https://github.com/hadley/emo/issues -Suggests: testthat +Suggests: + testthat, + dplyr Remotes: tidyverse/glue diff --git a/NAMESPACE b/NAMESPACE index 0c142a4..4939cdb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -35,12 +35,9 @@ export(moon) export(square) importFrom(assertthat,assert_that) importFrom(crayon,silver) -importFrom(dplyr,filter) -importFrom(dplyr,slice) importFrom(glue,glue) importFrom(glue,glue_collapse) importFrom(lubridate,ymd) -importFrom(magrittr,"%>%") importFrom(purrr,map_chr) importFrom(purrr,walk2) importFrom(rlang,enquo) diff --git a/R/flag.R b/R/flag.R index 37333c8..7d23bad 100644 --- a/R/flag.R +++ b/R/flag.R @@ -20,11 +20,10 @@ #' } #' #' @importFrom stringr str_detect -#' @importFrom dplyr filter #' @importFrom glue glue #' @export flag <- function( pattern ){ - data <- filter( emo::jis, group == "Flags", str_detect(name, pattern) ) + data <- emo::jis[ emo::jis$group == "Flags" & str_detect(emo::jis$name, pattern), ] n <- nrow(data) if( n == 0 ){ stop( glue( "Cannot find flag '{pattern}' ") ) diff --git a/R/keycap.R b/R/keycap.R index 822daf2..59a852c 100644 --- a/R/keycap.R +++ b/R/keycap.R @@ -13,8 +13,6 @@ #' } #' #' @importFrom assertthat assert_that -#' @importFrom magrittr %>% -#' @importFrom dplyr filter slice #' @export keycap <- function( x ){ choices <- c("#", "*", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10") @@ -22,12 +20,11 @@ keycap <- function( x ){ assert_that( length(x) == 1) assert_that( x %in% choices ) - idx <- which( x == choices ) - data <- filter( emo::jis, subgroup == "keycap" ) %>% - slice(idx) + jis <- emo::jis + emoji <- jis$emoji[ jis$subgroup == "keycap" & jis$qualified == "fully-qualified" ][ x == choices] structure( - data$emoji, + emoji, char = x, class = c("keycap", "emoji") ) diff --git a/R/medal.R b/R/medal.R index 0103715..c292737 100644 --- a/R/medal.R +++ b/R/medal.R @@ -28,9 +28,7 @@ medal <- function( position ){ names <- c("1st place medal", "2nd place medal", "3rd place medal") pos <- eval_tidy( position, data = aliases ) - - data <- emo::jis %>% - filter( name == names[pos] ) + data <- emo::jis[ emo::jis$name == names[pos], ] structure( data$emoji, class = c("medal", "emoji"), diff --git a/R/moon.R b/R/moon.R index dca581b..fc84d6d 100644 --- a/R/moon.R +++ b/R/moon.R @@ -43,12 +43,10 @@ moon <- function( date, day = day_in_synodic_cycle(date) ){ assert_that( day >= 0 & day <= synodic_month ) idx <- 1 + (day / synodic_month * 8) %% 8 - - data <- emo::jis %>% - filter( str_detect( name, "moon$" ) ) %>% - slice(idx) - - structure( data$emoji, + jis <- emo::jis + data <- jis[ which(str_detect( jis$name, "moon$" ))[idx], ] + structure( + data$emoji, class = c("moon", "emoji"), day = day, data = data