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

Redundant code in 4.2.3? #352

Closed
Henrik-P opened this issue Dec 15, 2018 · 2 comments
Closed

Redundant code in 4.2.3? #352

Henrik-P opened this issue Dec 15, 2018 · 2 comments
Assignees

Comments

@Henrik-P
Copy link
Contributor

Henrik-P commented Dec 15, 2018

In 4.2.3 Spatial joining, two lines of code seem redundant:

world$name_long = as.character(world$name_long)

"name_long" is already a character vector in the original "world" data.

world_random = world[random_points, ]

"world_random" doesn't seem to be used in the chapter.

@Henrik-P Henrik-P reopened this Dec 15, 2018
@Henrik-P Henrik-P changed the title RE Redundant code in 4.2.3? Dec 15, 2018
@Robinlovelace
Copy link
Collaborator

Thanks for pointing out these issues.

Regarding the 1st, I assigned it to a character because in an old version of the world dataset it was a factor. But you correctly point out that this is no longer the case:

class(spData::world$name_long)
#> [1] "character"

Created on 2018-12-17 by the reprex package (v0.2.1)

I've removed the as.character() line, fixing the first part of the issue (see commit below for details of the fix).

world_random was used in the chapter, but not explicitly (it creates the top right panel of the figure). I've now rewritten the section so that the purpose of doing the spatial subsetting is made clear. It also now shows the link between spatial subsetting and spatial joining.

Please take a look at the updated results at https://geocompr.robinlovelace.net/spatial-operations.html#spatial-joining and let us know if you find any other issues. The feedback is greatly appreciated!

@Robinlovelace
Copy link
Collaborator

535fe58

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

2 participants