how to upload shapefile and merge with csv in rshiny

I'm trying r shiny about spatial analysis with my r code:

parks = read_sf("C:/Users/HP/Downloads/Jawa barat")
dbd_sementara=read.table(file.choose(),header = T, sep = ";")
head(dbd_sementara)
newdata = merge(parks, dbd_sementara, by = "Kabupaten_")
pl <- st_cast(newdata$geometry[[4]], "POLYGON")
spd <- sf::as_Spatial(st_geometry(pl))
class(spd)
df <- pl
df$geometry <- NULL
sf_use_s2(FALSE)
temp<-poly2nb(newdata)
W<-nb2mat(temp, style = "B", zero.policy = TRUE)
W.list <- nb2listw(temp, style="B")

and now i want make that r code into rshiny. but i got error message like this:

Warning: Error in showMethods: first argument should be the names of one of more generic functions (got object of class “shiny.tag”)
  1: runApp

my r shiny code i upload on my github (sorry i can't post in here because there have 490 line):

Uploading a shapefile - especially the ESRI Shapefile with shp extension - can be tricky, as they are often spread across multiple files.

For an example known to work consider this earlier post ShinyFiles and shapefiles? - #5 by fiorepalombina

As for joining the shapefile - once digested by the {sf} package, e.g. via sf::st_read() call from a tempdir or what not - there should be no shiny specific issues: a code that runs in your R local session should run the same in a shiny app (my suggestion for joining by a common key would be start with your shapefile and do a dplyr::left_join() using a common key; that way the resulting object will inherit the "special sauce" (= sticky geometry) from your first argument.

1 Like

This topic was automatically closed 54 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.