How to translate the following simple curl call to R code using RCurl?

StackOverflow https://stackoverflow.com/questions/18896952

  •  29-06-2022
  •  | 
  •  

سؤال

Consider the following commands (2 examples)

curl -H "Accept:text/plain" http://rxnav.nlm.nih.gov/REST/rxcui/866350/allrelated 

curl -i -L -H "Accept: application/xml"  http://pub.orcid.org/search/orcid-bio?q=digital-object-ids:"10.1088/0031-9155/58/3/535"

The user is able to run those on win7 command line with curl.exe installed. The RCurl package has no vignette and it has a lot of commands to choose from. How do I get the text file and XML file output using RCurl?

هل كانت مفيدة؟

المحلول

I think you can use the following :

mytxt <- getURL("http://rxnav.nlm.nih.gov/REST/rxcui/866350/allrelated", httpheader=c(Accept="text/plain"))

And :

myxml <- getURL('http://pub.orcid.org/search/orcid-bio?q=digital-object-ids:"10.1088/0031-9155/58/3/535"', httpheader=c(Accept="application/xml"))

You will find many examples in the getURL help page.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top