r-lib / vctrs

Generic programming with typed R vectors

Home Page:https://vctrs.r-lib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in `vec_rbind()

DrewryWang opened this issue · comments

! c() method returned a vector of unexpected size 10002 instead of 10000.
ℹ In file c.c at line 414.
ℹ Install the winch package to get additional debugging info the next time you get this error.
ℹ This is an internal error that was detected in the vctrs package.
Please report it at https://github.com/r-lib/vctrs/issues with a reprex (https://tidyverse.org/help/) and the full backtrace.
Backtrace:

  1. ├─sfnetworks::to_spatial_smooth(net)
  2. │ └─sfnetworks:::bind_rows_list(edges, new_edges)
  3. │ └─dplyr::bind_rows(ins)
  4. │ └─vctrs::vec_rbind(!!!dots, .names_to = .id, .error_call = current_env())
  5. └─rlang:::stop_internal_c_lib(...)
  6. └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)

After I created a sfnetwork object from linestrings, I was trying to smooth the network by removing pseudo nodes.
Here are my code:
Link_Output_sf <- Link_to_Linestring(Link_Output[1:10000,])
net <- sfnetworks::as_sfnetwork(Link_Output_sf)
smoothed_net = to_spatial_smooth(net)

you can find more info about sfnetworks and removing pseudo nodes at the link:
https://luukvdmeer.github.io/sfnetworks/articles/sfn02_preprocess_clean.html

Could you please turn this into a self-contained reprex (short for minimal reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page.

You can install reprex by running (you may already have it, though, if you have the tidyverse package installed):

install.packages("reprex")

Thanks

@DavisVaughan Sorry that I couldn't turn it into a reprex as the code needs to read a external shp file.
However, I am attaching the minimal code and the file necessary as below. Hopefully you can run it on your side.

##Code
library(sfnetworks)
library(sf)
Link_Output_sf <- read_sf('~/link_output.shp') # Replace the shp file within the attached folder after unzip
net <- sfnetworks::as_sfnetwork(Link_Output_sf)
smoothed_net = to_spatial_smooth(net)
##End of Code

link_output_shp.zip