Hi there!
I am trying and iterative function with purrr.
This is a tibble with 2 columns. First col is a character, the second column is a list-column of one tibble with a vector character. I am adding a third list-column that is a new tibble.
To add the the third column I use a mutate and map on that column. It stops every time it finds and error. The error is a not very clear to me. I will be happy if it will return an empty row if the function doesn't get any results.
The Error is:
Error: Problem with
mutate()
columndoi_data1
.
![]()
doi_data1 = purrr::map(.x = data, .f = get_data_from_doi)
.
x nms %in% c("i", "x", "") are not all TRUE
the input is nested_doi
nested_doi <- tibble(
orcid = c("0000-0003-3685-174X"),
data = list( tibble(doi = c("10.1130/0016-7606(1997)109<1515:fositc>2.3.co",
"10.1130/0016-7606(1997)109<1515:fositc>2.3.co;2",
"10.1175/1087-3562(1999)003<0002:tdmcwc>2.0.co;2")) ))
The function I am using comes with package roadoi::oadoi_fetch I am wrapping it to work with the tibble
get_data_from_doi <- function(tibble_dois){
test <- tibble_dois %>%
mutate(doi_data = purrr::pmap(.l = list(
dois = doi,
email = "", ### PLEASE add your email here
.flatten = TRUE),
.f = roadoi::oadoi_fetch))
return(test)
}
Then I want to run this function for every row in the first tibble which has a number of dois in the example just 3, but i got some of those up to 400 dois
test <- nested_dois %>%
mutate(doi_data1 = purrr::map(.x = data,
.f = get_data_from_doi))
then I would need to open that new columns doi_data1 and filter from there, that's another story, not all those tibbles have the same columns.
Could someone point me to a better way of doing this? and one that won't stop when errors occur? Please