Skip to content
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

as.grob() on lattice graphics not comparable with all.equal() #12

Open
kplevoet opened this issue Apr 27, 2021 · 0 comments
Open

as.grob() on lattice graphics not comparable with all.equal() #12

kplevoet opened this issue Apr 27, 2021 · 0 comments

Comments

@kplevoet
Copy link

Dear Guangchuang Yu,

I am using your ggplotify package to make automatic exercises for students. However, when rendering a lattice graphic to a grob with as.grob(), there are many differences between the student's submission and the solution in the components childrenvp and childrenetc.

library(ggplotify)
library(lattice)

For instance, we can work on the built-in data set in R CO2:

data(CO2)

Say, we want to make a density plot of uptake for the different Treatments but with different panels for Type:

Solution_Plot <- densityplot(~ uptake | Type, data = CO2, plot.points = FALSE,
                            groups = Treatment,
                            auto.key = list(space = "right")
                            )

Suppose that the student submits the exact same solution:

Student_Plot <- densityplot(~ uptake | Type, data = CO2, plot.points = FALSE,
                            groups = Treatment,
                            auto.key = list(space = "right")
                            )

When I use the all.equal() function to compare the grobs of both plots, there is a whole list of differences:

Solution_Grob <- as.grob(Solution_Plot)
Student_Grob <- as.grob(Student_Plot)
all.equal(Solution_Grob, Student_Grob)
...

How can this be solved?

Best,

Koen

@kplevoet kplevoet changed the title as.grob() on lattice graphics not comparable with all equal() as.grob() on lattice graphics not comparable with all.equal() Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant