diff --git a/DESCRIPTION b/DESCRIPTION index 7022e4b..5ae13ca 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,8 +13,6 @@ Depends: import: RoxygenNote: 6.1.0 Imports: - lattice, - xml2, ggplot2, jsonlite, magrittr, diff --git a/NAMESPACE b/NAMESPACE index 6898bf0..5e58a14 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -80,6 +80,7 @@ export(last) export(listk) export(llply_par) export(make_date) +export(make_datetime) export(make_dt) export(map) export(mapvalues) @@ -88,6 +89,7 @@ export(match2) export(melt_list) export(melt_tree) export(merge_pdf) +export(mkdir) export(mutate) export(obj.size) export(options_update) @@ -109,7 +111,6 @@ export(set_dimnames) export(set_font) export(set_names) export(setwd_clip) -export(sf_rect) export(showfig) export(smerge) export(split_data) @@ -118,10 +119,10 @@ export(stat_sd) export(str_year) export(subl) export(tabular) +export(touch) export(transpose) export(unique_length) export(upper_envelope) -export(url_filezilla) export(which.isnull) export(which.na) export(which.notna) @@ -174,6 +175,7 @@ importFrom(jsonlite,read_json) importFrom(jsonlite,write_json) importFrom(lubridate,days_in_month) importFrom(lubridate,make_date) +importFrom(lubridate,make_datetime) importFrom(lubridate,yday) importFrom(lubridate,year) importFrom(lubridate,ymd) @@ -211,7 +213,3 @@ importFrom(utils,modifyList) importFrom(utils,object.size) importFrom(utils,str) importFrom(utils,write.table) -importFrom(xml2,read_xml) -importFrom(xml2,xml_find_all) -importFrom(xml2,xml_find_first) -importFrom(xml2,xml_text) diff --git a/R/RcppExports.R b/R/RcppExports.R deleted file mode 100644 index a7dad8e..0000000 --- a/R/RcppExports.R +++ /dev/null @@ -1,15 +0,0 @@ -# Generated by using Rcpp::compileAttributes() -> do not edit by hand -# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -senslope <- function(y, x = NULL) { - .Call(`_Ipaper_senslope`, y, x) -} - -Sf <- function(x) { - .Call(`_Ipaper_Sf`, x) -} - -varS <- function(x, rof, S) { - .Call(`_Ipaper_varS`, x, rof, S) -} - diff --git a/R/cmd_func.R b/R/cmd_func.R index a7d048d..094181c 100644 --- a/R/cmd_func.R +++ b/R/cmd_func.R @@ -102,12 +102,13 @@ dir.show <- function (path = getwd()) { # FUN(file = file, width = width, height = height, ...) # } -#' check_dir +#' mkdir +#' #' @param path character vectors #' #' @importFrom foreach %do% #' @export -check_dir <- function(path){ +mkdir <- function(path){ for (path_i in unique(path)) { if (!dir.exists(path_i)) { dir.create(path_i, recursive = TRUE) @@ -115,3 +116,14 @@ check_dir <- function(path){ } path } + +#' @rdname mkdir +#' @export +check_dir <- mkdir + +#' @keywords internal +#' @export +touch <- function(file) { + mkdir(dirname(file)) + writeLines("", file) +} diff --git a/R/facet_tag.R b/R/ggplot-facet_tag.R similarity index 100% rename from R/facet_tag.R rename to R/ggplot-facet_tag.R diff --git a/R/stat-.r b/R/ggplot-stat-.r similarity index 100% rename from R/stat-.r rename to R/ggplot-stat-.r diff --git a/R/reexports.R b/R/reexports.R index 7e91032..8fd453f 100644 --- a/R/reexports.R +++ b/R/reexports.R @@ -45,10 +45,13 @@ data.table::is.data.table #' @export data.table::as.data.table -#' @importFrom lubridate make_date days_in_month +#' @importFrom lubridate make_date make_datetime days_in_month #' @export lubridate::make_date +#' @export +lubridate::make_datetime + #' @export lubridate::days_in_month diff --git a/R/tools.R b/R/tools.R index ebc7388..3950d0a 100644 --- a/R/tools.R +++ b/R/tools.R @@ -98,8 +98,7 @@ cut_plevels <- function(x, pvalue = c(0.01, 0.05, 0.1), verbose = FALSE) { c(-rev(.), 0, .) levels_num <- cut(1, pvalue2) %>% - levels() %>% - { + levels() %>% { c(rev(.[1:np]), rev(.[-(1:np)])) %>% rev() } levels_str <- c( diff --git a/R/tools_external_apps.R b/R/tools_external_apps.R deleted file mode 100644 index 4277faf..0000000 --- a/R/tools_external_apps.R +++ /dev/null @@ -1,11 +0,0 @@ -#' @importFrom xml2 read_xml xml_find_first xml_find_all xml_text -#' @export -url_filezilla <- function(file) { - p <- read_xml(file) - - host <- xml_find_first(p, "//Host") %>% xml_text() %>% paste0("ftp://", .) - paths <- xml_find_all(p, "//File/RemotePath") %>% xml_text() %>% - gsub("1 0", "", .) %>% gsub(" \\d{1,} ", "/", .) - files <- xml_find_all(p, "//File/RemoteFile") %>% xml_text() %>% paste0(host, paths, "/", .) - data.table::fwrite(data.frame(files), "urls.txt", col.names = FALSE) -} diff --git a/R/tools_sp.R b/R/tools_sp.R index 2ee7c05..71d4f7f 100644 --- a/R/tools_sp.R +++ b/R/tools_sp.R @@ -1,26 +1,3 @@ - -#' sf_rect -#' -#' @examples -#' \dontrun{ -#' xlim = c(112, 115) -#' ylim = c(21, 23) -#' range <- c(xlim, ylim) -#' poly = sf_rect(range) -#' write_sf(poly, "poly.shp") -#' } -#' @export -sf_rect <- function(range, crs = st_crs(4326)){ - xlim = range[1:2] - ylim = range[3:4] - coors = matrix(c(xlim, rev(xlim), xlim[1], rep(ylim, each = 2), ylim[1]), ncol = 2) - pts = list(coors) - p <- st_polygon(list(coors)) #%T>% plot() - st_sfc(p, crs = crs) -} - -# st_bbox(c(112, 115, 21, 23) %>% set_names(c("xmin", "xmax", "ymin", "ymax")), crs = st_crs(4326)) - #' write_sp2rgb #' #' @param grid SpatialGridPixels or SpatialGridDataFrame object diff --git a/README.Rmd b/README.Rmd index 073b9ea..afde88b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -70,6 +70,7 @@ install.packages("../Ipaper_0.1.5.9000.tar.gz", repos = NULL, type = "source", d ### Base tools * `code`, `smerge`, `subl`, `github`: open app at assigned directory +* `mkdir`, `touch` * `dir.show`: open at assigned directory in explorer * `runningId`: print the running ID in the console * `fprintf`: c style `fprintf` diff --git a/README.md b/README.md index 06fd8c5..6e79e4b 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ After install, run `Ipaper::key_blind()` to make those shortcuts work. ### Base tools - `code`, `smerge`, `subl`, `github`: open app at assigned directory +- `mkdir`, `touch` - `dir.show`: open at assigned directory in explorer - `runningId`: print the running ID in the console - `fprintf`: c style `fprintf` diff --git a/data/grid_avhrr.rda b/data/grid_avhrr.rda deleted file mode 100644 index 83e0c3f..0000000 Binary files a/data/grid_avhrr.rda and /dev/null differ diff --git a/man/apply_3d.Rd b/man/apply_3d.Rd index ce8ea80..5d5c78e 100644 --- a/man/apply_3d.Rd +++ b/man/apply_3d.Rd @@ -52,7 +52,7 @@ by <- c(rep(1, 10), rep(2, 21)) r2 <- apply_3d(arr, 3, by = by, FUN = rowMeans) \dontrun{ -arr_yearly <- apply_3d(arr, year(dates), scale = days_in_month(dates)) +arr_yearly <- apply_3d(arr, by = year(dates), scale = days_in_month(dates)) } } \seealso{ diff --git a/man/ggplot2-ggproto.Rd b/man/ggplot2-ggproto.Rd index 15409a1..4beb1d0 100644 --- a/man/ggplot2-ggproto.Rd +++ b/man/ggplot2-ggproto.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/stat-.r +% Please edit documentation in R/ggplot-stat-.r \docType{data} \name{ggplot2-ggproto} \alias{ggplot2-ggproto} diff --git a/man/check_dir.Rd b/man/mkdir.Rd similarity index 76% rename from man/check_dir.Rd rename to man/mkdir.Rd index fdaa68a..a61f6a1 100644 --- a/man/check_dir.Rd +++ b/man/mkdir.Rd @@ -1,14 +1,17 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/cmd_func.R -\name{check_dir} +\name{mkdir} +\alias{mkdir} \alias{check_dir} -\title{check_dir} +\title{mkdir} \usage{ +mkdir(path) + check_dir(path) } \arguments{ \item{path}{character vectors} } \description{ -check_dir +mkdir } diff --git a/man/reexports.Rd b/man/reexports.Rd index 788811d..f5185bf 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -16,6 +16,7 @@ \alias{is.data.table} \alias{as.data.table} \alias{make_date} +\alias{make_datetime} \alias{days_in_month} \alias{\%dopar\%} \alias{\%do\%} @@ -39,7 +40,7 @@ below to see their documentation. \item{iterators}{\code{\link[iterators]{icount}}, \code{\link[iterators]{iter}}} - \item{lubridate}{\code{\link[lubridate]{days_in_month}}, \code{\link[lubridate:make_datetime]{make_date}}} + \item{lubridate}{\code{\link[lubridate]{days_in_month}}, \code{\link[lubridate:make_datetime]{make_date}}, \code{\link[lubridate]{make_datetime}}} \item{magrittr}{\code{\link[magrittr:compound]{\%<>\%}}, \code{\link[magrittr:pipe]{\%>\%}}, \code{\link[magrittr:aliases]{set_names}}} diff --git a/man/sf_rect.Rd b/man/sf_rect.Rd deleted file mode 100644 index 42edac7..0000000 --- a/man/sf_rect.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tools_sp.R -\name{sf_rect} -\alias{sf_rect} -\title{sf_rect} -\usage{ -sf_rect(range, crs = st_crs(4326)) -} -\description{ -sf_rect -} -\examples{ -\dontrun{ -xlim = c(112, 115) -ylim = c(21, 23) -range <- c(xlim, ylim) -poly = sf_rect(range) -write_sf(poly, "poly.shp") -} -}