Open rkrug opened 3 months ago
A quick fix would be to add a parameter for replace_w_na
:
replace_w_na <- function(x, y = NA){
lapply(x, `%||%`, y = y)
}
and then on this line https://github.com/ropensci/openalexR/blob/558581c6dbb43c65cd2003be8545e88fd4ed4ef7/R/oa2df.R#L230
do
prepend(replace_w_na(l$author, NA_character_), "au")
But you're right, this can happen in other fields as well. rbind.data.frame
automatically converts the NA to whichever type of the non-NAs, but if all values are NA then they do remain of type logical. I'll wait to see if others can chime in.
Is there any chance that you could take a look at this? The easiest might be to define a template with the expected types, and then use these? I have only an extremely slow fix running to correct this and I am working with millions of records... Thanks.
Hi
there is a bug in the conversion from the oa results to a data.frame / tibble. When all authors of a work do not have an ORCID, the column
au_orcid
is of type'logical;' while the others are as expected are of type
character`. This is causing problems, as I want to save these as parquet files which does not work if the objects are of different type.Probably replacing
NA`` with
as.character(NA)` in the appropriate places would fix this issue. I assume the same can occur in other fields.Thanks,
Rainer