I am new in R programming and I have code like below and I know that the windows does not support multicore but I don't know how to change this part of the code.
Can someone suggest me an equivalent code without using the mc.cores feature?
rpl <- unlist( lapply( waydf$geometry$coordinates , nrow ) ) # row per line
waydf <- waydf[ rpl > 1 , ]
ll <- parallel::mclapply( waydf$geometry$coordinates , st_linestring,
mc.cores =parallel::detectCores() - 1 )
outdf <- sf::st_sf(
line_geometry = sf::st_sfc( ll , crs = epsg ) ,
osm_id = waydf$id
)
If all you want to do is make it so this code doesn't run in parallel, you just need to tell it to use 1 core, then it will use lapply
under the hood.
ll <- parallel::mclapply(waydf$geometry$coordinates, st_linestring, mc.cores = 1)
Or just swap mclapply
out for lapply
.
ll <- lapply(waydf$geometry$coordinates, st_linestring)