Skip to content

Commit

Permalink
Added smaller example dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
dscolby committed Aug 23, 2021
1 parent ed7b06c commit b6323f7
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 127 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spacejamr
Title: Simulate Spatial Bernoulli Networks
Version: 1.0.0
Version: 0.1
Authors@R:
person(given = "Darren",
family = "Colby",
Expand All @@ -19,7 +19,7 @@ Description: Social network analysis is becoming increasingly popular in many
law or attenuated power law spatial interaction function; and
generate a network object. Additionally, the package provides simple
to use plotting methods for its classes that return plots which can be
further refined with the ggplot2 package.
further refined with the 'ggplot2' package.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand Down
50 changes: 25 additions & 25 deletions R/NetSim.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,20 @@ new_PowerLawNetwork <- function(point_sim, base_prob, scale, threshold, power) {
#'
#' @example \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' power_law <- PowerLawNetwork(mex_points, base_prob = 0.92, scale = 1,
#' ri_points <- PointProcess(1000, ri, 42)
#' power_law <- PowerLawNetwork(ri_points, base_prob = 0.92, scale = 1,
#' threshold = 0.5, power = -2.4)
#' }
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' power_law <- PowerLawNetwork(mex_seq, base_prob = 0.98, scale = 100,
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' power_law <- PowerLawNetwork(ri_seq, base_prob = 0.98, scale = 100,
#' threshold = 0.5, power = -1.87)
#' }
#'
Expand Down Expand Up @@ -287,20 +287,20 @@ new_APLNetwork <- function(point_sim, base_prob, scale, threshold, power) {
#'
#' @example \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' mex <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' apl_points <- APLNetwork(mex_points, base_prob = 0.92, scale = 1,
#' ri_points <- PointProcess(1000, ri, 42)
#' apl_points <- APLNetwork(ri_points, base_prob = 0.92, scale = 1,
#' threshold = 0.5, power = -2.4)
#' }
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' apl_seq <- APLNetwork(mex_seq, base_prob = 0.98, scale = 100,
#' mex_seq <- HaltonSeq(1000, ri, 42)
#' apl_seq <- APLNetwork(ri_seq, base_prob = 0.98, scale = 100,
#' threshold = 0.5, power = -1.87)
#' }
#'
Expand Down Expand Up @@ -345,21 +345,21 @@ APLNetwork <- function(point_sim, base_prob = 0.9, scale = 1,
#'
#' @examples \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' apl_points <- APLNetwork(mex_points, base_prob = 0.92, scale = 1,
#' ri_points <- PointProcess(1000, ri, 42)
#' apl_points <- APLNetwork(ri_points, base_prob = 0.92, scale = 1,
#' threshold = 0.5, power = -2.4)
#' plot(apl_points)
#' }
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' apl_seq <- APLNetwork(mex_seq, base_prob = 0.98, scale = 100,
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' apl_seq <- APLNetwork(ri_seq, base_prob = 0.98, scale = 100,
#' threshold = 0.5, power = -1.87)
#' plot(apl_seq)
#' }
Expand Down Expand Up @@ -397,21 +397,21 @@ plot.NetSim <- function(x, y, ..., layout = "stress",
#'
#' @examples \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' apl_points <- APLNetwork(mex_points, base_prob = 0.92, scale = 1,
#' ri_points <- PointProcess(1000, ri, 42)
#' apl_points <- APLNetwork(ri_points, base_prob = 0.92, scale = 1,
#' threshold = 0.5, power = -2.4)
#' print(apl_points)
#' }
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' apl_seq <- APLNetwork(mex_seq, base_prob = 0.98, scale = 100,
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' apl_seq <- APLNetwork(ri_seq, base_prob = 0.98, scale = 100,
#' threshold = 0.5, power = -1.87)
#' print(apl_seq)
#' }
Expand All @@ -438,21 +438,21 @@ print.NetSim <- function(x, ...) {
#'
#' @examples \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' apl_points <- APLNetwork(mex_points, base_prob = 0.92, scale = 1,
#' ri_points <- PointProcess(1000, ri, 42)
#' apl_points <- APLNetwork(ri_points, base_prob = 0.92, scale = 1,
#' threshold = 0.5, power = -2.4)
#' summary(apl_points)
#' }
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' apl_seq <- APLNetwork(mex_seq, base_prob = 0.98, scale = 100,
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' apl_seq <- APLNetwork(ri_seq, base_prob = 0.98, scale = 100,
#' threshold = 0.5, power = -1.87)
#' summary(apl_seq)
#' }
Expand Down
38 changes: 19 additions & 19 deletions R/PointSim.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ new_PointProcess <- function(points, window, seed) {
#'
#' @example \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' mex_points <- PointProcess(1000, mex, 42)
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' ri_points <- PointProcess(1000, ri, 42)
#' }
#'
#' @author Darren Colby \cr
Expand Down Expand Up @@ -164,8 +164,8 @@ new_HaltonSeq <- function(points, window, seed) {
#'
#' @example \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' }
#'
#' @author Darren Colby \cr
Expand Down Expand Up @@ -200,18 +200,18 @@ HaltonSeq <- function(points, window, seed = NULL) {
#'
#' @examples \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' plot(mex_points)}
#' ri_points <- PointProcess(1000, ri, 42)
#' plot(ri_points)}
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' plot(mex_seq)
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' plot(ri_seq)
#' }
#'
#' @author Darren Colby \cr
Expand Down Expand Up @@ -246,19 +246,19 @@ plot.PointSim <- function(x, y, ..., title = "Simulated Points", color = "red")
#'
#' @examples \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' print(mex_points)
#' ri_points <- PointProcess(1000, ri, 42)
#' print(ri_points)
#' }
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' print(mex_seq)
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' print(ri_seq)
#' }
#'
#' @author Darren Colby \cr
Expand All @@ -284,19 +284,19 @@ print.PointSim <- function(x, ...) {
#'
#' @examples \dontrun{
#' # Create spacejamr object
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' \dontrun{
#' # With PointProcess
#' mex_points <- PointProcess(1000, mex, 42)
#' summary(mex_points)
#' ri_points <- PointProcess(1000, ri, 42)
#' summary(ri_points)
#' }
#'
#' \dontrun{
#' # With HaltonSeq
#' mex_seq <- HaltonSeq(1000, mex, 42)
#' summary(mex_seq)
#' ri_seq <- HaltonSeq(1000, ri, 42)
#' summary(ri_seq)
#' }
#'
#' @author Darren Colby \cr
Expand Down
8 changes: 4 additions & 4 deletions R/compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
#'
#' @example \dontrun{
#' # load data
#' data("mexico)
#' data("RI")
#'
#' # Simulate point process
#' mex_points <- PointProcess(50, mexico)
#' ri_points <- PointProcess(50, RI)
#'
#' # Create two networks
#' pl <- PowerLawNetwork(mex_points) # Standard power law
#' apl <- APLNetwork(mex_points) # Attenuated power law
#' pl <- PowerLawNetwork(ri_points) # Standard power law
#' apl <- APLNetwork(ri_points) # Attenuated power law
#'
#' compare_networks(pl, apl)
#' }
Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' APLNetwork \cr
#' compare_networks \cr
#' HaltonSeq \cr
#' mexico \cr
#' RI \cr
#' plot.NetSim \cr
#' plot.PointSim \cr
#' plot.spacejamr \cr
Expand Down
10 changes: 5 additions & 5 deletions R/mexico.R → R/ri.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#' Geographical administrative level 0 boundary of Mexico.
#' Geographical boundary of Rhode Island.
#'
#' A dataset containing Mexico's border and the coordinate reference system in
#' which Mexico's border is projected.
#' which RHode Island's border is projected.
#'
#' @format A spacejamr object with an owin window object and an integer denoting
#' the projected coordinate reference system:
#' \describe{
#' \item{window}{geographical boundary of Mexico}
#' \item{window}{geographical boundary of Rhode Island}
#' \item{crs}{the EPSG code for the coordinate reference system of the window}
#' ...
#' }
#' @source \url{https://data.humdata.org/dataset/mexican-administrative-level-0-country-1-estado-and-2-municipio-boundary-polygons}
"mexico"
#' @source \url{https://www.rigis.org/datasets/edc::state-boundary-1989/about}
"RI"


14 changes: 7 additions & 7 deletions R/spacejamr.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ new_spacejamr <- function(path) {
#' @return a spacejamr object
#'
#' @example \dontrun{
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' }
#'
#' @author Darren Colby \cr
Expand Down Expand Up @@ -114,8 +114,8 @@ as.spacejamr <- function(path) {
#' @return A ggplot2 object
#'
#' @example \dontrun{
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' plot(mex)
#' ri <- as.spacejamr("Z:shapefiles/ri.shp")
#' plot(ri)
#' }
#'
#' @author Darren Colby \cr
Expand Down Expand Up @@ -148,8 +148,8 @@ plot.spacejamr <- function(x, y, ..., title = "Spatial Window", fill = "blue") {
#' package.
#'
#' @example \dontrun{
#' mex <- as.spacejamr("Z:shapefiles/mexico_adm0.shp")
#' print(mex)
#' mex <- as.spacejamr("Z:shapefiles/ri.shp")
#' print(ri)
#' }
#'
#' @author Darren Colby \cr
Expand All @@ -174,8 +174,8 @@ print.spacejamr <- function(x, ...) {
#' package.
#'
#' @example \dontrun{
#' mex <- spacejamr("Z:shapefiles/mexico_adm0.shp")
#' summary(mex)
#' mex <- spacejamr("Z:shapefiles/ri.shp")
#' summary(ri)
#' }
#'
#' @author Darren Colby \cr
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ Simulate a Poisson point process and use it to generate a power law network:
library(spacejamr)

## load mexico dataset
data(mexico)
data(RI)

## Simulate a spatial Poisson point process
mex_points <- PointProcess(points = 5000, window = mexico, seed = 88)
ri_points <- PointProcess(points = 5000, window = RI, seed = 88)

## Generate a standard power law network
mexnet <- PowerLawNetwork(point_process = mex_points, base_prob = 0.95,
scale = 1000, threshold = 0.5, power = -2.3)
rinet <- PowerLawNetwork(point_process = ri, base_prob = 0.95, scale = 100,
threshold = 0.5, power = -2.3)

## Visualize the new network
plot(mexnet)
plot(rinet)

```

13 changes: 2 additions & 11 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
## Resubmission
This is a resubmission. In this version I have:

* Changed the spelling of "ggplot" to "ggplot2" in the description file.
* Changed the spelling of "ggplot" to 'ggplot2' in the description file.

* Changed "orignially" to "originally" in the description file.
* Replaced the sample dataset with a smaller dataset to save space.

* Changed "possiblt" to "possibly" in the description file.

* Replaced "spacejamr" with "this package."

* Removed the package name from the title field.

* Changed the title from sentence case to title case in the description file.

* Created a cran-comments.md file in the correct directory.

## Test environments
* local R installation, R 4.1.0
Expand Down
Binary file added data/RI.rda
Binary file not shown.
Binary file removed data/mexico.rda
Binary file not shown.
Binary file modified inst/extdata/points.rds
Binary file not shown.
Loading

0 comments on commit b6323f7

Please sign in to comment.