Skip to content

Instantly share code, notes, and snippets.

@briatte
Created July 19, 2013 23:55

Revisions

  1. briatte created this gist Jul 19, 2013.
    35 changes: 35 additions & 0 deletions extractJournal.log.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    > # Get data for 2011
    > query <- c("cbt" = "'cognitive behavior therapy' OR 'cognitive behavioral therapy' OR 'cognitive therapy' AND 2011[DP]")
    > pub.efetch <- searchPubmed(query)
    Searching (downloading 1718 articles)
    Completed download from PubMed.
    > cbt_2011 <- extractJournal()
    XML declaration allowed only at the start of the document
    StartTag: invalid element name
    Error: 1: XML declaration allowed only at the start of the document
    2: StartTag: invalid element name
    > traceback()
    5: stop(e)
    4: (function (msg, ...)
    {
    if (length(grep("\\\n$", msg)) == 0)
    paste(msg, "\n", sep = "")
    if (immediate)
    cat(msg)
    if (length(msg) == 0) {
    e = simpleError(paste(1:length(messages), messages, sep = ": ",
    collapse = ""))
    class(e) = c(class, class(e))
    stop(e)
    }
    messages <<- c(messages, msg)
    })(character(0))
    3: .Call("RS_XML_ParseTree", as.character(file), handlers, as.logical(ignoreBlanks),
    as.logical(replaceEntities), as.logical(asText), as.logical(trim),
    as.logical(validate), as.logical(getDTD), as.logical(isURL),
    as.logical(addAttributeNamespaces), as.logical(useInternalNodes),
    as.logical(isHTML), as.logical(isSchema), as.logical(fullNamespaceInfo),
    as.character(encoding), as.logical(useDotNames), xinclude,
    error, addFinalizer, as.integer(options), PACKAGE = "XML")
    2: xmlTreeParse(pub.efetch, useInternalNodes = TRUE) at pubmed.R#64
    1: extractJournal()