From 9ec321f8c0edba1bb247c8ba5f261ef79e4390ad Mon Sep 17 00:00:00 2001 From: almac2022 Date: Thu, 15 Dec 2022 22:59:26 -0800 Subject: [PATCH] seems to be throwing error so moved here. not sure why we have it actually. --- LICENSE | 2 + LICENSE.md | 21 ++++++++ R/intro.R | 5 ++ hold/add_pkg_versions.R | 74 +++++++++++++++++++++++++++ man/fpr_gpkg_p.Rd | 3 -- man/fpr_kable.Rd | 12 +++-- man/fpr_photo_paths_to_copy_phase2.Rd | 18 +++++++ 7 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 LICENSE create mode 100644 LICENSE.md create mode 100644 R/intro.R create mode 100644 hold/add_pkg_versions.R create mode 100644 man/fpr_photo_paths_to_copy_phase2.Rd diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..256fb3c --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +YEAR: 2022 +COPYRIGHT HOLDER: fpr authors diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9f9d796 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2022 fpr authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/R/intro.R b/R/intro.R new file mode 100644 index 0000000..db1419e --- /dev/null +++ b/R/intro.R @@ -0,0 +1,5 @@ +.onAttach <- function(libname, pkgname) { + message <- c("\n Machin3 readable Winters.", + "\n Happy coding bud!") + packageStartupMessage(message) +} diff --git a/hold/add_pkg_versions.R b/hold/add_pkg_versions.R new file mode 100644 index 0000000..b3f6c8a --- /dev/null +++ b/hold/add_pkg_versions.R @@ -0,0 +1,74 @@ +#' Add curent version string to package dependencies +#' +#' Will \code{cat} out a cut/paste-able set of fields for a +#' \code{DESCRIPTION} file with minimum required versions for +#' each package based upon currently available package vesions +#' in CRAN. https://stackoverflow.com/questions/38738292/how-can-i-automatically-add-update-depends-imports-suggests-versions-in-descript +#' +#' @param pkg package description, can be path or package name +#' @param fields fields to get & report dependencies for +#' @note R and the R version is NOT added to \code{Depends} +#' @examples +#' add_pkg_versions("qmethod") +#' add_pkg_versions("MASS") +#' \dontrun { # assumes you're in a pkg devel dir +#' add_pkg_versions() +#' } +#' @export +add_pkg_versions <- function(pkg=".", + fields=c("Depends", "Imports", "LinkingTo", "Suggests")) { + + require(purrr) + walk(c("dplyr", "tools", "stringi", "devtools"), require, character.only=TRUE) + + stopifnot(is_scalar_character(pkg), pkg != "") + fields <- match.arg(fields, c("Depends", "Imports", "LinkingTo", "Suggests"), + several.ok=TRUE) + + avail <- as_tibble(available.packages()) + + if (pkg == ".") { + pkg_deps <- unclass(as_tibble(read.dcf(file.path(package_file(), "DESCRIPTION")))) + pkg <- pkg_deps$Package + map(fields, ~stri_split_lines(pkg_deps[[.]])) %>% + map(function(x) { + if (length(x) > 0) { + unlist(x) %>% + stri_replace_all_regex(" \\(.*$|,", "") %>% + discard(`%in%`, c("", "R")) + } else { x } + }) -> pkg_deps + names(pkg_deps) <- fields + } else { + pkg_deps <- map(fields, ~flatten_chr((package_dependencies(pkg, which=.)))) + names(pkg_deps) <- fields + } + + pkg_deps <- discard(pkg_deps, function(x) {length(x)==0}) + + map(pkg_deps, function(x) { + + non_base <- filter(avail, Package %in% x) + base <- setdiff(x, non_base$Package) + + non_base %>% + mutate(pv=sprintf("%s (>= %s)", Package, Version)) %>% + select(pv) %>% + flatten_chr() -> pkg_plus_version + + sort(c(pkg_plus_version, base)) + + }) -> pkg_deps + + cat("Package: ", pkg, "\n", sep="") + walk(names(pkg_deps), function(x) { + + cat(x, ":\n", sep="") + sprintf(" %s", pkg_deps[[x]]) %>% + paste0(collapse=",\n") %>% + cat() + cat("\n") + + }) + +} diff --git a/man/fpr_gpkg_p.Rd b/man/fpr_gpkg_p.Rd index 79f7ac7..e9e022c 100644 --- a/man/fpr_gpkg_p.Rd +++ b/man/fpr_gpkg_p.Rd @@ -25,9 +25,6 @@ fpr_gpkg_p( \item{northing}{Numeric value for} \item{directory}{String value for} -} -\value{ - } \description{ Make point geopackage layer from dataframe diff --git a/man/fpr_kable.Rd b/man/fpr_kable.Rd index 643f92a..d97e707 100644 --- a/man/fpr_kable.Rd +++ b/man/fpr_kable.Rd @@ -9,7 +9,10 @@ fpr_kable( caption_text = "", font = font_set, footnote_text = NULL, - scroll = TRUE + scroll = TRUE, + scroll_box_height = "500px", + col_width_min = NULL, + width_min = "1.0in" ) } \arguments{ @@ -22,9 +25,12 @@ fpr_kable( \item{footnote_text}{string to insert as footnote} \item{scroll}{TRUE or FALSE about whether to have scroll} -} -\value{ +\item{scroll_box_height}{string. pixel height of scroll box. Defaults to "500px"} + +\item{col_width_min}{Number or vector of numbers. Defaults to NULL} + +\item{width_min}{string with units of inches (in). Defaults to 1.0in} } \description{ Custom kable settings diff --git a/man/fpr_photo_paths_to_copy_phase2.Rd b/man/fpr_photo_paths_to_copy_phase2.Rd new file mode 100644 index 0000000..c97bda5 --- /dev/null +++ b/man/fpr_photo_paths_to_copy_phase2.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/photo.R +\name{fpr_photo_paths_to_copy_phase2} +\alias{fpr_photo_paths_to_copy_phase2} +\title{Untested!! Identify photos that should be copied over into a file to upload to the phase 2 PSCIS interface +This is every photo not moved by fpr_photo_paths_to_copy +adapted from https://stackoverflow.com/questions/56160445/how-to-pass-multiple-necessary-patterns-to-str-subset} +\usage{ +fpr_photo_paths_to_copy_phase2(path_to_photo_dir) +} +\arguments{ +\item{path_to_photo_dir}{Full path to photo directories that will be copied over} +} +\description{ +Untested!! Identify photos that should be copied over into a file to upload to the phase 2 PSCIS interface +This is every photo not moved by fpr_photo_paths_to_copy +adapted from https://stackoverflow.com/questions/56160445/how-to-pass-multiple-necessary-patterns-to-str-subset +}