Hi, I made a function myfunction
which used left_join
from dplyr
.
I obtain the error message :
Error in
left_join()
:
! Can't joinx$i
withy$EPT_NUM
due to incompatible types.
![]()
x$i
is a .
![]()
y$EPT_NUM
is a .
This messages is due to
dff.jointure <- DF.flow %>%
left_join(df.point, by = setNames(id, nm = origin)) %>%
rename(Xi = x, Yi = y) %>%
left_join(df.point, by = setNames(id, nm = destination)) %>%
rename(Xj = x, Yj = y)
I think I know where is a problem but I don't know to fix.
I received the error message because the data in my function is created as below
myfunction(map,code
carte_sf <- st_as_sf(map, "sf")
contig<-st_intersects(x = carte_sf, y = carte_sf, sparse=FALSE, prepared = TRUE)
colnames(contig)<-carte_sf$code
rownames(contig)<-carte_sf$code
for (i in 1:nrow(contig)) {
for (j in 1:ncol(contig))
{
if (contig[i, j] == TRUE) {
contig[i, j] <- 1
}
if (contig[i, i] != 0) {
contig[i, i] <- 0
}
}
}
tab <- flowtabmat(contig, matlist = "L")
colnames(tab) <- c("i", "j", "ordre")
ordre_1 <- tab[tab[, "cij"] != 0, ]
The ouput myfunction
I've tested the code inside of my function and I obtain
As you can see the type is different between two output.
Plus when write in CSV ordre_1 there is a colonn added I think it's here the problem.
This shifft will explain the error message!
I hope it's clear; Have you any suggestions how I can fix this ?