I am trying to plot a 3d surface plot based on these plotly examples
When I try these examples on my dataset
test_plotly = structure(list(Age = c
add_surface
requires x
and y
to form a grid and z
to be a matrix over that grid.
Without knowing exactly what your data are and what you want to do, I can only guess how to do that:
library(akima)
# interpolate data onto grid
test_plotly <- with(test_plotly, interp(Age, BMI, Task_Completion_Time,
duplicate = "mean"))
# plot surface over grid
plot_ly(x = test_plotly$x, y = test_plotly$y, z = test_plotly$z,
type = "surface")
will give you