R. Pairwise distances between two point patterns on a linear network (crossdist.lpp) displays: "Error in order(Yseg0, tY) : argument 2 is not a vector

I've been trying for 3 days to find out where the problem came from but I am a beginner in R working on the re-use of interesting scripts for my work like [functions of EAA presentations]([functions of EAA presentation · GitHub]. I create a new R file.

#### Calculating distances on observed point patterns ####
  ## creation of an lpp object
  observed_lpp1 <- spatstat.linnet::lpp(
    X = spatstat.geom::as.ppp(X = pp1 %>% dplyr::select(geometry)),
    L = maptools::as.linnet.SpatialLines(X = as(network, "Spatial"))
  )
  
  observed_lpp2 <- spatstat.linnet::lpp(
    X = spatstat.geom::as.ppp(X = pp2 %>% dplyr::select(geometry)),
    L = maptools::as.linnet.SpatialLines(X = as(network, "Spatial"))
  )
  
  ## calculating shortest paths for observed data
  matrix_observed_dist_pi_p <- spatstat.linnet::crossdist.lpp(X = observed_lpp1, Y = observed_lpp2)
  
  observed_dist <- matrix_observed_dist_pi_p %>%
    tibble::as_tibble() %>%
    tibble::rowid_to_column(var = "pp1") %>%
    tidyr::pivot_longer(cols = -pp1, names_to = "pp2", values_to = "dist_pi_p") %>%
    dplyr::filter(!is.na(dist_pi_p)) %>%
    dplyr::mutate(pp2 = stringr::str_replace_all(string = pp2, pattern = "V", replacement = ""))

I received an error message at the line matrix_observed_dist_pi_p <- spatstat.linnet::crossdist.lpp(X = observed_lpp1, Y = observed_lpp2)

Error in order(Yseg0, tY) : argument 2 is not a vector In addition: Warning message: In as.data.frame.hyperframe(x$data[, chosen, drop = FALSE]) : 1 variable discarded in conversion to data frame

I am currently working with R.4.2 because I needed to use maptools::as.linnet.SpatialLines.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.