Closed iembry closed 4 months ago
Hi @iembry
Note that these lines:
# > cff_write(jab_adverse_reactions_citation)
# Error in x[[i]] : recursive indexing failed at level 2
are trying to create a full CFF from a reference list cff_ref_lst
, but no for a full CFF list. See https://docs.ropensci.org/cffr/reference/cff_class.html#sub-classes for more info.
With the new API you may want to make these changes:
bib
with cff_read()
(or cff_read_bib()
, same results but the latter is more explicit).jab_adverse_reactions_citation
before writing with cff_modify()
.cff_write()
.See an example, you would need to adjust the paths since I created this cff from a stand-alone project (not inside the package project):
library(cffr)
bib_path <- system.file("references/Data_References.bib",
package = "jab.adverse.reactions"
)
# read in the References stored in a JabRef database
# For an in-development package use bib <- cff_read("./inst/references/Data_References.bib")
bib <- cff_read(bib_path)
# create the cff object, we can use native pipe now (|>)
# For an in-development package use jab_adverse_reactions_citation <- cff_create() |> ...
jab_adverse_reactions_citation <- cff_create("jab.adverse.reactions") |>
# Use cff_modify: this would override original references
cff_modify(references = bib)
# Write the package citation as a .cff file
temp_cff <- tempfile(fileext = ".cff")
cff_write(jab_adverse_reactions_citation, temp_cff)
#> ✔ '/tmp/RtmphjeHQ2/file6dd403d6eec.cff' generated
#> ══ Validating cff ══════════════════════════════════════════════════════════════
#> ✔ Congratulations! '/tmp/RtmphjeHQ2/file6dd403d6eec.cff' is valid
# preview
cff_read(temp_cff)
Created on 2024-05-30 with reprex v2.1.0
Hi @dieghernan, thank you for your prompt response and for the alternative course of action.
I have modified the CITATION.cff file creation code with your suggestions and it worked perfectly!
Irucka
I previously used version 0.2.0 of the cffr package with the following code to create a CITATION.cff file from a BibTeX file:
However, with the current version 1.0.1, the aforementioned workflow is no longer possible. I have attempted to read the documentation and attempt a new strategy to get the same results, but to no avail. Please refer to the error message below:
What's the correct method to create a CITATION.cff file from a BibTeX file?
Thank you.
Irucka