0

i'm trying to use the Kest function (and many other in the spatstat package).

i have made a ppp point pattern data set (ppp.1)

summary (ppp.1) Planar point pattern: 189 points Average intensity 241122300 points per square unit

Coordinates are given to 6 decimal places

Window: rectangle = [40.74603, 40.74662] x [-111.84693, -111.8456] units (0.000592 x 0.001324 units) Window area = 7.83834e-07 square units

when i try to use the Kest function: Kest(ppp.1), i get the following error: Error in Kest(ppp.1) : could not find function "Kest"

in fact, there are many functions in the spatstat package that can't be found (e.g., rpoint)... i get the same error.

does this have anything to do with "spatstat.random" not being found when i load the spatstat library: Error: package ‘spatstat.random’ required by ‘spatstat’ could not be found

i'm using the most current version of R and spatstat (on an intel Mac): R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin17.0 (64-bit)

spatstat 2.3-4 downloaded installed directly from R.

thank you.

  • Welcome to SO! You maximise your chance of getting a useful answer if you provide a minimal reproducible example. [This post](https://stackoverflow.com/help/minimal-reproducible-example) may help. To start with the obvious, how are you loading `spatstat`? Did the installation of `spatstat` report any errors? Does `spatstat` appear in the output from `installed.packages()`? – Limey Jul 04 '22 at 07:30

2 Answers2

1

Some time ago spatstat was one big package containing all the functions you mention, but due to technical requirements from CRAN it has now been split into several smaller packages all named according to the scheme spatstat.xxxx such as spatstat.random. The package spatstat is now an umbrella package with barely any functions, but it depends on spatstat.random and others, and it loads all these packages when you execute library(spatstat) in the R console.

Under normal circumstances R should refuse to install spatstat without all the needed sub-packages, but it appears you have an installation of spatstat without e.g. spatstat.random. Probably the easiest solution is to remove spatstat and install it again:

remove.packages("spatstat")
install.packages("spatstat", dependencies = TRUE)

Alternatively you can try (requires a relatively new version of spatstat to already be installed):

pkgs <- spatstat::spatstat.family()
install.packages(pkgs)
Ege Rubak
  • 4,347
  • 1
  • 10
  • 18
  • Thank you. i did try removing and reinstalling spatstat. i tried it again, to no avail (spatstat.random was still not installed). what i ended up doing was opening the package installer dropdown menu in R, searching for spatstat (and sure enough, the repository version of spatstat.random wasn't installed). i select everything, then installed/updated the packages, which seemed to work. for some reason, install.packages("spatstat", dependencies=TRUE) wasn't installing spatstat.random. – colby tanner Jul 05 '22 at 23:07
0

To find information about a package, you can visit its CRAN page (go to cran.r-project.org and look for Contributed Packages).

The CRAN page for spatstat says that spatstat 2.3-4 requires the packages spatstat.random and spatstat.core. This means that spatstat depends on code that is provided in these other packages.

Your error message says that spatstat.random is missing. This explains why the random generation function rpoint was not found.

As @EgeRubak says, the best solution is to remove and re-install spatstat.

Adrian Baddeley
  • 2,534
  • 1
  • 5
  • 8