Created
July 21, 2018 23:48
-
-
Save tiernanmartin/71b44f40567edfdb70c73b5e00afa7c1 to your computer and use it in GitHub Desktop.
A template for R/utils.R in a package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @title A set of generic helpful functions | |
#' @description General purpose functions to make working in R easier. | |
#' @name utils | |
#' @import purrr | |
NULL | |
#' @rdname utils | |
#' @export | |
not_sfc <- function(x) !any(class(x) %in% 'sfc') | |
#' @rdname utils | |
#' @export | |
first_not_na <- function(x){ | |
if(all(sapply(x,is.na))){ | |
methods::as(NA,class(x)) | |
}else{ | |
x[!sapply(x,is.na)][1] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment