We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I can convert the values of spatVector to ordered factor class, but I can't assign this to the spatVector. Is this as intended?
First, the values can be ordered:
library(terra) f <- system.file("ex/lux.shp", package="terra") v <- vect(f) ordered(v$NAME_1, levels = c("Diekirch", "Grevenmacher", "Luxembourg")) |> is.ordered() # [1] TRUE ordered(v$NAME_1, levels = c("Diekirch", "Grevenmacher", "Luxembourg")) |> class() # [1] "ordered" "factor"
However, if I reassign these values to the spatVector, they are do not persist as ordered:
v$NAME_1 <- ordered(v$NAME_1, levels = c("Diekirch", "Grevenmacher", "Luxembourg")) is.ordered(v$NAME_1) # [1] FALSE class(v$NAME_1) [1] "factor"
This is also true using tidyterra::mutate
tidyterra::mutate
v <- tidyterra::mutate(v, NAME_1 = ordered(NAME_1, levels = c("Diekirch", "Grevenmacher", "Luxembourg"))) is.ordered(v$NAME_1) # [1] FALSE class(v$NAME_1) [1] "factor"
Using terra_1.7-39.
The text was updated successfully, but these errors were encountered:
14afa94
That was not intended, but since terra stores these in its own C++ object it needs to be explicitly added. I have now done that and I now see:
library(terra) #terra 1.7.48 v <- vect(system.file("ex/lux.shp", package="terra")) v$test <- ordered(v$NAME_1, levels = c("Diekirch", "Grevenmacher", "Luxembourg")) is.ordered(v$NAME_1) #[1] FALSE is.ordered(v$test) #[1] TRUE
Sorry, something went wrong.
No branches or pull requests
I can convert the values of spatVector to ordered factor class, but I can't assign this to the spatVector. Is this as intended?
First, the values can be ordered:
However, if I reassign these values to the spatVector, they are do not persist as ordered:
This is also true using
tidyterra::mutate
Using terra_1.7-39.
The text was updated successfully, but these errors were encountered: