Created
November 27, 2018 15:17
-
-
Save Nowosad/34bdbcafb4a58daecf30992970a1266a to your computer and use it in GitHub Desktop.
How to change the class of variables within an sf object?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sf) | |
library(dplyr) | |
library(spData) | |
str(nz) | |
# change class for one column | |
nz2 = nz %>% | |
mutate(Land_area = as.factor(Land_area)) | |
str(nz2) | |
# change class for more than one column | |
nz3 = nz %>% | |
mutate_if(is.character, as.factor) | |
str(nz3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment