I'm trying to use R to interpolate a response value v from irregularly placed three-dimensional processing x, y, z. In this case, I have 50 unique three-dimensional points (treatments in my experience) and a response variable. I have a value of v for each of the 50 points, but I want to interpolate the answer between these 50 points. To my knowledge, many interpolation codes such as contour () require regularly spaced data, but my treatments are not at all regularly spaced in 3D space.
the actual data frame looks like this:
head (df) x y z v 14.200 27.20250 8.057316 2.427 13.675 37.98000 7.874447 1.740 13.700 24.64750 7.760348 3.637 13.800 32.93833 7.711711 2.175 13.775 30.17500 8.040487 2.498 14.125 18.65750 7.658253 3.246
up to row 50. I've already used ploy_ly () to create a v-colored 3D point cloud, but I want to interpolate a functional response shape or a 3D heat map to fill spaces between points. It also means that I will have to color it with transparent colors or a slice outline or something like that. Ideas??
Reproducible data set code:
df <- data.frame (matrix (ncol = 4, nrow = 50)) colnames (df) <- c ("x", "y", "z") df $ x <- rep (1:25, each = 2) df $ y <- sample (40, size = nrow (df), replace = TRUE) df $ z <- sample (30, size = nrow (df), replace = TRUE) df $ v <- rep (1:50)
install.packages ("plotly") library (plot) plot_ly (x = df $ x, y = df $ y, z = df $ z, type = "scatter3d", mode = "markers", color = df $ v)%>% disposition( scene = list ( xaxis = list (title = "X"), yaxis = list (title = "Y"), zaxis = list (title = "Z")))