[R] How to generate a smoothed surface for a three dimensional dataset?
David Winsemius
dwinsemius at comcast.net
Fri Dec 6 21:28:01 CET 2013
On Dec 5, 2013, at 9:46 PM, A Xi Ma wrote:
> The following question is inspired by Jun's problem, which resembles some
> of my own problems, but goes off on a tangent about applying plot3D from
> Karline Soetart.
>
>
> On Thu, Dec 5, 2013 at 11:52 PM, Bert Gunter <gunter.berton at gene.com> wrote:
>
>>
>> Your comment that:
>>
>> " I can see the critical point here is to find a right function to
>> make the prediction. "
>>
>> is what indicates to me that your "critical point" is that you have
>> insufficient knowledge and need help. Feel free to disagree, of
>> course.
>>
>
> I don't know if it's true for Jun, but it's definitely true for me - I have
> insufficient knowledge! I'm out of my depth with surface estimation, but I
> have to learn how to do it, one way or the other.
>
> Currently I'm reading the docs for plot3d.
>
> I loaded the package into rstudio and ran some of the examples. The
> image2D example seems to get its data from a data.frame called "volcano"
> with a small "v."
Right. the 'volcano'-object is a standard data object for demonstration of R graphics. It resides in the datasets package and has a help file:
help(volcano)
>
> imag2D> nr <- nrow(volcano)
>
> imag2D> nc <- ncol(volcano)
>
> imag2D> image2D(volcano, x = 1:nr, y = 1:nc, lighting = TRUE,
> imag2D+ main = "volcano", clab = "height, m")
>
>
> The objects() command shows a "Volcano" with a big "V." The small-v and
> big-V volcanoes are not the same, because the str command shows:
>
snipped superfluous output from an objects()-command.
>> str(Volcano)
> num [1:29, 1:21] 100 103 105 108 110 116 120 122 123 118 ...
>> str(volcano)
> num [1:87, 1:61] 100 101 102 103 104 105 105 106 107 108 ...
They are both matrices. The Volcano matrix has only one-ninth the number of values.
The first small section of the volcano vignette reads:
------------------------------------------------------------------------
1. Intro
To make this vignette smaller, the size of volcano is reduced:
# Reduce the resolution
Volcano <- volcano[seq(1, nrow(volcano), by = 3),
seq(1, ncol(volcano), by = 3)]
-------------------------------------------------------------------------
So that code just selects every third of the values of the 'volcano' matrix.
>
> I don't understand how the "volcano" object works well enough to power the
> image2D command, but doesn't show up in "objects()".
It is accessible by functions although it is not visible in the workspace.
> str(volcano)
num [1:87, 1:61] 100 101 102 103 104 105 105 106 107 108 ...
> 'volcano' %in% ls()
[1] FALSE
If you want to get it into the workspace, you just use the data() function:
> data('volcano')
> 'volcano' %in% ls()
[1] TRUE # now "visible"
> At first I thought
> there was some kind of secret smuggling compartment in memory space, and
> "nr" and "nc" and "volcano" were all hidden in that secret place. But in
> fact, "nr" and "nc" show up in "objects()".
>
> So ... I am even less educated than the other newbies on the list, and I'm
> following along, and I really don't see how R is doing what it's doing.
> Should I be reading the plot3D .pdf textbooks, or should I give up and go
> back to some much more basic textbook?
I'm thinking you are not yet ready for plot3D. It's unclear what level of effort you have put in to reading and mastering the "Introduction to R" or whatever text you are using to educate yourself. I certainly do not think that a beginning tutorial in R was the goal that the authors of the plot3D package had in mind. Even before posting to Rhelp you are expected to have studied the available documentation and learned enough R to be able to answer all the questions you posed. So I suggest studying your copy of Introduction to R that is shipped with every binary of R.
>
> Thanks.
>
> [[alternative HTML version deleted]]
And you should learn to post in plain text. Please do read the Posting Guide.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list