I am trying to get the output of the following code into a dataframe:
library(easyPubMed)
pmid_list=['35566889','33538053', '30848212']
pmxml <- fetch_pubmed_data_by_PMID(pmid_list,format='asn.1')
require(XML)
xml_data <- xmlToList(pmxml)
According to the documentation the output is in xml. However I get the error:
Error: XML content does not seem to be XML .. Any ideas on how I can convert the output to a dataframe? Thank you!!
Not sure if you are still looking for an answer to this. Anyway, there are a few things I noticed:
pmid_listvector needs to be defined using thec()function (unlike python)easyPubMedincludes a function (see code below) to cast XML output intodata.frameAssuming you are working with
easyPubMedversion 2.22 (available on GitHub atdami82/easyPubMed), you may want to have a look at the following code.If you prefer to parse XML using the
XMLlibrary, you can do so as follows.Please note that additional help to cast PubMed records into
data.frameobjects can be found in the package vignette (e.g.,vignette("getting_started_with_easyPubMed")) as well as in the manual of thetable_articles_byAuth()function (e.g., see?easyPubMed::table_articles_byAuth).