You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The check that ensures equality between the original Excel spreadsheet and the CSV snapshot fails in the vignette("readxl-workflows") article. The check can be found here in the R markdown file.
My guess is that it's because the object classes are different and the problems attribute that readr seems to be adding.
library(tidyverse)
library(readxl)
iris_xl<- readxl_example("datasets.xlsx") %>%
read_excel(sheet="iris") %>%
write_csv("iris-raw.csv")
iris_xl
dir(pattern="iris")
iris_alt<- read_csv("iris-raw.csv")
## readr leaves a note-to-self in `spec` that records its column guessing,## so we remove that attribute before the check
attr(iris_alt, "spec") <-NULL
identical(iris_xl, iris_alt)
What would be the "right" way to make the call to base::identical() return TRUE? Calling as_tibble() on the iris_alt object before comparing them works, but maybe this is a bad idea?
identical(iris_xl, as_tibble(iris_alt))
Alternatively, I can follow the approach in the vignette by first removing the problems attribute. Then I can set the class of the iris_alt object equal to that of iris_xl.
The question is if it's important that the check fails if the objects have differing attributes? There might exist scenarios where differing attributes between the original Excel spreadsheet and the CSV file can cause problems down the road?
The text was updated successfully, but these errors were encountered:
The check that ensures equality between the original Excel spreadsheet and the CSV snapshot fails in the vignette("readxl-workflows") article. The check can be found here in the R markdown file.
My guess is that it's because the object classes are different and the
problems
attribute thatreadr
seems to be adding.What would be the "right" way to make the call to
base::identical()
returnTRUE
? Callingas_tibble()
on theiris_alt
object before comparing them works, but maybe this is a bad idea?Alternatively, I can follow the approach in the vignette by first removing the
problems
attribute. Then I can set theclass
of theiris_alt
object equal to that ofiris_xl
.In my view an easy solution is to call
base::all.equal()
withcheck.attributes = FALSE
. Even easier is to use (the now deprecated)dplyr::all_equal()
.The question is if it's important that the check fails if the objects have differing attributes? There might exist scenarios where differing attributes between the original Excel spreadsheet and the CSV file can cause problems down the road?
The text was updated successfully, but these errors were encountered: