Data for reprex

reprex

#1

I’m curious if anyone can give me a deeper understanding of how reprex interacts with data built into packages. For example:

library(ggplot2)
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.1.3, proj.4 4.9.3

validData <- mpg
invalidData <- nc
#> Error in eval(expr, envir, enclos): object 'nc' not found

Why is it the case that reprex can interact with data from ggplot2 or dplyr but not from sf?

I’m specifically interested in being able to build reproducible examples with sf objects. It seems like the easiest way to do this would be to subset an sf object in one that is shorter (in terms of rows) and narrower (in terms of columns), and then use dput(). For sf data in particular, this does not seem to be a particularly satisfying approach (given that all of the rows may be important for making the eventual ggplot2 map in the reprex).


#2

I’ll “close this issue” - misunderstanding on my part! May have been an issue I was having with the earlier CRAN version of reprex and also forgetting that nc is not visible automatically & you have to use system.file() to get to it!


#3

Can you mark your question as solved ? That way it will be shown as solved in the post and in the list of question. Thanks you very much !


#4

sorry about that! not my finest R moment.