Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
DSCC
FSO Metadata Auto R
Commits
cbda14f5
Commit
cbda14f5
authored
Oct 22, 2021
by
Pauline Maury Laribière
Browse files
all check pass
parent
bd7affcc
Pipeline
#270125
passed with stage
in 21 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
my_package/R/api_call.R
View file @
cbda14f5
###############################################################
########################## i14y APIs ##########################
###############################################################
#' Get a codelist based on an identifier
#'
#' @param identifier the codelist's identifier
...
...
@@ -13,9 +9,6 @@
#'
#' @return response based on the export format
#' @export
#'
#' @examples
#' get_codelist(identifier='CL_NOGA_SECTION')
get_codelist
<-
function
(
identifier
,
export_format
=
"SDMX-ML"
,
version_format
=
2.1
,
...
...
@@ -38,9 +31,6 @@ get_codelist <- function(identifier,
#'
#' @return data structure
#' @export
#'
#' @examples
#' get_data_structure(identifier='HCL_NOGA', language='it')
get_data_structure
<-
function
(
identifier
,
language
=
"en"
)
{
api
<-
api_class
(
api_type
=
"dcat_data_structure"
,
...
...
@@ -63,9 +53,6 @@ get_data_structure <- function(identifier, language = "en") {
#' @return dataframe with 3 columns
#' (Code, Parent and Name in the selected language)
#' @export
#'
#' @examples
#' get_nomenclature_one_level(identifier='HCL_CH_ISCO_19_PROF', filters=my_filters, level_number=2)
get_nomenclature_one_level
<-
function
(
identifier
,
filters
,
level_number
=
1
,
...
...
@@ -96,10 +83,6 @@ get_nomenclature_one_level <- function(identifier,
#' @return dataframe columns
#' from `level_from` to `level_to` codes
#' @export
#'
#' @examples
#' get_nomenclature_multiple_levels(identifier='HCL_CH_ISCO_19_PROF',
#' filters=my_filters, level_from=2, level_to=5)
get_nomenclature_multiple_levels
<-
function
(
identifier
,
filters
,
level_from
=
1
,
...
...
@@ -114,17 +97,4 @@ get_nomenclature_multiple_levels <- function(identifier,
export_format
=
"CSV"
)
res
<-
api
$
get_response
()
# Post-processing
# fill sub groups rows with parent group's values (instead of NA)
nb_col
<-
level_to
-
level_from
+
1
group_columns
<-
names
(
res
)[
1
:
nb_col
]
res
[[
group_columns
[[
1
]]]]
<-
data.table
::
nafill
(
res
[[
group_columns
[[
1
]]]],
type
=
"locf"
)
res
[
group_columns
[
2
:
(
level_to
-
level_from
+
1
)]]
<-
res
%>%
group_by
(
group_columns
[
1
])
%>%
subset
(
select
=
group_columns
[
2
:
(
level_to
-
level_from
+
1
)])
%>%
data.table
::
nafill
(
type
=
"locf"
)
res
}
my_package/R/api_class.R
View file @
cbda14f5
...
...
@@ -14,10 +14,6 @@
#' @field api_url character. The url to make the request to.
#'
#' @importFrom methods new
#'
#' @examples
#' api <- api_class(api_type = "codelist", id = "CL_NOGA_SECTION")
#' api <- api_class(api_type = "content_configuration")
api_class
<-
setRefClass
(
"Api"
,
fields
=
list
(
...
...
my_package/R/format_request.R
View file @
cbda14f5
...
...
@@ -36,13 +36,12 @@ REQUEST_FUNCTION_MAPPING <- hash::hash(
#' Transform a hash object into a string of parameters
#' hash::hash("a" = list("1"), "b" = list("2", "3"))
#' becomes "a=1&b=2&b=3"
#'
#' @param filters hash object
#'
#' @return formatted string of parameters
#' @examples
#' filters <- hash::hash("a" = list("1"), "b" = list("2", "3"))
#' hash_to_string(filters) -> "a=1&b=2&b=3"
hash_to_string
<-
function
(
filters
)
{
string
<-
""
for
(
prop
in
ls
(
filters
))
{
...
...
my_package/man/Api-class.Rd
View file @
cbda14f5
...
...
@@ -31,7 +31,3 @@ Available are 'fr', 'de', 'it', 'en'}
}}
\examples{
api <- api_class(api_type = "codelist", id = "CL_NOGA_SECTION")
api <- api_class(api_type = "content_configuration")
}
my_package/man/get_codelist.Rd
View file @
cbda14f5
...
...
@@ -28,6 +28,3 @@ response based on the export format
\description{
Get a codelist based on an identifier
}
\examples{
get_codelist(identifier='CL_NOGA_SECTION')
}
my_package/man/get_data_structure.Rd
View file @
cbda14f5
...
...
@@ -18,6 +18,3 @@ data structure
\description{
Get the data structure
}
\examples{
get_data_structure(identifier='HCL_NOGA', language='it')
}
my_package/man/get_nomenclature_multiple_levels.Rd
View file @
cbda14f5
...
...
@@ -34,7 +34,3 @@ from `level_from` to `level_to` codes
\description{
Get multiple levels of a nomenclature (from `level_from` to `level_to`)
}
\examples{
get_nomenclature_multiple_levels(identifier='HCL_CH_ISCO_19_PROF',
filters=my_filters, level_from=2, level_to=5)
}
my_package/man/get_nomenclature_one_level.Rd
View file @
cbda14f5
...
...
@@ -31,6 +31,3 @@ dataframe with 3 columns
\description{
Get one level of a nomenclature
}
\examples{
get_nomenclature_one_level(identifier='HCL_CH_ISCO_19_PROF', filters=my_filters, level_number=2)
}
my_package/man/hash_to_string.Rd
View file @
cbda14f5
...
...
@@ -2,7 +2,9 @@
% Please edit documentation in R/format_request.R
\name{hash_to_string}
\alias{hash_to_string}
\title{Transform a hash object into a string of parameters}
\title{Transform a hash object into a string of parameters
hash::hash("a" = list("1"), "b" = list("2", "3"))
becomes "a=1&b=2&b=3"}
\usage{
hash_to_string(filters)
}
...
...
@@ -14,8 +16,6 @@ formatted string of parameters
}
\description{
Transform a hash object into a string of parameters
}
\examples{
filters <- hash::hash("a" = list("1"), "b" = list("2", "3"))
hash_to_string(filters) -> "a=1&b=2&b=3"
hash::hash("a" = list("1"), "b" = list("2", "3"))
becomes "a=1&b=2&b=3"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment