Reputation: 1
Assuming i have a dataframe of x , y , z wherein x any y are the coordinates and z is the height. How do I create a blanket of z over the x and y plane. I tried using the loess function to create a blanket
data.loess = loess(z~x*y,data =data.df)
data.fit = expand.grid(list(x = seq(min(x),max(x),0.1), y = seq(min(y),max(y),0.1)))
z = predict(data.loess, newdata =data.fit)
But the predicted z value is not in coherence with the original height.
Functions like scatterplot3d
gives me only the scattered dots,how do I get a surface with hills and valley?
Upvotes: 0
Views: 3600
Reputation: 263332
I have no idea what the phrase "not in coherence with original height" means, but why not look at:
persp(z)
x = seq(1,10,0.1); y = seq(1,10,0.1)
z= outer(x,y,"*")
data =data.frame(x=rep(x, times=91), y=rep(y, each=91), z=c(z) )
data.loess = loess(z~x*y,data =data)
data.fit = expand.grid(list(x = seq(min(x),max(x),0.1), y = seq(min(y),max(y),0.1)))
z = predict(data.loess, newdata =data.fit)
persp(z)
Upvotes: 1