[R] Deciphering an error message
Uwe Ligges
ligges at statistik.uni-dortmund.de
Tue Jul 1 13:11:22 CEST 2003
Suzanne E. Blatt wrote:
>
>
>
> Hello again,
>
> Below is the code I am using which generates the error message.
>
> Any comments greatly appreciated,
> S.
Well, my questions were:
- 'What is a "ppp object"?'
Still not answered yet, AFAICS.
- 'Which function has been applied and generated that error message?'
Still not answered yet, AFAICS.
You have send us a self written function, but not a reproducible example
that helps to discover the error message. And this function does *not*
generate the error message, but perhaps a function called within your
function. Further on:
- You are using a function ppp() I don't know anything about.
- (At least) The line
sp"Col <- t(trees[spColNam])
should generate a syntax error ...
So, please use the debugging tools to find out which function produces
the error message (e.g. via traceback()) and specify *reproducible*
examples that are as short as possible.
We cannot help as long as you are concealing the relevant information.
Uwe
>
> ------------------------------------
>
> #####################################################################
> # Function to create a PPP object for all the points in a particular
> # include. Mark the points with their species name (or a number
> # indicating it)
> #
> # Usage:
> # x <- getBigPPP(year, include, species, number=FALSE)
> #
> # Where:
> # x = ppp object with coordinates and bounds for indicated species
> # and plots.
> # year = year(s) to include data for. Either a single number or a
> # vector of numbers
> # include = name(s) of plots to include data from. Either a single
> # character expression or a vector of characters.
> # species = name(s) of species to include data for. Either a single
> # species name or a vector of characters.
> # number = flag indicating whether species names or numbers are used
> # as marks in ppp object. Species names are default. To
> # use numbers, set number=TRUE. This argument is not needed
> # unless numbers are desired.
> #
> # Example:
> # source("spat1.R") # source file to install functions
> # getBigPPP(1992, "G1", "apple") # print PPP object (summary of)
> # # for apple in G1 in 1992. Marks
> # # will be species name 'apple'
> # x <- getBigPPP(1992, c("P1","P2","P3"), c("apple","hawthorn"), number=TRUE)
> # # x is defined as PPP object with
> # # coordinates and plot information
> # # for apple and hawthorn species
> # # in plots P1, P2, and P3, with
> # # marks set to numbers.
> # plot(x) # plot locations of species, with
> # # different marks for each one, and
> # # plot boundaries.
> #
> getBigPPP <- function(year=NULL, include=NULL, species=NULL, number=FALSE, spColNam="Species") {
> # message about usage
> if(is.null(year) || is.null(include)) {
> return("ERROR !")
> }
> # create species selection if it is now null
> sp"Col <- t(trees[spColNam])
> # print(spCol)
> if(is.null(species)) {
> species <- as.character(unique(spCol))
> }
> # create the bounds for this object
> bounds <- plotBounds(include)
> # selection based on include and year
> select <- (trees$Plot %in% include) & (trees$Year %in% year) &
> (spCol %in% species) & (!is.na(trees$Northing)) &
> (!is.na(trees$Easting)) & (trees$Present == 1)
> # mark with numbers or with species name
> if(!number) {
> return(ppp(x=trees$Easting[select], y=trees$Northing[select],
> marks=as.factor(spCol[select]), poly=bounds))
> }
> specs <- unique(spCol[select])
> marks <- apply(as.matrix(spCol[select]), 1, function(x) {
> which(specs == x)[1]
> })
> return(ppp(x=trees$Easting[select], y=trees$Northing[select],
> marks=as.factor(marks), poly=bounds))
> }
> --------------------------------------------------
>
>
>
>
>
>
>
> Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote:
>
>
>>Suzanne E. Blatt wrote:
>>
>>>Hello,
>>>
>>>I'm working in spatstat and having difficulty with the ppp objects. I can get a ppp object for one set of data, but with the same code applied to a second data set (all I am changing is the field identifier), I get the following error message:
>>>
>>>Error in switch(w$type, rectangle={: internal error: some total scores are neither 0 nor 1
>>
>>What is a "ppp object"?
>>Which function has been applied and generated that error message?
>>
>>The error message tells you some values a ought to sum up to 0 or 1 but
>>they don't. I (and perhaps others as well) cannot help when you don't
>>specify some relevant information.
>>
>>Uwe Ligges
>>
>>
>>>Any thoughts on what this means and how to correct it would be most appreciated.
>>>
>>>Thanks,
>>>Suzanne
>>>
More information about the R-help
mailing list