Simple trial plot in R using plotly function

I’​m planning to ​make a 3D surface plot in R, including 3 variables. I’m unsure about how to format my data to construct a 3D plot. I tried running this example
http://moderndata.plot.ly/3d-surface-plots-with-rstudio-and-plotly/
but when I run the last step:

response ← py$plotly(data,

  • kwargs = list(
  • layout = layout,
  • filename = “waves example”,
  • fileopt = “overwrite”))

I get an error:
Error: attempt to apply non-function

Is the plotly function deprecated? Or could something else be wrong?

I have kind of same problem as yours…my data is in format like show in the link.

dt <- read.csv(‘https://raw.githubusercontent.com/plotly/datasets/master/3d-line1.csv’)

I followed the tutorials in the link of this topic and also referred to other plotly r examples of 3d surface plots. I am sure there is something I am missing on how to use the z axis data before plotting it, may be it needs further modification or something.

This is what I tried,
x_vec <- matrix(dt$x, nrow = 601, ncol = 1)
y_vec <- matrix(dt$y, nrow = 1, ncol = 601)
z_vec <- matrix(dt$z, nrow = 601, ncol = 601)
plot_ly(x = x_vec, y = y_vec, z = z_vec, type = ‘surface’)

But it resulted in an empty plot.