Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

{{sf}} commands now giving "Error: (converted from warning) message

Some of my code which previously yielded a warning message is now giving an error. Here is an example:

library(sf)

states <- tigris::states(cb = T) %>% select(state = NAME) %>% filter(state == "Wisconsin")
wi.counties <- tigris::counties(state = "WI", cb = T) %>% select(county = NAME)

st_crs(states) == st_crs(wi.counties)
[1] TRUE

intersection <- st_intersection(states, wi.counties)
Error: (converted from warning) attribute variables are assumed to be spatially constant throughout all geometries

Previously, I just got the message "Warning: attribute variables are assumed . . ."

Now, the code entirely values due to the warning being converted to an error.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My question

Why is this warning now being converted to an error, and how can I make it stop doing that?

I’m running {{sf}} version 1.0.7 on R 4.2.0.

>Solution :

It looks like you have somehow set your options to convert all warnings to errors. To check whether this is the case, run getOption("warn"). If so, the output will be 2, or a value greater than 2 when converted to an integer:

If warn is negative all warnings are ignored. If warn is zero (the default) warnings are stored until the top–level function returns. If warn is one, warnings are printed as they occur. If warn is two (or larger, coercible to integer), all warnings are turned into errors.

Assuming that you know you can safely ignore the warning, you can reset it with:

options(warn=0)

See here for more info about the different options settings.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading