From 1b6f93880b4acb274fc143ed4c47f7b07206f0c8 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 6 May 2019 10:17:33 +0200 Subject: [PATCH] pkgdown docs added --- DESCRIPTION | 52 ++--- NAMESPACE | 10 +- R/to_words.R | 56 ++++++ README.md | 233 +++++++++++++++-------- docs/authors.html | 53 ++++-- docs/docsearch.css | 148 ++++++++++++++ docs/docsearch.js | 85 +++++++++ docs/favicon.ico | Bin 1397 -> 0 bytes docs/index.html | 115 ++++++++--- docs/jquery.sticky-kit.min.js | 9 - docs/pkgdown.css | 65 ++++++- docs/pkgdown.js | 165 +++++++++------- docs/pkgdown.yml | 5 + docs/reference/cadastral_references.html | 189 ++++++++++++++++++ docs/reference/cantidades.html | 60 ++++-- docs/reference/geocode_cadastral.html | 195 +++++++++++++++++++ docs/reference/index.html | 141 ++++++++------ docs/reference/spanish.html | 74 ++++--- docs/reference/to_number.html | 62 ++++-- man/geocode_cadastral.Rd | 59 ------ man/spanish.Rd | 49 ++--- man/to_number.Rd | 30 --- man/to_words.Rd | 21 ++ spanish.Rproj | 20 ++ 24 files changed, 1404 insertions(+), 492 deletions(-) create mode 100644 R/to_words.R create mode 100644 docs/docsearch.css create mode 100644 docs/docsearch.js delete mode 100644 docs/favicon.ico delete mode 100644 docs/jquery.sticky-kit.min.js create mode 100644 docs/pkgdown.yml create mode 100644 docs/reference/cadastral_references.html create mode 100644 docs/reference/geocode_cadastral.html delete mode 100644 man/geocode_cadastral.Rd delete mode 100644 man/to_number.Rd create mode 100644 man/to_words.Rd create mode 100644 spanish.Rproj diff --git a/DESCRIPTION b/DESCRIPTION index b3d6c0e..047f457 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,26 +1,26 @@ -Package: spanish -Type: Package -Title: Translate Quantities from Strings Spelled in Spanish to Integer -Version: 0.3.1 -Date: 2017-12-14 -Authors@R: person( "Jose Manuel","Vera Oteo", email = "vera.josemanuel@gmail.com", - role = c("aut","cre")) -URL: https://github.com/verajosemanuel -BugReports: https://github.com/verajosemanuel/spanish/issues -Depends: magrittr, xml2 -Description: Character vector to numerical translation in Euros from Spanish - spelled monetary quantities. Text must be previously cleaned & removed - extraneous words, symbols or cents. Quantities MUST be written in a correct - Spanish cause this isn't a grammar tool. Upper limit is up to the millions - range. -License: GPL-3 -Encoding: UTF-8 -LazyData: true -Collate: - 'geocode_cadastral.R' - 'cadastral_references-data.R' - 'to_number.R' - 'cantidades-data.R' - 'spanish.R' -RoxygenNote: 6.0.1.9000 -Suggests: testthat, tidyr +Package: spanish +Type: Package +Title: Translate Quantities from Strings Spelled in Spanish to Integer +Version: 0.3.1 +Date: 2017-12-14 +Authors@R: person( "Jose Manuel","Vera Oteo", email = "vera.josemanuel@gmail.com", + role = c("aut","cre")) +URL: https://github.com/verajosemanuel +BugReports: https://github.com/verajosemanuel/spanish/issues +Depends: magrittr, xml2 +Description: Character vector to numerical translation in Euros from Spanish + spelled monetary quantities. Text must be previously cleaned & removed + extraneous words, symbols or cents. Quantities MUST be written in a correct + Spanish cause this isn't a grammar tool. Upper limit is up to the millions + range. +License: GPL-3 +Encoding: UTF-8 +LazyData: true +Collate: + 'geocode_cadastral.R' + 'cadastral_references-data.R' + 'to_number.R' + 'cantidades-data.R' + 'spanish.R' +RoxygenNote: 6.1.1 +Suggests: testthat, tidyr diff --git a/NAMESPACE b/NAMESPACE index f139192..533c06a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,4 @@ -# Generated by roxygen2: do not edit by hand - -import(magrittr) -import(xml2) -export(to_number) -export(geocode_cadastral) +# Generated by roxygen2: do not edit by hand + +export() +export(to_words) diff --git a/R/to_words.R b/R/to_words.R new file mode 100644 index 0000000..badc249 --- /dev/null +++ b/R/to_words.R @@ -0,0 +1,56 @@ +#' From integers to spanish spelled quantities. +#' +#' +#' @keywords spanish, integers, money, quantities. +#' @param x A valid integer amount. +#' @return A string for the same integer number in spanish. +#' @export + + +to_words <- function(x) { + + if (!requireNamespace("magrittr", quietly = TRUE)) { + stop("magrittr needed for this function to work. Please install it.", + call. = FALSE) + } + + x <- round(x) + len <- nchar(x) + digits <- rev(strsplit(as.character(x), "")[[1]]) + + + units <- c("", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", + "ocho", "nueve") + names(units) <- 0:9 + + + dozens <- c("diez", "once", "doce", "trece", "catorce", "quince", + "dieciseis", " diecisiete", "dieciocho", "diecinueve") + names(dozens) <- 0:9 + + + tens <- c("veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", + "noventa") + names(tens) <- 2:9 + + + hundred <- c("ciento", "doscientos", "trescientos", "cuatrocientos", "quinientos", "seiscientos", "setecientos", + "ochocientos", "novecientos") + names(hundred) <- 1:9 + + + if (len == 1) x <- as.vector(units[digits]) + + if (len == 2) + if (x <= 19) x <- as.vector(dozens[digits[1]]) else x <- as.vector(paste0(tens[digits[2]]," y ", units[digits[1]])) + + if (len == 3) x <- as.vector(paste0(hundred[digits[3]]," ", if (as.numeric(paste0(digits[2],digits[3])) <= 19) as.vector(dozens[digits[1]]) else as.vector(paste0(tens[digits[2]]," y ", units[digits[1]])))) + + x <- gsub("unociento", "ciento ", x ) + x <- gsub("veinte y ", "veinti", x ) + x <- gsub("veinti$", "veinte", x, perl = TRUE ) + x <- gsub("veinte y $", "veinte", x, perl = TRUE ) + + return(x) + +} diff --git a/README.md b/README.md index 5cd41fb..5884cb4 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,152 @@ -# spanish: R package for functions on spanish data [![Build Status](https://travis-ci.org/rOpenSpain/spanish.svg?branch=master)](https://travis-ci.org/rOpenSpain/spanish) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/spanish)](http://cran.r-project.org/package=spanish) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/spanish)](http://cran.r-project.org/web/packages/spanish/index.html) [![Rdoc](http://www.rdocumentation.org/badges/version/spanish)](http://www.rdocumentation.org/packages/spanish) [![](https://img.shields.io/badge/blog-spanish-orange.svg?colorB=E91E63)](https://jvera.rbind.io) - -![spanish logo](man/figures/logo.png) - - - -There are some special data in spain that is not addressed by any R package or function. Mainly on data processing and NLP. -This package is my humble (and objectionable) attempt of helping programmers working with this kind of data creating some functions for it. - -### Installation: ### - -*spanish* is available on CRAN: - -``` -install.package("spanish") -``` - -Development version: - -``` -devtools::install_github("verajosemanuel/spanish") -``` - -### to_number() ### -**to_number()** is a quick & dirty function to translate spanish spelled monetary quantities into their numerical counterparts. -Given a numerical quantity spelled in spanish **to_number** translates it to integer. - -``` -to_number("dosmil ciento cuarenta y ocho") -[1] 2148 -``` -This function can be used on dataframes with lapply. Try the provided example dataframe (cantidades). -``` -cantidades$var3 <- lapply(cantidades$var2, to_number) - -head(cantidades[ , c("var2","var3")]) - var2 var3 -1 DOS 2 -2 CINCO MIL NOVECIENTOS VEINTE 5920 -3 DOS MILLONES QUINIENTOS VEINTISIETEMIL DOSCIENTOS CUARENTA Y CINCO 2527245 -4 cientoveintisietemil cuatrocientos ochenta y dos 127482 -5 Dos mil cuatrocientos noventa y seis 2496 -6 dosmil cuarenta 2040 -``` - -### to_words() ### -**to_words()** is a quick & dirty (optimization pending) function to translate integers to spanish spelled monetary quantities. -Given a numerical quantity **to_words** translates it to spanish. - -``` -to_words(3245235) -[1] "tres millones doscientos cuarenta y cincomil doscientos treinta y cinco" -``` -This function can be used on dataframes with apply. Try random numbers. -``` -a <- rnorm(n = 12,mean = 1000000,sd = 6000000) -a <- abs(a) # non negative - -> sapply(a, to_words) - [1] "un millón setecientos ochenta y cuatromil quinientos diez" "cuatro millones setecientos sesenta y seismil novecientos noventa y nueve" - [3] "cinco millones setecientos mil setecientos once" "cinco millones trescientos noventa y ochomil setecientos treinta y cuatro" - [5] "setecientos sesenta y mil cuatrocientos y cinco" "doscientos ochenta y seismil setecientos " - [7] "un millón novecientos sesenta y sietemil cincuenta y tres" "ciento noventa y seismil novecientos treinta y seis" - [9] "siete millones doscientos ochenta y ochomil cuatrocientos ochenta y cinco" "dos millones ciento y sietemil quinientos cincuenta y siete" -[11] "seis millones ochocientos ochenta y ochomil doscientos y uno" "seis millones sesentamil novecientos cuarenta y siete" -``` - -### Requirements: -- magrittr must be installed. -- to_number() needs clean text. So it must be previously cleaned & removed extraneous words, symbols or cents. -- to_number() quantities MUST be written in a correct Spanish (this is not a grammar tool). -- to_words() does not keep sign. If negative numbers are provided, their positive is used for conversion. -- The upper limit is up to the millions range in both cases. - -### TO DO - -- Try to clean text prior to be used by to_number() -- Include decimals (cents) in to_number() function -- Force to_words() keep sign -- Add Cadastral Geolocation function - +# spanish: R package for functions on spanish data [![Build Status](https://travis-ci.org/rOpenSpain/spanish.svg?branch=master)](https://travis-ci.org/rOpenSpain/spanish) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/spanish)](http://cran.r-project.org/package=spanish) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/spanish)](http://cran.r-project.org/web/packages/spanish/index.html) [![Rdoc](http://www.rdocumentation.org/badges/version/spanish)](http://www.rdocumentation.org/packages/spanish) [![](https://img.shields.io/badge/blog-spanish-orange.svg?colorB=E91E63)](https://jvera.rbind.io) + +![spanish logo](man/figures/logo.png) + + + +There are some special data in spain that is not addressed by any R package or function. Mainly on data processing and NLP. +This package is my humble (and objectionable) attempt of helping programmers working with this kind of data creating some functions for it. + +### Installation: ### + +*spanish* is available on CRAN: + +``` +install.package("spanish") +``` + +Development version: + +``` +devtools::install_github("verajosemanuel/spanish") +``` + +### to_number() ### +**to_number()** is a quick & dirty function to translate spanish spelled monetary quantities into their numerical counterparts. +Given a numerical quantity spelled in spanish **to_number** translates it to integer. + +``` +to_number("dosmil ciento cuarenta y ocho") +[1] 2148 +``` +This function can be used on dataframes with lapply. Try the provided example dataframe (cantidades). +``` +cantidades$var3 <- lapply(cantidades$var2, to_number) + +head(cantidades[ , c("var2","var3")]) + var2 var3 +1 DOS 2 +2 CINCO MIL NOVECIENTOS VEINTE 5920 +3 DOS MILLONES QUINIENTOS VEINTISIETEMIL DOSCIENTOS CUARENTA Y CINCO 2527245 +4 cientoveintisietemil cuatrocientos ochenta y dos 127482 +5 Dos mil cuatrocientos noventa y seis 2496 +6 dosmil cuarenta 2040 +``` + +### to_words() ### +**to_words()** is a quick & dirty (optimization pending) function to translate integers to spanish spelled monetary quantities. +Given a numerical quantity **to_words** translates it to spanish. + +``` +to_words(3245235) +[1] "tres millones doscientos cuarenta y cincomil doscientos treinta y cinco" +``` +This function can be used on dataframes with apply. Try random numbers. +``` +a <- rnorm(n = 12,mean = 1000000,sd = 6000000) +a <- abs(a) # non negative + +> sapply(a, to_words) + [1] "un millón setecientos ochenta y cuatromil quinientos diez" "cuatro millones setecientos sesenta y seismil novecientos noventa y nueve" + [3] "cinco millones setecientos mil setecientos once" "cinco millones trescientos noventa y ochomil setecientos treinta y cuatro" + [5] "setecientos sesenta y mil cuatrocientos y cinco" "doscientos ochenta y seismil setecientos " + [7] "un millón novecientos sesenta y sietemil cincuenta y tres" "ciento noventa y seismil novecientos treinta y seis" + [9] "siete millones doscientos ochenta y ochomil cuatrocientos ochenta y cinco" "dos millones ciento y sietemil quinientos cincuenta y siete" +[11] "seis millones ochocientos ochenta y ochomil doscientos y uno" "seis millones sesentamil novecientos cuarenta y siete" +``` + + +### geocode_cadastral() ### +**geocode_cadastral** obtains longitude/latitude from valid cadastral references or kml files from catastro. + +``` +geocode_cadastral("0636105UF3403N", parse_files = FALSE) + +[1] "36.5209422288168,-4.89298751473745" + +``` + +Use lapply to geocode cadastral references from dataframe columns. + +``` +cadastral_references$new <- lapply(cadastral_references$cadref1, geocode_cadastral) + +cadastral_references + cadref1 cadref2 new +1 2614501VK6621S 1449804NH1014N -3.44129716598736,40.3007548071216 +2 2715807VK6621S 3880109CD6038S -3.44034755388475,40.3008975152619 +3 2744702DF3824D 9501722DD6890B 2.19479121426678,41.4065056978248 +4 0944328DF3804D 1617647TF8611F 2.17206636096108,41.4071068008502 +5 8742806DF2884B 7893306CS7479S 2.14651391794721,41.4046077850113 +6 9314903NH3591C 9701703XG8890B -8.51948430067999,42.9131469314961 +``` + +separate generated geocode "new" into columns (lon/lat) usign tidyr + +``` +library(tidyr) + +separate(cadastral_references, new, into = c('longitude','latitude'), sep = "," ) + + cadref1 cadref2 longitude latitude +1 2614501VK6621S 1449804NH1014N -3.44129716598736 40.3007548071216 +2 2715807VK6621S 3880109CD6038S -3.44034755388475 40.3008975152619 +3 2744702DF3824D 9501722DD6890B 2.19479121426678 41.4065056978248 +4 0944328DF3804D 1617647TF8611F 2.17206636096108 41.4071068008502 +5 8742806DF2884B 7893306CS7479S 2.14651391794721 41.4046077850113 +6 9314903NH3591C 9701703XG8890B -8.51948430067999 42.9131469314961 + +``` + +When folder is source. We may process each kml the same way as remote URL. + +``` + + files <- list.files("folder", full.names = T) + + for (f in files) { + coords <- geocode_cadastral(f, parse_files = TRUE) + df <- as.data.frame(rbind(df , as.data.frame(coords, stringsAsFactors = F ))) + } + +``` + +separate lat/lon into columns the same as before + +``` + + df <- tidyr::separate(coords, into = c("longitude","latitude"), sep = "," ) + +``` + + + +### Requirements: +- magrittr must be installed. +- to_number() needs clean text. So it must be previously cleaned & removed extraneous words, symbols or cents. +- to_number() quantities MUST be written in a correct Spanish (this is not a grammar tool). +- to_words() does not keep sign. If negative numbers are provided, their positive is used for conversion. +- The upper limit is up to the millions range in both cases. +- geocode_cadastral() requests to catastro website. So notice if website is alive and working. + +# BE WARNED: You'll be banned if many requests to catastro are made in short time. # +- Because of that geocode_cadastral() waits two seconds between requests. + + +### TO DO + +- Try to clean text prior to be used by to_number() +- Include decimals (cents) in to_number() function +- Force to_words() keep sign + + diff --git a/docs/authors.html b/docs/authors.html index 653bb18..bce89f9 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,38 +1,45 @@ - + -Authors • spanish +Authors • spanish - + - - + + - + - + + + + - - - + + + + + + - + + @@ -83,15 +96,15 @@ -
-
+
+
  • -

    Jose Manuel Vera Oteo. Author, maintainer. +

    Jose Manuel Vera Oteo. Author, maintainer.

@@ -107,11 +120,13 @@

Authors

-

Site built with pkgdown.

+

Site built with pkgdown 1.3.0.

-
+ + + diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 0000000..e5f1fe1 --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 0000000..b35504c --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/favicon.ico b/docs/favicon.ico deleted file mode 100644 index 01edfb10ce88adf2ff64b4ac3b014d602f235d09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1397 zcmV-*1&aEKP)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x00(qQO+^Rd0v8T5B;ufega7~pc}YY;R7l62mRW3+RTRhn z=iKj`r8C3Kbh=CnBq|{wTNEN{5R@Vs31TD2VnvJ~i*ZYQ;6A-o`!HnOGY zi_u`J4}e9|xP(S3s9m5PI@6)kS-yLZ4{hzxPMN}ayx+OMd(Z!zbH76(f+8kjTJ@E^ zu)K(FQ`USUzV!yWHPmt1IoW6qe{YWFz`%M-ZCF8p7g<%`2{e<5*>qBWeGCUvrbp=i z4^>dxgR=Z-%d;79O&;oG(@mF3M>Q zQ-~J|B6$N^qjU_Ukbk%+XMr*Ifml@L&Q zL^`^qvy*4fg3l|R-ST%EZ?Li95%z6mRW%CLx{sYE{Y||&kU&I(qH`ea=Fwl-Pcf6N#PJ;*Ub+<^1532^>>1NJ4a*jNyKg#6GCjwFmM)PA!&FSW$qeinY00G31LXs<}_g#!0$tNa^Zb-#pG(ghZ z3m|38$NjNUmmz#XA^;7fZCY3ZAleV!XHph0q zn@F$fxnf3w^)b!1+`eM1nQvoV%a!$#FJwk?CO}H$Wq;Trx^pOiI$!96P<2~zBiT8pP#lr^>WL3s$GV--Mxk+gXfB**N_tC^wK-k-; zzJhky$>qjnurSmjimKw_6W}AdG*0UY!>{r9C$5=c^ARs}c{_A&9CQNRmbps+RIu_B zdx#d;?zaPxH~ppaY&U?rlpP>Wi?n9brDIb{7J>j3xKo%F6Y9&RS)kYZx}Nb)+2Riw zU}?5wV{gaaaFvJYwd-9S+POEsP6_bC(rdTy^snU8xU}B{_A!^TiYnVfRIaQC-QFRw z?zUWIN>wNoQC6k0Dp}bh&jQUN-dRbDU$9)>=do;+exN~`j+=uSB!;0u;)S-yO$5LN z3i7b}M^pW~1CfZb0NB8X;b_{3ubgO`$6B=st~Ep<3jipjN_IGFSE>~U5a@j91myx%H)izqsLZGi%;hBvZFq_M)3IRdATdWt#YW zquGB|+N5B4&|KzS6=vRM+w(;6VIt46Ci{gsb<7+bKyTi1l+^Zssj0O+b+ - + -Translate Quantities from Strings Spelled in Spanish to Integer • spanish - - - - +Translate Quantities from Strings Spelled in Spanish to Integer • spanish + + + + - @@ -27,13 +27,18 @@
-
+ +

spanish logo

There are some special data in spain that is not addressed by any R package or function. Mainly on data processing and NLP. This package is my humble (and objectionable) attempt of helping programmers working with this kind of data creating some functions for it.

@@ -76,7 +82,7 @@

spanish is available on CRAN:

install.package("spanish")

Development version:

-
devtools::install_github("verajosemanuel/spanish")
+
devtools::install_github("verajosemanuel/spanish")

@@ -114,6 +120,52 @@

[9] "siete millones doscientos ochenta y ochomil cuatrocientos ochenta y cinco" "dos millones ciento y sietemil quinientos cincuenta y siete" [11] "seis millones ochocientos ochenta y ochomil doscientos y uno" "seis millones sesentamil novecientos cuarenta y siete"

+
+

+geocode_cadastral()

+

geocode_cadastral obtains longitude/latitude from valid cadastral references or kml files from catastro.

+
geocode_cadastral("0636105UF3403N", parse_files = FALSE)
+
+[1] "36.5209422288168,-4.89298751473745"
+
+

Use lapply to geocode cadastral references from dataframe columns.

+
cadastral_references$new <- lapply(cadastral_references$cadref1, geocode_cadastral)
+
+cadastral_references
+         cadref1        cadref2                                new
+1 2614501VK6621S 1449804NH1014N -3.44129716598736,40.3007548071216
+2 2715807VK6621S 3880109CD6038S -3.44034755388475,40.3008975152619
+3 2744702DF3824D 9501722DD6890B  2.19479121426678,41.4065056978248
+4 0944328DF3804D 1617647TF8611F  2.17206636096108,41.4071068008502
+5 8742806DF2884B 7893306CS7479S  2.14651391794721,41.4046077850113
+6 9314903NH3591C 9701703XG8890B -8.51948430067999,42.9131469314961
+

separate generated geocode “new” into columns (lon/lat) usign tidyr

+
library(tidyr)
+
+separate(cadastral_references, new, into = c('longitude','latitude'), sep = "," )
+
+         cadref1        cadref2         longitude         latitude
+1 2614501VK6621S 1449804NH1014N -3.44129716598736 40.3007548071216
+2 2715807VK6621S 3880109CD6038S -3.44034755388475 40.3008975152619
+3 2744702DF3824D 9501722DD6890B  2.19479121426678 41.4065056978248
+4 0944328DF3804D 1617647TF8611F  2.17206636096108 41.4071068008502
+5 8742806DF2884B 7893306CS7479S  2.14651391794721 41.4046077850113
+6 9314903NH3591C 9701703XG8890B -8.51948430067999 42.9131469314961
+
+

When folder is source. We may process each kml the same way as remote URL.

+

+ files <- list.files("folder", full.names = T)
+
+ for (f in files) {
+  coords <- geocode_cadastral(f, parse_files = TRUE)
+  df <- as.data.frame(rbind(df , as.data.frame(coords, stringsAsFactors = F )))
+ }
+
+

separate lat/lon into columns the same as before

+

+ df <- tidyr::separate(coords, into = c("longitude","latitude"), sep = "," )
+ 
+

Requirements:

@@ -123,8 +175,16 @@

  • to_number() quantities MUST be written in a correct Spanish (this is not a grammar tool).
  • to_words() does not keep sign. If negative numbers are provided, their positive is used for conversion.
  • The upper limit is up to the millions range in both cases.
  • +
  • geocode_cadastral() requests to catastro website. So notice if website is alive and working.
  • +
    +
    +

    +BE WARNED: You’ll be banned if many requests to catastro are made in short time.

    +
      +
    • Because of that geocode_cadastral() waits two seconds between requests.
    • +

    TO DO

    @@ -132,42 +192,51 @@

  • Try to clean text prior to be used by to_number()
  • Include decimals (cents) in to_number() function
  • Force to_words() keep sign
  • -
  • Add Cadastral Geolocation function
  • +
    -
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.3.0.

    -
    + + diff --git a/docs/jquery.sticky-kit.min.js b/docs/jquery.sticky-kit.min.js deleted file mode 100644 index e2a3c6d..0000000 --- a/docs/jquery.sticky-kit.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net -*/ -(function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k)); -if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
    "))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q, -u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}), -a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize", -y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + body > .container { display: flex; - padding-top: 60px; - min-height: calc(100vh); + height: 100%; flex-direction: column; + + padding-top: 60px; } body > .container .row { - flex: 1; + flex: 1 0 auto; } footer { @@ -16,6 +35,7 @@ footer { border-top: 1px solid #e5e5e5; color: #666; display: flex; + flex-shrink: 0; } footer p { margin-bottom: 0; @@ -38,6 +58,17 @@ img { max-width: 100%; } +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + /* Section anchors ---------------------------------*/ a.anchor { @@ -68,7 +99,7 @@ a.anchor { .contents h1, .contents h2, .contents h3, .contents h4 { padding-top: 60px; - margin-top: -60px; + margin-top: -40px; } /* Static header placement on mobile devices */ @@ -100,16 +131,19 @@ a.anchor { margin-bottom: 0.5em; } +.orcid { + height: 16px; + vertical-align: middle; +} + /* Reference index & topics ----------------------------------------------- */ .ref-index th {font-weight: normal;} -.ref-index h2 {font-size: 20px;} .ref-index td {vertical-align: top;} +.ref-index .icon {width: 40px;} .ref-index .alias {width: 40%;} -.ref-index .title {width: 60%;} - -.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} .ref-index .title {width: 60%;} .ref-arguments th {text-align: right; padding-right: 10px;} @@ -187,3 +221,16 @@ a.sourceLine:hover { .hasCopyButton:hover button.btn-copy-ex { visibility: visible; } + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 64b20df..eb7e83d 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -1,94 +1,115 @@ -$(function() { - - $("#sidebar") - .stick_in_parent({offset_top: 40}) - .on('sticky_kit:bottom', function(e) { - $(this).parent().css('position', 'static'); - }) - .on('sticky_kit:unbottom', function(e) { - $(this).parent().css('position', 'relative'); +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $("#sidebar") + .stick_in_parent({offset_top: 40}) + .on('sticky_kit:bottom', function(e) { + $(this).parent().css('position', 'static'); + }) + .on('sticky_kit:unbottom', function(e) { + $(this).parent().css('position', 'relative'); + }); + + $('body').scrollspy({ + target: '#sidebar', + offset: 60 }); - $('body').scrollspy({ - target: '#sidebar', - offset: 60 - }); + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } - var cur_path = paths(location.pathname); - $("#navbar ul li a").each(function(index, value) { - if (value.text == "Home") - return; - if (value.getAttribute("href") === "#") - return; - - var path = paths(value.pathname); - if (is_prefix(cur_path, path)) { - // Add class to parent
  • , and enclosing
  • if in dropdown - var menu_anchor = $(value); + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); menu_anchor.parent().addClass("active"); menu_anchor.closest("li.dropdown").addClass("active"); } }); -}); -function paths(pathname) { - var pieces = pathname.split("/"); - pieces.shift(); // always starts with / + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } - var end = pieces[pieces.length - 1]; - if (end === "index.html" || end === "") - pieces.pop(); - return(pieces); -} + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); -function is_prefix(needle, haystack) { - if (needle.length > haystack.lengh) - return(false); + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } - for (var i = 0; i < haystack.length; i++) { - if (needle[i] != haystack[i]) - return(false); - } + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } - return(true); -} + return(haystack.length); + } -/* Clipboard --------------------------*/ + /* Clipboard --------------------------*/ -function changeTooltipMessage(element, msg) { - var tooltipOriginalTitle=element.getAttribute('data-original-title'); - element.setAttribute('data-original-title', msg); - $(element).tooltip('show'); - element.setAttribute('data-original-title', tooltipOriginalTitle); -} + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); + } -if(Clipboard.isSupported()) { - $(document).ready(function() { - var copyButton = ""; + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; - $(".examples").addClass("hasCopyButton"); + $(".examples, div.sourceCode").addClass("hasCopyButton"); - // Insert copy buttons: - $(copyButton).prependTo(".hasCopyButton"); + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); - // Initialize tooltips: - $('.btn-copy-ex').tooltip({container: 'body'}); + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); - // Initialize clipboard: - var clipboardBtnCopies = new Clipboard('[data-clipboard-copy]', { - text: function(trigger) { - return trigger.parentNode.textContent; - } - }); + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent; + } + }); - clipboardBtnCopies.on('success', function(e) { - changeTooltipMessage(e.trigger, 'Copied!'); - e.clearSelection(); - }); + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); - clipboardBtnCopies.on('error', function() { - changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); }); - }); -} - + } +})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 0000000..1c6f8ef --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,5 @@ +pandoc: '2.6' +pkgdown: 1.3.0 +pkgdown_sha: ~ +articles: [] + diff --git a/docs/reference/cadastral_references.html b/docs/reference/cadastral_references.html new file mode 100644 index 0000000..70fbff1 --- /dev/null +++ b/docs/reference/cadastral_references.html @@ -0,0 +1,189 @@ + + + + + + + + +Cadastral references test data — cadastral_references • spanish + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Randomly selected data from catastro to test geocode_cadastral function

    + +
    + +
    data(cadastral_references)
    + +

    Format

    + +

    A data frame.

    + +

    Source

    + +

    Sede Electrónica del Catastro

    + +

    References

    + +

    Catastro. Ministerio de Hacienda y función pública. +(Catastro)

    + + +

    Examples

    +
    ## source is cadastral reference number ## + +geocode_cadastral("0636105UF3403N", parse_files = FALSE)
    #> Error in geocode_cadastral("0636105UF3403N", parse_files = FALSE): no se pudo encontrar la función "geocode_cadastral"
    +## Use lapply to geocode cadastral references from dataframe columns. + +cadastral_references$new <- lapply(cadastral_references$cadref1, geocode_cadastral)
    #> Error in match.fun(FUN): objeto 'geocode_cadastral' no encontrado
    +## separate previously generated "new" data into columns usign tidyr + +library(tidyr)
    #> Warning: package 'tidyr' was built under R version 3.5.2
    #> +#> Attaching package: 'tidyr'
    #> The following object is masked from 'package:magrittr': +#> +#> extract
    separate(cadastral_references, new, into = c('longitude','latitude'), sep = "," )
    #> Error: `var` must evaluate to a single number or a column name, not a function
    +## source is folder. A loop is needed to process each kml file ## + +
    # NOT RUN { +files <- list.files("folder", full.names = T) + +for (f in files) { + coords <- geocode_cadastral(f, parse_files = TRUE) + d <- as.data.frame(rbind(d , as.data.frame(coords, stringsAsFactors = F ))) +} + +# separate lat/lon into columns if you prefer using tidyr +d <- tidyr::separate(coords, into = c("longitude","latitude"), sep = "," ) +# }
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cantidades.html b/docs/reference/cantidades.html index b3b95fe..aa1c323 100644 --- a/docs/reference/cantidades.html +++ b/docs/reference/cantidades.html @@ -1,40 +1,47 @@ - + -Cantidades test data — cantidades • spanish +Cantidades test data — cantidades • spanish - + - - + + - + - + + + + - - - + + + + + + - + +
  • @@ -85,17 +98,21 @@ -
    +
    +

    Randomly generated spanish spelled monetary integers to test to_number function

    +
    -
    data(cantidades)
    +
    data(cantidades)

    Format

    @@ -103,11 +120,12 @@

    FormatExamples

    -
    to_number("mil trescientos noventa y dos")
    #> [1] 1392
    +
    to_number("mil trescientos noventa y dos")
    #> Error in to_number("mil trescientos noventa y dos"): no se pudo encontrar la función "to_number"
    ## testing provided dataframe: cantidades -cantidades$var3 <- lapply(cantidades$var2, to_number)
    +cantidades$var3 <- lapply(cantidades$var2, to_number)
    #> Error in match.fun(FUN): objeto 'to_number' no encontrado
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.3.0.

    -
    + + + diff --git a/docs/reference/geocode_cadastral.html b/docs/reference/geocode_cadastral.html new file mode 100644 index 0000000..264f4c1 --- /dev/null +++ b/docs/reference/geocode_cadastral.html @@ -0,0 +1,195 @@ + + + + + + + + +geocode by longitude and latitude from cadastral references. — geocode_cadastral • spanish + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Get longitude/latitude from valid cadastral ref. or kml files from catastro.

    + +
    + +
    geocode_cadastral(x, parse_files)
    + +

    Arguments

    + + + + + + + + + + +
    x

    A valid spanish cadastral reference.

    parse_files

    bool. Default to FALSE. Set TRUE if source are KML files.

    + +

    Value

    + +

    A string for longitude/latitude if found. NA if not found.

    + +

    Warning

    + +

    You may be banned if many requests in short time are made.

    + + +

    Examples

    +
    ## source is cadastral reference number ## + +geocode_cadastral("0636105UF3403N", parse_files = FALSE)
    #> Error in geocode_cadastral("0636105UF3403N", parse_files = FALSE): no se pudo encontrar la función "geocode_cadastral"
    + "36.5209422288168,-4.89298751473745"
    #> [1] "36.5209422288168,-4.89298751473745"
    +## Use lapply to geocode cadastral references from dataframe columns. + +cadastral_references$new <- lapply(cadastral_references$cadref1, geocode_cadastral)
    #> Error in match.fun(FUN): objeto 'geocode_cadastral' no encontrado
    +## separate previously generated "new" data into columns usign tidyr + +library(tidyr) +separate(cadastral_references, new, into = c('longitude','latitude'), sep = "," )
    #> Error: `var` must evaluate to a single number or a column name, not a function
    +## source is folder. A loop is needed to process each kml file ## + +
    # NOT RUN { +files <- list.files("folder", full.names = T) + +for (f in files) { + coords <- geocode_cadastral(f, parse_files = TRUE) + d <- as.data.frame(rbind(d , as.data.frame(coords, stringsAsFactors = F ))) +} + +# separate lat/lon into columns if you prefer using tidyr +d <- tidyr::separate(coords, into = c("longitude","latitude"), sep = "," ) +# }
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html index 273734c..da88a99 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,38 +1,45 @@ - + -Function reference • spanish +Function reference • spanish - + - - + + - + - + + + + - - - + + + + + + - + +
    @@ -83,52 +96,60 @@ -
    -
    +
    +
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    All functions

    -

    -
    -

    data

    -

    Cantidades test data

    -

    spanish

    -

    spanish: A package for spanish related data functions.

    -

    to_number

    -

    translate spanish spelled quantities into their integer counterparts.

    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    cadastral_references

    +

    Cadastral references test data

    +

    cantidades

    +

    Cantidades test data

    +

    geocode_cadastral()

    +

    geocode by longitude and latitude from cadastral references.

    +

    spanish

    +

    spanish: A package for spanish related data functions.

    +

    to_number()

    +

    translate spanish spelled quantities into their integer counterparts.

    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.3.0.

    -
    + + + diff --git a/docs/reference/spanish.html b/docs/reference/spanish.html index 58d4a59..bd199b4 100644 --- a/docs/reference/spanish.html +++ b/docs/reference/spanish.html @@ -1,41 +1,48 @@ - + -spanish: A package for spanish related data functions. — spanish • spanish +spanish: A package for spanish related data functions. — spanish • spanish - + - - + + - + - + + + + - - - + + + +to_number() and to_words()" /> + + + - + +
    @@ -86,16 +99,20 @@ -
    +
    +

    The spanish package provides two important functions: -to_number() and geocode_cadastral()

    +to_number() and to_words()

    +

    to_number()

    @@ -108,16 +125,13 @@

    t The upper limit is up to the millions range. Cents must be removed. (in my TODO list to parse cents part)

    -

    geocode_cadastral()

    +

    to_words()

    -

    Geocode by longitude and latitude from cadastral references. -Get longitude/latitude from valid cadastral ref. or kml files from catastro.

    - -

    Warning

    - -

    You may be banned if many requests in short time are made -to cadastral website. Please be warned.

    +

    Allows you to translate to words numerical quantities in integer. +Floating point numbers will lose every number after the decimal separator. +Quantities MUST be non negative because negative numbers will be converted to positive +The upper limit is up to the millions range.

    @@ -127,9 +141,7 @@

    Contents

  • to_number()
  • -
  • geocode_cadastral()
  • - -
  • Warning
  • +
  • to_words()
  • @@ -141,11 +153,13 @@

    Contents

    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.3.0.

    - + + + diff --git a/docs/reference/to_number.html b/docs/reference/to_number.html index ccca6e0..6a3e107 100644 --- a/docs/reference/to_number.html +++ b/docs/reference/to_number.html @@ -1,43 +1,50 @@ - + -translate spanish spelled quantities into their integer counterparts. — to_number • spanish +translate spanish spelled quantities into their integer counterparts. — to_number • spanish - + - - + + - + - + + + + - - - + + + + + + - + + @@ -88,22 +101,26 @@ -
    +
    +

    Allows you to translate to integer numerical words spelled in spanish. Text must be previously cleaned & removed extraneous words or symbols Quantities MUST be written in a correct Spanish (this is not a grammar tool) The upper limit is up to the millions range. Cents must be removed.

    +
    to_number(x)
    -

    Arguments

    +

    Arguments

    @@ -114,11 +131,12 @@

    Ar

    Examples

    -
    to_number("mil trescientos noventa y dos")
    #> [1] 1392
    +
    to_number("mil trescientos noventa y dos")
    #> Error in to_number("mil trescientos noventa y dos"): no se pudo encontrar la función "to_number"
    1392
    #> [1] 1392
    ## Example dataframe is provided: cantidades -cantidades$var3 <- lapply(cantidades$var2, to_number)
    +cantidades$var3 <- lapply(cantidades$var2, to_number)
    #> Error in match.fun(FUN): objeto 'to_number' no encontrado
    +
    -

    Site built with pkgdown.

    +

    Site built with pkgdown 1.3.0.

    - + + + diff --git a/man/geocode_cadastral.Rd b/man/geocode_cadastral.Rd deleted file mode 100644 index 47829ea..0000000 --- a/man/geocode_cadastral.Rd +++ /dev/null @@ -1,59 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/geocode_cadastral.R -\name{geocode_cadastral} -\alias{geocode_cadastral} -\title{geocode by longitude and latitude from cadastral references.} -\usage{ -geocode_cadastral(x, parse_files) -} -\arguments{ -\item{x}{A valid spanish cadastral reference.} - -\item{parse_files}{bool. Default to FALSE. Set TRUE if source are KML files.} -} -\value{ -A string for longitude/latitude if found. NA if not found. -} -\description{ -Get longitude/latitude from valid cadastral ref. or kml files from catastro. -} -\section{Warning}{ - You may be banned if many requests in short time are made. -} - -\examples{ -## source is cadastral reference number ## - -geocode_cadastral("0636105UF3403N", parse_files = FALSE) - - "36.5209422288168,-4.89298751473745" - -## Use lapply to geocode cadastral references from dataframe columns. - -cadastral_references$new <- lapply(cadastral_references$cadref1, geocode_cadastral) - -## separate previously generated "new" data into columns usign tidyr - -library(tidyr) -separate(cadastral_references, new, into = c('longitude','latitude'), sep = "," ) - -## source is folder. A loop is needed to process each kml file ## - -\dontrun{ -files <- list.files("folder", full.names = T) - -for (f in files) { - coords <- geocode_cadastral(f, parse_files = TRUE) - d <- as.data.frame(rbind(d , as.data.frame(coords, stringsAsFactors = F ))) -} - -# separate lat/lon into columns if you prefer using tidyr -d <- tidyr::separate(coords, into = c("longitude","latitude"), sep = "," ) -} -} -\keyword{cadastral} -\keyword{cadastre,} -\keyword{geocoding,} -\keyword{latitude,} -\keyword{longitude,} -\keyword{reference.} diff --git a/man/spanish.Rd b/man/spanish.Rd index 4851d5c..f59b85d 100644 --- a/man/spanish.Rd +++ b/man/spanish.Rd @@ -1,28 +1,21 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spanish.R -\docType{package} -\name{spanish} -\alias{spanish} -\alias{spanish-package} -\title{spanish: A package for spanish related data functions.} -\description{ -The spanish package provides two important functions: -to_number() and to_words() -} -\section{to_number()}{ - -Translate spanish spelled quantities into their integer counterparts. -Allows you to translate to integer numerical words spelled in spanish. -Text must be previously cleaned & removed extraneous words or symbols. -Quantities MUST be written in a correct Spanish (this is not a grammar tool) -The upper limit is up to the millions range. Cents must be removed. -(in my TODO list to parse cents part) -} -\section{to_words()}{ - -Allows you to translate to words numerical quantities in integer. -Floating point numbers will lose every number after the decimal separator. -Quantities MUST be non negative because negative numbers will be converted to positive -The upper limit is up to the millions range. -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/spanish.R +\docType{package} +\name{spanish} +\alias{spanish} +\alias{spanish-package} +\title{spanish: A package for spanish related data functions.} +\description{ +The spanish package provides two important functions: +to_number() and geocode_cadastral() +} +\section{to_number()}{ + +Translate spanish spelled quantities into their integer counterparts. +Allows you to translate to integer numerical words spelled in spanish. +Text must be previously cleaned & removed extraneous words or symbols. +Quantities MUST be written in a correct Spanish (this is not a grammar tool) +The upper limit is up to the millions range. Cents must be removed. +(in my TODO list to parse cents part) +} + diff --git a/man/to_number.Rd b/man/to_number.Rd deleted file mode 100644 index e5ea5fe..0000000 --- a/man/to_number.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/to_number.R -\name{to_number} -\alias{to_number} -\title{translate spanish spelled quantities into their integer counterparts.} -\usage{ -to_number(x) -} -\arguments{ -\item{x}{A spanish spelled number.} -} -\description{ -Allows you to translate to integer numerical words spelled in spanish. -Text must be previously cleaned & removed extraneous words or symbols -Quantities MUST be written in a correct Spanish (this is not a grammar tool) -The upper limit is up to the millions range. Cents must be removed. -} -\examples{ -to_number("mil trescientos noventa y dos") - -1392 - -## Example dataframe is provided: cantidades - -cantidades$var3 <- lapply(cantidades$var2, to_number) - -} -\keyword{currency,} -\keyword{euros} -\keyword{money,} diff --git a/man/to_words.Rd b/man/to_words.Rd new file mode 100644 index 0000000..9527fcf --- /dev/null +++ b/man/to_words.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/to_words.R +\name{to_words} +\alias{to_words} +\title{From integers to spanish spelled quantities.} +\usage{ +to_words(x) +} +\arguments{ +\item{x}{A valid integer amount.} +} +\value{ +A string for the same integer number in spanish. +} +\description{ +From integers to spanish spelled quantities. +} +\keyword{integers,} +\keyword{money,} +\keyword{quantities.} +\keyword{spanish,} diff --git a/spanish.Rproj b/spanish.Rproj new file mode 100644 index 0000000..b9255bc --- /dev/null +++ b/spanish.Rproj @@ -0,0 +1,20 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source