New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml_integer() does not return integer #146

Closed
ddiez opened this Issue Nov 14, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@ddiez
Contributor

ddiez commented Nov 14, 2016

For example:

x <- read_xml("<plot><point x='1' y='2' /><point x='2' y='1' /></plot>")
xml_integer(xml_find_all(x, "//@x")) %>% is
[1] "numeric"        "vector"         "atomic"         "vectorORfactor"

The culprit might be in xml_text.R:

#' @export
xml_integer.xml_nodeset <- function(x) {
  vapply(x, xml_integer, numeric(1))
}

Where changing numeric(1) for integer(1) fixes it. It seem the unit test for xml_integer is passing because it uses expect_equal instead of expect_identical (but I am just getting familiar with testthat so I may be completely wrong on this):

test_that("xml_integer() returns an integer vector", {
  x <- read_xml("<plot><point x='1' y='2' /><point x='2' y='1' /></plot>")

  expect_equal(xml_integer(xml_find_all(x, "//@x")),
    c(1L, 2L))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment