From adc548a78cac5a35b6e97076d3db033af65ce06f Mon Sep 17 00:00:00 2001 From: ncarvalho Date: Tue, 27 Mar 2018 23:09:22 +0200 Subject: [PATCH 1/7] chores: Fixing cran check. Add .Rbuildignore . Fix DESCRIPTION --- .Rbuildignore | 16 ++++++++++++++-- DESCRIPTION | 20 +++++++++++--------- R/get_dir.R | 2 +- R/siane_map.R | 10 +++++----- R/siane_merge.R | 11 +++++++---- R/stop_advices.R | 2 +- man/siane_map.Rd | 2 +- man/siane_merge.Rd | 6 ++++-- 8 files changed, 44 insertions(+), 25 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf..28d9910 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,14 @@ -^.*\.Rproj$ -^\.Rproj\.user$ +^.*\.Rproj$ # Automatically added by RStudio, +^\.Rproj\.user$ # used for temporary files. +^README.md$ # An Rmarkdown file used to generate README.md +^cran-comments\.md$ # Comments for CRAN submission +^NEWS\.md$ # A news file written in Markdown +^\.travis\.yml$ # Used for continuous integration testing with travis +^Images$ # Images used in README +Images +.git +./.git +.gitignore +RData +Siane.Rproj + diff --git a/DESCRIPTION b/DESCRIPTION index b8a5cb8..e78740d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,19 +1,21 @@ Package: Siane -Title: Siane +Title: Explore the Spanish INE Data using this Geographic Tool Version: 0.1 -Description: Statistic polygon plots of INE data -Depends: R (>= 3.3.1) -License: MIT +Description: A tool that makes the user able to represent spatial data over Spain + territories. It's main functionality is to bind numerical data to polygons. + It's only compatible with the spanish IGN(National Institute of Geography) maps + and the INE(National Institute of Statistics) data. +Depends: classInt, plyr, raster, rgdal, sp, methods, utils +License: MIT + file LICENSE Encoding: UTF-8 LazyData: true Authors@R: c(person("Carlos J. Gil Bellosta", - email = "cgb@datanalytics.com",role = c("aut","cre")), - person("Nuno", "Carvalho", role = c("aut"), + email = "cgb@datanalytics.com", role = c("aut")), + person("Nuno", "Carvalho", role = c("cre", "aut"), email = "nunocarvalhodossantos@gmail.com")) -Author: Carlos J. Gil Bellosta[aut, cre] - Nuno Carvalho[aut] +Author: Carlos J. Gil Bellosta [aut], + Nuno Carvalho [cre, aut] Maintainer: Nuno Carvalho -Depends: RColorBrewer, classInt, maptools, plyr, raster, rgdal, sp RoxygenNote: 6.0.1 Suggests: knitr, rmarkdown diff --git a/R/get_dir.R b/R/get_dir.R index 35348b6..b910017 100644 --- a/R/get_dir.R +++ b/R/get_dir.R @@ -19,7 +19,7 @@ get_dir <- function(base_path, dirs_path,last_path, year){ folder_years <- sapply(dirs_path, - function(x) tail(strsplit(x = x,split = "/")[[1]],1)) # If the user introduces a year we try to search for the newest map until that year + function(x) utils::tail(strsplit(x = x,split = "/")[[1]],1)) # If the user introduces a year we try to search for the newest map until that year folder_years_num <- sapply(folder_years, diff --git a/R/siane_map.R b/R/siane_map.R index 5a64410..ea68bb3 100644 --- a/R/siane_map.R +++ b/R/siane_map.R @@ -1,4 +1,4 @@ -#' @import "rgdal" +#' @import "rgdal" #'@title Loads a spanish map #' #' @description A function that returns a S4 object(map) of a Spain specific map @@ -6,7 +6,7 @@ #' @examples #' \dontrun{ #' obj <- register_siane("/home/ncarvalho/Downloads/") # Registering a sample of Siane -#' shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE, peninsula = "close") # Loading the municipality's map of Spain +#' shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE, peninsula = "close") #' plot(shp) # Plot the map} @@ -60,15 +60,15 @@ siane_map <- function(obj, canarias, year, level, scale, peninsula){ shp_peninsula <- siane_map_piece(obj = obj, canarias = FALSE, level = level, scale = scale) # Loading the municipality's map of Spain shp_canarias <- siane_map_piece(obj = obj, canarias = TRUE , level = level, scale = scale) # Canarias True - shp_canarias_shifted <- shift(shp_canarias, x = 18, y = 8) + shp_canarias_shifted <- raster::shift(shp_canarias, x = 18, y = 8) shp_total <- bind(shp_peninsula, shp_canarias_shifted) rectangle <- as(raster::extent(-0.5, 5, 11.6, 9), "SpatialPolygons") proj4string(rectangle) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" - shif_rect <- shift(rectangle, y = 26) - shp_rect_total <- bind(shif_rect,shp_total) + shif_rect <- raster::shift(rectangle, y = 26) + shp_rect_total <- raster::bind(shif_rect,shp_total) return(shp_rect_total) } diff --git a/R/siane_merge.R b/R/siane_merge.R index 3c60f48..79eb2d0 100644 --- a/R/siane_merge.R +++ b/R/siane_merge.R @@ -7,9 +7,11 @@ #' \dontrun{ #' library(pxR) #' obj <- register_siane("/home/ncarvalho/Downloads/") -#' shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE) # Loading the municipality's map of Spain +#' # Loading the municipality's map of Spain +#' shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE) #' plot(shp) # Plot the map -#' df <- as.data.frame(read.px("/home/ncarvalho/Downloads/2879.px"))# Get this file in INE's website. Check the README to learn how to do it. +#' # Get this file in INE's website. Check the README to learn how to do it. +#' df <- as.data.frame(read.px("/home/ncarvalho/Downloads/2879.px")) #' by <- "codes" #' df[[by]] <- sapply(df$Municipios,function(x) strsplit(x = as.character(x), split = " ")[[1]][1]) #' year <- 2016 @@ -52,8 +54,9 @@ siane_merge <- function(shp, df, by, level, value){ stop_advices(df, by, value) # Stop sentences for column names: Values column and codes column. - shp_code <- shp_code(level) # The shape file column that contains the code depends on the level. This function returns the code's shp column name - + # The shape file column that contains the code depends on the level. + #This function returns the code's shp column name + shp_code <- shp_code(level) name_filter <- names(df) == by # names(df)[name_filter] <- shp_code # Renaming the column to make the join diff --git a/R/stop_advices.R b/R/stop_advices.R index ed72a08..9e59999 100644 --- a/R/stop_advices.R +++ b/R/stop_advices.R @@ -1,5 +1,5 @@ -stop_advices <- function(df,by,name){ +stop_advices <- function(df, by, value){ if((by %in% names(df)) == FALSE){ # Checking if the ID's column is in the dataframe stop(paste0("The column ", by, " is not in the data frame. Try to run names(df) to check the data frame column names")) diff --git a/man/siane_map.Rd b/man/siane_map.Rd index 39cf64f..a5d779b 100644 --- a/man/siane_map.Rd +++ b/man/siane_map.Rd @@ -38,6 +38,6 @@ The default value for the municipalities maps is \code{scale <- "3m"} . The defa \examples{ \dontrun{ obj <- register_siane("/home/ncarvalho/Downloads/") # Registering a sample of Siane -shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE, peninsula = "close") # Loading the municipality's map of Spain +shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE, peninsula = "close") plot(shp) # Plot the map} } diff --git a/man/siane_merge.Rd b/man/siane_merge.Rd index 9e33cdb..7947f46 100644 --- a/man/siane_merge.Rd +++ b/man/siane_merge.Rd @@ -39,9 +39,11 @@ There will be as many missing territories as missing codes in the dataframe. \cr \dontrun{ library(pxR) obj <- register_siane("/home/ncarvalho/Downloads/") -shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE) # Loading the municipality's map of Spain +# Loading the municipality's map of Spain +shp <- siane_map(obj = obj, level = "Municipios", canarias = FALSE) plot(shp) # Plot the map -df <- as.data.frame(read.px("/home/ncarvalho/Downloads/2879.px"))# Get this file in INE's website. Check the README to learn how to do it. +# Get this file in INE's website. Check the README to learn how to do it. +df <- as.data.frame(read.px("/home/ncarvalho/Downloads/2879.px")) by <- "codes" df[[by]] <- sapply(df$Municipios,function(x) strsplit(x = as.character(x), split = " ")[[1]][1]) year <- 2016 From cdb350d72d9c3a2a765c9d03227ae33985e93aef Mon Sep 17 00:00:00 2001 From: ncarvalho Date: Tue, 27 Mar 2018 23:34:51 +0200 Subject: [PATCH 2/7] Fix library dependencies(function visibility) --- DESCRIPTION | 2 +- LICENSE | 2 ++ NAMESPACE | 7 +++++++ R/brks_color.R | 7 ------- R/siane_map.R | 11 +++++++---- R/siane_merge.R | 2 +- 6 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 LICENSE delete mode 100644 R/brks_color.R diff --git a/DESCRIPTION b/DESCRIPTION index e78740d..4b14b37 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Description: A tool that makes the user able to represent spatial data over Spai territories. It's main functionality is to bind numerical data to polygons. It's only compatible with the spanish IGN(National Institute of Geography) maps and the INE(National Institute of Statistics) data. -Depends: classInt, plyr, raster, rgdal, sp, methods, utils +Depends: plyr, raster, rgdal, sp, methods, utils License: MIT + file LICENSE Encoding: UTF-8 LazyData: true diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9ab6c36 --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +YEAR: 2017 +COPYRIGHT HOLDER: Your name goes here diff --git a/NAMESPACE b/NAMESPACE index e5494ab..1aa6d55 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,3 +4,10 @@ export(register_siane) export(siane_map) export(siane_merge) import("rgdal") +importFrom(methods,as) +importFrom(plyr,join) +importFrom(raster,bind) +importFrom(raster,extent) +importFrom(raster,shift) +importFrom(sp,"proj4string<-") +importFrom(sp,proj4string) diff --git a/R/brks_color.R b/R/brks_color.R deleted file mode 100644 index 8ec6dcd..0000000 --- a/R/brks_color.R +++ /dev/null @@ -1,7 +0,0 @@ - -brks_color <- function(n,pallete_colour, values_ine, style){ - brks <- classIntervals(values_ine, n = n, style = style) - brks <- brks$brks - - return(brks) -} diff --git a/R/siane_map.R b/R/siane_map.R index ea68bb3..73d4a62 100644 --- a/R/siane_map.R +++ b/R/siane_map.R @@ -1,4 +1,7 @@ #' @import "rgdal" +#'@importFrom raster shift extent bind +#'@importFrom sp proj4string proj4string<- +#'@importFrom methods as #'@title Loads a spanish map #' #' @description A function that returns a S4 object(map) of a Spain specific map @@ -60,15 +63,15 @@ siane_map <- function(obj, canarias, year, level, scale, peninsula){ shp_peninsula <- siane_map_piece(obj = obj, canarias = FALSE, level = level, scale = scale) # Loading the municipality's map of Spain shp_canarias <- siane_map_piece(obj = obj, canarias = TRUE , level = level, scale = scale) # Canarias True - shp_canarias_shifted <- raster::shift(shp_canarias, x = 18, y = 8) + shp_canarias_shifted <- shift(shp_canarias, x = 18, y = 8) shp_total <- bind(shp_peninsula, shp_canarias_shifted) - rectangle <- as(raster::extent(-0.5, 5, 11.6, 9), "SpatialPolygons") + rectangle <- as(extent(-0.5, 5, 11.6, 9), "SpatialPolygons") proj4string(rectangle) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" - shif_rect <- raster::shift(rectangle, y = 26) - shp_rect_total <- raster::bind(shif_rect,shp_total) + shif_rect <- shift(rectangle, y = 26) + shp_rect_total <- bind(shif_rect,shp_total) return(shp_rect_total) } diff --git a/R/siane_merge.R b/R/siane_merge.R index 79eb2d0..ebad679 100644 --- a/R/siane_merge.R +++ b/R/siane_merge.R @@ -1,5 +1,5 @@ #' @title Merges data and maps -#' +#'@importFrom plyr join #' @description This is a function that binds data to polygons #' From 8dffe77eb334caa4e467d971f13e4a9b134acbc8 Mon Sep 17 00:00:00 2001 From: ncarvalho Date: Thu, 29 Mar 2018 02:45:29 +0200 Subject: [PATCH 3/7] fixes in extent function --- R/siane_map.R | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/siane_map.R b/R/siane_map.R index 73d4a62..da51928 100644 --- a/R/siane_map.R +++ b/R/siane_map.R @@ -67,7 +67,7 @@ siane_map <- function(obj, canarias, year, level, scale, peninsula){ shp_total <- bind(shp_peninsula, shp_canarias_shifted) - rectangle <- as(extent(-0.5, 5, 11.6, 9), "SpatialPolygons") + rectangle <- as(extent(-0.5, 5, 9, 11.6), "SpatialPolygons") proj4string(rectangle) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" shif_rect <- shift(rectangle, y = 26) diff --git a/README.md b/README.md index 9c2e657..645142a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Now we are ready to go through the code. ``` library(devtools) -install_github("Nuniemsis/Siane") +install_github("rOpenSpain/Siane") library(pxR) # install.packages("pxR") library(Siane) library(RColorBrewer) From 3eceb0bd06d3c876427f437457c7f1e6055815eb Mon Sep 17 00:00:00 2001 From: ncarvalho Date: Sat, 7 Apr 2018 12:04:10 +0200 Subject: [PATCH 4/7] chores:improving the package description --- DESCRIPTION | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4b14b37..aa5c4d4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,9 +1,11 @@ Package: Siane Title: Explore the Spanish INE Data using this Geographic Tool Version: 0.1 -Description: A tool that makes the user able to represent spatial data over Spain - territories. It's main functionality is to bind numerical data to polygons. - It's only compatible with the spanish IGN(National Institute of Geography) maps +Description: A tool that assists the user in two tasks: the map reading process and the + data representation process. The reading process is leveraged with functions that allow + the user to find maps in the Siane repository easily, i.e. searching by map year or + administrative level. The other main functionality is to bind numerical data to polygons. + This package is only compatible with the spanish IGN(National Institute of Geography) maps and the INE(National Institute of Statistics) data. Depends: plyr, raster, rgdal, sp, methods, utils License: MIT + file LICENSE From e5b810ca10f57fd2f1f45f027cb1d16e8b49d761 Mon Sep 17 00:00:00 2001 From: ncarvalho Date: Sat, 7 Apr 2018 12:15:55 +0200 Subject: [PATCH 5/7] chores: fixing .Rbuildignore --- .Rbuildignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 28d9910..e50130e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,13 +1,8 @@ ^.*\.Rproj$ # Automatically added by RStudio, ^\.Rproj\.user$ # used for temporary files. ^README.md$ # An Rmarkdown file used to generate README.md -^cran-comments\.md$ # Comments for CRAN submission -^NEWS\.md$ # A news file written in Markdown -^\.travis\.yml$ # Used for continuous integration testing with travis -^Images$ # Images used in README Images .git -./.git .gitignore RData Siane.Rproj From a9fae35307bb19193b6df94f4b61463add5a72b3 Mon Sep 17 00:00:00 2001 From: ncarvalho Date: Sun, 6 May 2018 16:21:49 +0200 Subject: [PATCH 6/7] year license changed, authors and mantainer fields removed, change Depends to Imports --- DESCRIPTION | 3 --- LICENSE | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aa5c4d4..b0668f3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,9 +15,6 @@ Authors@R: c(person("Carlos J. Gil Bellosta", email = "cgb@datanalytics.com", role = c("aut")), person("Nuno", "Carvalho", role = c("cre", "aut"), email = "nunocarvalhodossantos@gmail.com")) -Author: Carlos J. Gil Bellosta [aut], - Nuno Carvalho [cre, aut] -Maintainer: Nuno Carvalho RoxygenNote: 6.0.1 Suggests: knitr, rmarkdown diff --git a/LICENSE b/LICENSE index 9ab6c36..b462b15 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2017 -COPYRIGHT HOLDER: Your name goes here +YEAR: 2017-2018 +COPYRIGHT HOLDER: Carlos J. Gil Bellosta, Nuno Carvalho From ee470e6ae24a2f6d1da7e940f48a190e79f315eb Mon Sep 17 00:00:00 2001 From: ncarvalho Date: Sun, 6 May 2018 16:24:23 +0200 Subject: [PATCH 7/7] Forgotten changes: Depends to Imports --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index b0668f3..15ec6a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Description: A tool that assists the user in two tasks: the map reading process administrative level. The other main functionality is to bind numerical data to polygons. This package is only compatible with the spanish IGN(National Institute of Geography) maps and the INE(National Institute of Statistics) data. -Depends: plyr, raster, rgdal, sp, methods, utils +Imports: plyr, raster, rgdal, sp, methods, utils License: MIT + file LICENSE Encoding: UTF-8 LazyData: true