diff --git a/DESCRIPTION b/DESCRIPTION index 636aeda..cf35924 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: ggOceanMaps Type: Package Title: Plot Data on Oceanographic Maps using 'ggplot2' -Version: 2.0.1 -Date: 2023-07-04 +Version: 2.0.2 +Date: 2023-07-05 Authors@R: c(person("Mikko", "Vihtakari", email = "mikko.vihtakari@hi.no", role = c("aut", "cre"), comment = c(affiliation = "Institute of Marine Research", diff --git a/R/basemap.R b/R/basemap.R index 5fa4b63..4a0fcf7 100644 --- a/R/basemap.R +++ b/R/basemap.R @@ -193,7 +193,7 @@ ## Test parameters # limits = c(160, -160, 60, 80); bathymetry = TRUE -# x = NULL; limits = NULL; data = NULL; shapefiles = NULL; crs = NULL; bathymetry = FALSE; glaciers = FALSE; rotate = FALSE; legends = TRUE; legend.position = "right"; lon.interval = NULL; lat.interval = NULL; bathy.style = NULL; bathy.border.col = NA; bathy.size = 0.1; bathy.alpha = 1; land.col = "grey60"; land.border.col = "black"; land.size = 0.1; gla.col = "grey95"; gla.border.col = "black"; gla.size = 0.1; grid.col = "grey70"; grid.size = 0.1; base_size = 11; projection.grid = FALSE; verbose = TRUE +# x = NULL; limits = NULL; data = NULL; shapefiles = NULL; crs = NULL; bathymetry = FALSE; glaciers = FALSE; rotate = FALSE; legends = TRUE; legend.position = "right"; lon.interval = NULL; lat.interval = NULL; bathy.style = NULL; downsample = 0; bathy.border.col = NA; bathy.size = 0.1; bathy.alpha = 1; land.col = "grey60"; land.border.col = "black"; land.size = 0.1; gla.col = "grey95"; gla.border.col = "black"; gla.size = 0.1; grid.col = "grey70"; grid.size = 0.1; base_size = 11; projection.grid = FALSE; verbose = TRUE basemap <- function(x = NULL, limits = NULL, data = NULL, shapefiles = NULL, crs = NULL, bathymetry = FALSE, glaciers = FALSE, rotate = FALSE, legends = TRUE, legend.position = "right", lon.interval = NULL, lat.interval = NULL, bathy.style = NULL, downsample = 0, bathy.border.col = NA, bathy.size = 0.1, bathy.alpha = 1, land.col = "grey60", land.border.col = "black", land.size = 0.1, gla.col = "grey95", gla.border.col = "black", gla.size = 0.1, grid.col = "grey70", grid.size = 0.1, base_size = 11, projection.grid = FALSE, expand.factor = 1.1, verbose = FALSE) { diff --git a/R/load_map_data.R b/R/load_map_data.R index f26188e..4798676 100644 --- a/R/load_map_data.R +++ b/R/load_map_data.R @@ -66,7 +66,7 @@ load_map_data <- function(x, force = FALSE, downsample = 0) { exist_list <- lapply(x[c("land", "glacier", "bathy")], function(k) { if(is.null(k)) { NULL - } else if(grepl("/", k)) { + } else if(grepl("/|\\\\", k)) { if(file.exists(k) & !force) { TRUE } else { @@ -97,11 +97,11 @@ load_map_data <- function(x, force = FALSE, downsample = 0) { lapply(x[c("land", "glacier")], function(k) { if(is.null(k)) { NULL - } else if(grepl("/", k)) { + } else if(grepl("/|\\\\", k)) { if(file.exists(k) & !force) { mget(load(k))[[1]] } else { - tmp <- unlist(strsplit(k, "/")) + tmp <- unlist(strsplit(k, "/|\\\\")) dest_path <- file.path(normalizePath(getOption("ggOceanMaps.datapath")),tmp[length(tmp)]) download.file(paste0(x$path, tmp[length(tmp)]), dest_path) @@ -118,11 +118,11 @@ load_map_data <- function(x, force = FALSE, downsample = 0) { if(bathy_user_defined) { x[["bathy"]] <- stars::read_stars(k, downsample = downsample) } else { - if(grepl("/", k)) { + if(grepl("/|\\\\", k)) { if(file.exists(k) & !force) { x[["bathy"]] <- mget(load(k))[[1]] } else { - tmp <- unlist(strsplit(k, "/")) + tmp <- unlist(strsplit(k, "/|\\\\")) dest_path <- file.path(normalizePath(getOption("ggOceanMaps.datapath")),tmp[length(tmp)]) download.file(paste0(x$path, tmp[length(tmp)]), dest_path) diff --git a/R/zzz.R b/R/zzz.R index 516ca5b..9b4057e 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -33,7 +33,7 @@ ".ggOceanMapsenv <- new.env(); ", ".ggOceanMapsenv$datapath <- 'YourCustomPath'}", ". You can use usethis::edit_r_profile() to edit the file.", - " normalizePath('~/Documents/ggOceanMapsLargeData') ", + " '~/ggOceanMapsLargeData' ", "would make it in a writable folder on most operating systems.") } else { msg <- paste0("ggOceanMaps: Using ", getOption("ggOceanMaps.datapath"), diff --git a/README.Rmd b/README.Rmd index 2244a16..2e0e6b5 100644 --- a/README.Rmd +++ b/README.Rmd @@ -74,7 +74,7 @@ While ggOceanMaps allows plotting any custom-made shapefiles, the package contai .ggOceanMapsenv$datapath <- 'YourCustomPath' ``` -It is smart to use a directory R has writing access to. For example `normalizePath("~/Documents/ggOceanMapsLargeData")` would work for most operating systems. +It is smart to use a directory R has writing access to. For example `"~/ggOceanMapsLargeData"` would work for most operating systems. You will need to set up the data path to your .Rprofile file only once and ggOceanMaps will find the path even though you updated your R or packages. ggOceanMaps will inform you about your data path when you load the package. diff --git a/README.md b/README.md index de9bd56..c6fc0c3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # ggOceanMaps **Plot data on oceanographic maps using ggplot2. R package version -2.0.0** +2.0.2** @@ -97,7 +97,7 @@ basemap(data = dt, bathymetry = TRUE) + color = "red", fill = NA) ``` -![](man/figures/README-unnamed-chunk-5-1.png) +![](man/figures/README-unnamed-chunk-4-1.png) See the [ggOceanMaps website](https://mikkovihtakari.github.io/ggOceanMaps/index.html), @@ -133,8 +133,7 @@ computer by modifying your .Rprofile file ``` It is smart to use a directory R has writing access to. For example -`normalizePath("~/Documents/ggOceanMapsLargeData")` would work for most -operating systems. +`"~/ggOceanMapsLargeData"` would work for most operating systems. You will need to set up the data path to your .Rprofile file only once and ggOceanMaps will find the path even though you updated your R or @@ -194,7 +193,7 @@ citation("ggOceanMaps") #> To cite package 'ggOceanMaps' in publications use: #> #> Vihtakari M (2023). _ggOceanMaps: Plot Data on Oceanographic Maps -#> using 'ggplot2'_. R package version 2.0.0, +#> using 'ggplot2'_. R package version 2.0.2, #> . #> #> A BibTeX entry for LaTeX users is @@ -203,7 +202,7 @@ citation("ggOceanMaps") #> title = {ggOceanMaps: Plot Data on Oceanographic Maps using 'ggplot2'}, #> author = {Mikko Vihtakari}, #> year = {2023}, -#> note = {R package version 2.0.0}, +#> note = {R package version 2.0.2}, #> url = {https://mikkovihtakari.github.io/ggOceanMaps/}, #> } ``` diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png new file mode 100644 index 0000000..e866ecb Binary files /dev/null and b/man/figures/README-unnamed-chunk-4-1.png differ