[R] Deciphering an error message

Suzanne E. Blatt SuzieBlatt at netscape.net
Tue Jul 1 11:59:05 CEST 2003





Hello again,

Below is the code I am using which generates the error message.

Any comments greatly appreciated,
S.


------------------------------------

#####################################################################
# 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
>> 
>> __________________________________________________________________
>> McAfee VirusScan Online from the Netscape Network.
>> Comprehensive protection for your entire computer. Get your free trial today!
>> http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
>> 
>> Get AOL Instant Messenger 5.1 free of charge.  Download Now!
>> 
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>
>

__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!




More information about the R-help mailing list