read_xml_num: Lacks Example and Detailed Explanation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 38/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- r
- Ambito
- documentation
Direzione di ricerca
Begin by locating the existing documentation entry for read_xml_num and compare it with the xml_find_num calls shown here. Resolve the naming and behavior ambiguity, then add a runnable example and explanation covering the reported error and missing-year case.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Function read_xml_num
Documentation
The function lacks an example and a detailed explanation. Therefore, I am unsure what it actually does or how to actually use it.
All examples generate an error:
Error: result of type: ‘list’, not numeric
Other Issues
This issue is also related to issue:
https://github.com/r-lib/xml2/issues/356
Example
I try to extract the year from the corresponding node. Some records may miss the value for the year, but it makes sense to process the set sequentially and retrieve an NA. Skipping such nodes would generate frame-shifts and scramble the data (as I am actually interested in the whole record, in this example it includes the Title & Year). The straightforward solution: xml_find_num, but it doesn't look to do this.
library("xml2")
### All Years Present
sx = "<?xml version=\"1.0\" ?>
<ArticleSet>
<a><b>Title 1</b>
<c>2023</c>
</a>
<a><b>Title 2</b>
<c>2022</c>
</a>
<a><b>Title 3</b>
<c>2023</c>
</a>
</ArticleSet>"
x = read_xml(sx)
ns = xml_find_all(x, "/ArticleSet/a")
ns
xml_find_all(ns, ".//c/text()")
xml_find_num(ns, ".//c/text()")
xml_find_num(ns, ".//c")
####################
### One Year Missing
sx = "<?xml version=\"1.0\" ?>
<ArticleSet>
<a><b>Title 1</b>
<c>2023</c>
</a>
<a><b>Title 2</b>
<c></c>
</a>
<a><b>Title 3</b>
<c>2023</c>
</a>
</ArticleSet>"
x = read_xml(sx)
ns = xml_find_all(x, "/ArticleSet/a")
ns
# one Node is missing the Year
# !! find_all actually skips this node !!
xml_find_all(ns, ".//c/text()")
# nodeset with only 2023 & 2023;
xml_text(xml_find_all(ns, ".//c"))
# "2023" "" "2023"
xml_find_num(ns, ".//c/text()")
- Lingua principale
- R
- Stelle
- 227
- Fork
- 86
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di r-lib/xml2
-
Export libxml2_version()Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 67/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Optimize xml_path() and xml_find_all() for large node setsForse già presa @astruebi l’ha presa 182 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
Bioconductor/BiocParallel#289 ·
-
automation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
waldronlab/BugSigDBcuration#2224 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
merliseclyde/BAS#118 ·