-
Notifications
You must be signed in to change notification settings - Fork 19
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
Error building an Out object #225
Comments
$coo expects a list of matrices
I cannot really help further as I dont really understand your df structure
Le jeu. 29 sept. 2022 à 18:48, JohnSal1 ***@***.***> a écrit :
… Hi,
I have a theoretical data frame (df) with this structure:
Code Outline
A1 X1; Y1 X2; Y2 X3; Y3 Xn; Yn
A2 X1; Y1 X2; Y2 X3; Y3 Xn; Yn
A3 X1; Y1 X2; Y2 X3; Y3 Xn; Yn
…
And I wish to create from it an Out object so I used this code:
df <- as_tibble(df)
fac <- df$Code
coo <- df$Outline
x <- Out(coo, fac)
but I get this error:
an Out object can only be built from a shape, a list, an array or a Coo
object.
I presume that the coo object is not in the right order/structure, am I
correct? How can I change it?
—
Reply to this email directly, view it on GitHub
<#225>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABECQFRLKAKE7AXJMNZO27LWAXB5DANCNFSM6AAAAAAQY6XBD4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
vincentbonhomme.fr <http://www.vincentbonhomme.fr>
cevennette.fr <https://www.cevennette.fr> 🌱
|
Thanks for the reply. Updated code:
|
I think that does the job ;-)
````
library(tidyverse)
library(Momocs)
Code <- c('A1', 'A2','A3')
Outline <- c('0;0 0;10 10;10', '0;0 0;10 10;10 0;10', '0;0 0;10 5;5')
df <- data.frame(Code, Outline)
str_2_shp <- function(x){
x %>%
# split on spaces and ;
strsplit(";| ") %>%
# turn into numeric
unlist() %>% as.numeric() %>%
# then into a shape
matrix(ncol=2, byrow=T)
}
coo <- df$Outline %>% map(str_2_shp)
fac <- select(fac, -Outline)
Out(coo, fac) %>% stack()
````
Le ven. 30 sept. 2022 à 06:59, JohnSal1 ***@***.***> a écrit :
… Thanks for the reply.
Updated code:
Code <- c('A1', 'A2','A3')
Outline <- c('0;0 0;10 10;10', '0;0 0;10 10;10 0;10', '0;0 0;10 5;5')
df <- data.frame(Code, Outline)
df <- as_tibble(df)
fac <- df$Code
coo <- as.list(df$Outline)
x <-Out(coo, fac)
stack(x)
—
Reply to this email directly, view it on GitHub
<#225 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABECQFU5BGSR4DAGGAUA7XDWAZXSDANCNFSM6AAAAAAQY6XBD4>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
vincentbonhomme.fr <http://www.vincentbonhomme.fr>
cevennette.fr <https://www.cevennette.fr> 🌱
|
I get this error while running
so I changed it to and than run these lines:
and still I get the shp names instead of the fac/Code. Any idea how to fix it |
Dear Dr. Bonhomme, Any idea how to solve it? Thanks. |
select(df, -Outline)
Le dim. 9 oct. 2022 à 09:08, JohnSal1 ***@***.***> a écrit :
… Dear Dr. Bonhomme,
Any idea how to solve it?
Thanks.
—
Reply to this email directly, view it on GitHub
<#225 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABECQFUHLMIHH3RZM5DH6D3WCJVNZANCNFSM6AAAAAAQY6XBD4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Instead of select(fac etc. ?
Le dim. 9 oct. 2022 à 12:24, Vincent Bonhomme ***@***.***>
a écrit :
… select(df, -Outline)
Le dim. 9 oct. 2022 à 09:08, JohnSal1 ***@***.***> a écrit :
> Dear Dr. Bonhomme,
>
> Any idea how to solve it?
>
> Thanks.
>
> —
> Reply to this email directly, view it on GitHub
> <#225 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABECQFUHLMIHH3RZM5DH6D3WCJVNZANCNFSM6AAAAAAQY6XBD4>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
Hi, Sorry for the long silence. Thanks again Code:
|
Hi there,
panel/stack use the names of the coo directly.
so that sth like this should work
coo <- df$Outline %>% map(str_2_shp)
*names(coo) <- df$Code*
fac <- select(df , -Outline)
x <- Out(coo, fac)
panel(x, names=TRUE, cex.names=0.9)
Le mer. 17 mai 2023 à 21:54, JohnSal1 ***@***.***> a écrit :
… Hi,
Sorry for the long silence.
It still does not assign the codes (A1,A2 and A3) to the coo object. In
the panel plot, I get shp1, shp2 and shp3. Any idea how to solve it?
Thanks again
Code:
library(tidyverse)
library(Momocs)
Code <- c('A1', 'A2','A3')
Outline <- c('0;0 0;10 10;10', '5;5 0;2.5 0;0', '0;0 0;10 5;5')
df <- data.frame(Code, Outline)
str_2_shp <- function(x){
x %>%
# split on spaces and ;
strsplit(";| ") %>%
# turn into numeric
unlist() %>% as.numeric() %>%
# then into a shape
matrix(ncol=2, byrow=T)
}
coo <- df$Outline %>% map(str_2_shp)
fac <- select(df , -Outline)
x <- Out(coo, fac)
panel(x, names=TRUE, cex.names=0.9)
—
Reply to this email directly, view it on GitHub
<#225 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABECQFVZYCVEGNQAH6VAQP3XGUUGHANCNFSM6AAAAAAQY6XBD4>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
vincentbonhomme.fr <http://www.vincentbonhomme.fr>
cevennette.fr <https://www.cevennette.fr> 🌱
|
Hi,
I have this data frame (df) structure:
Code Outline
A1 X1; Y1 X2; Y2 X3; Y3
A2 X1; Y1 X2; Y2 X3; Y3
A3 X1; Y1 X2; Y2 X3; Y3
…
And I wish to create from it an Out object so I used this code:
but I get these errors:
Error in coo_check.default(coo) : do not know how to turn into a coo
The x does not contain the codes but shp1, shp2, shp3
Why is it? How can I fix it?
The text was updated successfully, but these errors were encountered: