Skip to content

Commit 9f9f2e5

Browse files
authored
Merge pull request #23 from sckott/master
add OKmaps readme footer image
2 parents 9377d50 + 64ed256 commit 9f9f2e5

File tree

8 files changed

+31
-15
lines changed

8 files changed

+31
-15
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Description: Client for the OpenAIRE API.
66
that is it does not give direct access to publication files and it
77
does not provide access to the whole information space since the
88
number of total results returned by one query is limited to 10,000.
9-
Version: 0.1.6.9433
9+
Version: 0.1.7.9210
1010
Authors@R: c(
1111
person("Najko", "Jahn", role = c("aut", "cre"),
1212
email = "[email protected]"),

R/roa_projects.R

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#' roa_projects(call_id = "FP7-PEOPLE-2010-IRSES")
2929
#' roa_projects(title = "open", size = 3)
3030
#'
31-
#' roa_projects(dataset_id = "")
32-
#'
3331
#' # formats
3432
#' roa_projects(org = "UGOE", size = 3, format = "tsv")
3533
#' roa_projects(org = "UGOE", size = 3, format = "csv")
@@ -68,22 +66,22 @@ roa_projects <- function(grant_id = NULL, publication_id = NULL,
6866
}
6967

7068
xml_names <- c(
71-
grantID = "//code",
72-
acronym = "//acronym",
73-
title = "//title",
74-
startdate = "//startdate",
75-
enddate = "//enddate",
76-
callidentifier = "//callidentifier",
77-
ecsc39 = "//ecsc39",
78-
funding_level_0 = "//funding_level_0/name"
69+
grantID = ".//code",
70+
acronym = ".//acronym",
71+
title = ".//title",
72+
startdate = ".//startdate",
73+
enddate = ".//enddate",
74+
callidentifier = ".//callidentifier",
75+
ecsc39 = ".//ecsc39",
76+
funding_level_0 = ".//funding_level_0/name"
7977
)
8078

8179
parse_project <- function(x) {
8280
x <- xml2::read_xml(x$content)
8381
results <- xml2::xml_find_all(x, xpath = '//results/result')
8482
lapply(results, function(z) {
8583
lapply(xml_names, function(w) {
86-
xml2::xml_text(xml2::xml_find_all(z, w))
84+
xml2::xml_text(xml2::xml_find_all(z, w)) %|m|% NA_character_
8785
})
8886
})
8987
}

R/utils.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
oa_base <- function() "http://api.openaire.eu/"
33

44
`%||%` <- function(x, y) if (is.null(x)) y else x
5+
`%|m|%` <- function(x, y) {
6+
if (length(x) == 0) return(y)
7+
if (is.null(x) || !nzchar(x)) y else x
8+
}
59

610
comp <- function(x) Filter(Negate(is.null), x)
711

README.Rmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,6 @@ roa_projects(org = "UGOE", size = 10)
8282

8383
* Please [report any issues or bugs](https://github.com/njahn82/ropenaire/issues).
8484
* License: MIT ©Najko Jahn
85+
86+
[![okmaps_footer](tools/github-banner-okmaps-contribution.png)](https://openknowledgemaps.org/)
87+

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,5 @@ roa_projects(org = "UGOE", size = 10)
170170

171171
* Please [report any issues or bugs](https://github.com/njahn82/ropenaire/issues).
172172
* License: MIT ©Najko Jahn
173+
174+
[![okmaps_footer](tools/github-banner-okmaps-contribution.png)](https://openknowledgemaps.org/)

man/roa_projects.Rd

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-roa_projects.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@ test_that("roa_projects returns correct class", {
88
expect_is(a, "data.frame")
99
expect_is(a, "tbl_df")
1010
expect_is(a$grantID, "character")
11-
expect_gt(NROW(a), 10)
11+
expect_named(a, c('grantID', 'acronym', 'title', 'startdate',
12+
'enddate', 'callidentifier', 'ecsc39', 'funding_level_0'))
13+
})
14+
15+
test_that("roa_projects works with eg that used to fail due to missing data", {
16+
skip_on_cran()
17+
18+
a <- roa_projects(keywords = "open science", start_year = "2009")
19+
20+
expect_is(a, "data.frame")
21+
expect_is(a, "tbl_df")
22+
expect_gt(NROW(a), 0)
1223
})
1324

1425
test_that("roa_projects fails well", {
7.63 KB
Loading

0 commit comments

Comments
 (0)