read_xml_num: Lacks Example and Detailed Explanation
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- r
- Área
- documentation
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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()")
- Lenguaje dominante
- R
- Estrellas
- 227
- Forks
- 86
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de r-lib/xml2
-
Export libxml2_version()Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 67/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Optimize xml_path() and xml_find_all() for large node setsPosiblemente ocupada @astruebi la tomó hace 182 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
Todos los issues de r-lib/xml2
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Bioconductor/BiocParallel#289 ·
-
automation
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
waldronlab/BugSigDBcuration#2224 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
merliseclyde/BAS#118 ·