我想使用 parLapply 并且我正在设置我的代码,就像这里介绍的那样:http : //www.win-vector.com/blog/2016/01/parallel-computing-in-r/
最后几次效果很好。但是,在我当前的parLapply
通话中,我收到了错误消息
Error in checkForRemoteErrors(val) : 3 nodes produced errors; first error: could not find function "bindToEnv"
。
这里有一个简短的例子:
#' Copy arguments into env and re-bind any function's lexical scope to bindTargetEnv .
#'
#' See http://winvector.github.io/Parallel/PExample.html for example use.
#'
#'
#' Used to send data along with a function in situations such as parallel execution
#' (when the global environment would not be available). Typically called within
#' a function that …
Run Code Online (Sandbox Code Playgroud) 我有以下数据: https: //ufile.io/p9s0le6g
...其中包含 485 个纬度/经度观测值。我最终想计算这个数字的表面积(以平方米或平方公里为单位)。我想用数据点(外部点)创建一个多边形,然后计算表面积。但是,我无法想出一个漂亮的多边形。我的数据点作为坐标如下所示:
我想要一个看起来像这样(或类似)的多边形:
这是我尝试过的:
library(sp)
df <- read.csv('data.csv')
p = Polygon(df)
ps = Polygons(list(p),1)
sps = SpatialPolygons(list(ps))
plot(sps)
Run Code Online (Sandbox Code Playgroud)
这导致(显然不是一个漂亮的多边形):
我还尝试实现从分布的点集创建多边形
的答案,但这对我来说只是一个矩形:
任何人都知道如何优化我的多边形以获得看起来像我的数据点的外部形状的图形,以及如何计算该优化多边形的表面积?
假设以下数据框:
mydf <- data.frame(date = as.Date(rep(c('2019-11-01', '2019-10-01'), 2)),
value = c(10, 15, 8, 4),
type = c('Type 1', 'Type 1', 'Type 2', 'Type 2'))
print(mydf)
date value type
1 2019-11-01 10 Type 1
2 2019-10-01 15 Type 1
3 2019-11-01 8 Type 2
4 2019-10-01 4 Type 2
Run Code Online (Sandbox Code Playgroud)
我想创建一个自动代码,为每种类型创建一个线图并定义每条线的颜色。一般来说,我知道该怎么做:
require(ggplot2)
myplot <- ggplot(mydf, aes(x = date, y = value, colour = type)) + geom_line() +
scale_color_manual(name = 'Type', values=c('blue', 'red'))
Run Code Online (Sandbox Code Playgroud)
但是,在另一个月运行代码时,数据框可能会发生变化。Type 3
数据框中可能有:
mydf <- data.frame(date = as.Date(rep(c('2019-11-01', '2019-10-01'), …
Run Code Online (Sandbox Code Playgroud)