正在为R中的surface3d准备数据。请使用更快速的代码
我试图从120000行csv数据中获取“surface3d绘图”,但我的代码太慢,处理时间将超过12小时。 应该换哪个地方? (interp()处理时间也将超过12小时。如果可能,我想合并mk_surface_data()和interp()。是否可能?)正在为R中的surface3d准备数据。请使用更快速的代码,r,interpolation,weighted-average,R,Interpolation,Weighted Average,我试图从120000行csv数据中获取“surface3d绘图”,但我的代码太慢,处理时间将超过12小时。 应该换哪个地方? (interp()处理时间也将超过12小时。如果可能,我想合并mk_surface_data()和interp()。是否可能?) 库(rgl) 库(数据表) 图书馆(秋马) fv在效率方面总是引起危险信号的一行代码是: surface_m <- rbind(surface_m,insert) 谢谢你的回复。我试过你的代码,处理时间是4小时。谢谢。 surface_
库(rgl)
库(数据表)
图书馆(秋马)
fv在效率方面总是引起危险信号的一行代码是:
surface_m <- rbind(surface_m,insert)
谢谢你的回复。我试过你的代码,处理时间是4小时。谢谢。
surface_m <- rbind(surface_m,insert)
surface_m <- t(apply(expand.grid(y=0:y_div, x=0:x_div), 1, function(yx) {
y <- yx[1]
x <- yx[2]
base_x_range <- min_x + (step_x * x)
min_x_range <- base_x_range - (mean_range * step_x)
max_x_range <- base_x_range + (mean_range * step_x)
base_y_range <- min_y + (step_y * y)
min_y_range <- base_y_range - (mean_range * step_y)
max_y_range <- base_y_range + (mean_range * step_y)
all_z <- mat[((min_x_range < mat[,"x"]) & (max_x_range > mat[,"x"]) & (min_y_range < mat[,"y"]) & (max_y_range > mat[,"y"])),c("z")]
if (length(fv(all_z)) > 0){
insert <- c(base_x_range,base_y_range,weighted.mean(all_z,na.rm=T))
} else {
insert <- c(base_x_range,base_y_range,defalut_z)
}
return(insert)
}))