Converting TriRep to DelaunayTri while using pointLocation? - delaunay

I have a TriRep object with triangulations and I want to use pointLocation on the object to find whether the points are inside the triangles. But the pointLocation is a method defined for DelaunayTri class which is a subclass of TriRep.
So I would like to ask if TriRep object can be converted to DelaunayTri to be used in pointLocation?

At my knowledge, there is no way to make such a conversion. While waiting a more elegant solution, I advice you using tsearchn() instead of pointLocation(). Best of all

I found a workaround for the problem thanks to the Mathworks folks. It seems there is a way to typecast the TriRep object to be a delaunay triangulation. The details are given in this post - http://www.mathworks.com/help/techdoc/math/bspqkfv-1.html#bspqkfv-4

Related

What is a way to get the object Array from the object Vector in Julia?

There is maintype(t) = getfield(parentmodule(t), nameof(t)), but it's rather indirect...
Does anyone know a better way?
original post
The solution is to use Base.typename(t).wrapper given t is the same t you referenced in your question!
original post

What is the R equivalent of numpy "stride" indexing?

In numpy if you have an array x you can access it's elements with a 'stride' (i.e. skipping some inbetween) like so: x[::2]. How can you do this in R with a vector? I've searched all over the internet and couldn't find an answer to something so simple, kind of surprising.
EDIT:
I just realized that you could use seq(), but is there no built-in method for doing this?
Ya so it turns out you just need to use
v[seq(to=length(v),by=stride)], just another quirk of R.
Though as #Igor F. mentioned they don't bother making it easier since array order is less important to statisticians. I imagine people are more likely to do something like sample(v,as.integer(length(v)/stride)) without being so verbose of course.
There is none, to my knowledge, but a hard-core R user (which I am not) would probably tell you that you are having a wrong approach. R is made for statistics, by statisticians. In their worldview, the order of the entries in an array or frame is irrelevant (or random), so there is no point in accessing them in a particular order.

When should I use "#" sign while using r language:

Every time I miss spell this at(#) character while writing R code so what is the usage as it has a special colour so I supposed it was meant to do something useful. Any comments on that?
The "at"-sign is used to access S4 slots. It is the equivalent of the "dollar"-sign used to access lists (of which data.frames are but one example.)
On the other hand you might be talking about its special use in certain external packages? But I'm guessing that's not going to be the case here, because that would imply that you knew quite about about R.

Create an alias to a slot of an object in R

I've bumped my head on the walls trying to create an alias (aka a pointer, or a new short nickname designating the same object in memory without copying that object) to a subpart of a complex object. Let's say I am working with an object of class SpatialPolygonsDataFrame (package "sp"), and I want to perform operations on an part thereof, deep down in the hierarchical representation of that object. Instead of writing repeatedly things like
myBigMap#polygons[FRA][[1]]#Polygons[[1]]
I want to be able to write simply
mypolygon
so that
myBigMap#polygons[FRA][[1]]#Polygons[[1]]#coords
can be abbreviated
mypolygon#coords
etc. I've seen that I should maybe use environments as a replacement to the former .Alias defunct function, but can't find out how to tell R that I want to consider a subpart of a complex object as an environment. Thanks!
assignment:
mypolygon=myBigMap#polygons[FRA][[1]]#Polygons[[1]]
doesn't create a copy until you modify something in it. So if its just shorthand for accessing the data to make some code more readable then that will be fine:
mypolygon#coords
mean(mypolygon#coords[,1])
neither of those will make a copy.
However, if you do modify mypolygon, eg by changing #coords, you need to put the modified value back in the structure since a copy is made:
mypolygon#coords = mypolygon#coords * 1000
myBigMap#polygons[FRA][[1]]#Polygons[[1]] = mypolygon
I think that's a preferred solution, since its just as efficient as any kind of magic aliasing scheme and its explicit since there's no magic action-at-a-distance happening.
I don't think there's any way to alias parts of an object like the way you want to do.

What does mfrow & mfcol stand for in par()?

As the title says. I ask because understanding what the abbreviation stands for helps me remember it and I'm really struggling with this parameter.
If the answer is unintuitive, can you also explain how you rationalize it?
Paul Murrell has listed some helpful mnemonics; the interpretation might be
mfrow: number of Multiple Figures (use ROW-wise).
mfrow simply stands for "MultiFrame rowwise layout". The other one is pretty obvious now: mfcol stands for MultiFrame columnwise layout.
I'm guessing here, and my guess is that it might be "matrix-frame". The parameters set up the row and column dimensions of the graphical device. "mfrow" might be thought of as matrix-frame-by-row, since the two parameters have The "mfg" parameter might be thought of as matrix-frame-get, since it addresses a location in matrix-like conceptual arrangement of device splits set up by the last call to par with either "mfcol" or "mfrow".
I suppose another hypothesis might be "-_m_ultiple-_f_igures". Still guessing after an attempt at searching with Google and MarkMail in Rhelp.
I've wondered about this myself. "multi-frame" and "multiple-figures" make all kind of sense.
In the absence of the "right" answer, I came up with the mnemonic "me first" (by) rows and by columns. Certainly wrong, but I always remember what they do!
My understanding is : mfrow == matrix filled by row; mfcols == matrix filled by column.

Resources