[R] Character type and size using spatstats
Rolf Turner
r.turner at auckland.ac.nz
Thu May 15 05:00:00 CEST 2014
Dear Patrick,
(a) Your attachment did not come through; only attachments with
extensions belonging to a limited class are passed through by the list
software.
Perhaps you could email your data set to me privately,
(b) I have only had a quick glance at your code. A few comments:
* In your first call to ppp(), "range(ColN), range(Row)" will be
ignored. They would be used to construct a (rectangular) window
except for the fact that you have specified "window" explicitly.
* the argument "maxsize" gets used only if the marks involved are
*numeric*; it'll be ignored when the marks are a factor.
* the argument "chars" should take values which would be acceptable
as values of the "pch" argument to plot(). The levels of
"Concept" do not meet this requirement.
* if I were me I wouldn't clutter things up by plotting the density
estimate initially. Just plot the pattern, until you get the
sort of result you want. *Then* overlay it on top of a density
plot.
(c) If you send me the data off-list and explain in words what it is
that you want to achieve ("Tell me what you want to do not how you want
to do it.") then I'm pretty sure that I can show you how to achieve it.
cheers,
Rolf
On 15/05/14 14:25, p_connolly wrote:
> The spatstat package has hundreds of useful functions but I'm having
> trouble understanding the intricate ways it does things. I've read lots of
> Rspatialcourse_CMIS_PDF Standard.pdf from here:
> http://www.csiro.au/resources/pf16h but can't find what I need to know. I'm
> particularly interested in how to set the plotting character and its
> size in density plots.
>
>
> require(spatstat)
> load("CharacterSizeRData") # (attached to this message)
> ls()
> [1] "all.win" "bb9"
> head(bb9)
> Col Row ColN Concept Pch VinesJune VinesAug New Event
> 1 A 10 3.333333 Gold 4x 4 42 41 1 TRUE
> 8 A 16 3.333333 Gold 4x 4 42 41 1 TRUE
> 10 A 18 3.333333 Gold 4x 4 42 41 1 TRUE
> 11 A 19 3.333333 Gold 4x 4 42 41 1 TRUE
> 14 A 21 3.333333 Gold 4x 4 42 41 1 TRUE
> 18 A 24 3.333333 Gold 4x 4 42 34 8 TRUE
>>
> ## If I make a ppp class object from bb9, like so:
> ppp9A <- with(bb9, ppp(ColN, Row, range(ColN), range(Row), window =
> all.win,
> marks = Concept))
> ## I can do a density plot:
> plot(density(ppp9A, 5, edge = FALSE, weights = bb9$New), main = "ppp9A")
> ## Adding to show the points:
> plot(ppp9A, add = TRUE, cols = "red", maxsize = max(bb9$New)/20)
> ## works except that maxsize is ignored.
> ##
> ## If I make the ppp object like this:
> ppp9B <- with(bb9, ppp(ColN, Row, range(ColN), range(Row), window =
> all.win,
> marks = New))
> plot(density(ppp9B, 5, edge = FALSE, weights = bb9$New), main = "ppp9B")
> plot(ppp9B, add = TRUE, cols = "red", maxsize = max(bb9$New)/20)
> ## maxsize works how I intended.
> ##
> ## I tried to combine plotting character and size with a fancier use of
> marks
> ppp9C <- with(bb9, ppp(ColN, Row, range(ColN), range(Row), window =
> all.win,
> marks = data.frame(New, Concept)))
> ## Then try
> plot(density(ppp9C, 5, edge = FALSE, weights = marks(ppp9C)$New),
> main = "")
> plot(ppp9C, add = TRUE, cols = "red", chars =
> levels(marks(ppp9C)$Concept),
> maxsize = max(marks(ppp9C)$New)/20)
> ## chars is ignored and no error message to complain or explain
>
> What I wish to know is how to get plotting character and size
> information displayed simultaneously. I tried ways of specifying it
> from bb9 dataframe instead of the ppp object, or specifying a fixed
> value but it's always ignored. Ideally, I'd like to customize the
> plotting characters used, but getting the defaults to work would be a
> start.
More information about the R-help
mailing list