├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ ├── pkgdown.yaml │ └── test-coverage.yaml ├── .gitignore ├── .lintr ├── CONTRIBUTING.md ├── CRAN-SUBMISSION ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── NetLogoR.Rproj ├── R ├── Agent-classes.R ├── NetLogoR-package.R ├── agentMatrix-Class-methods.R ├── agentset-functions.R ├── function-arguments.R ├── helpers.R ├── patch-functions.R ├── plot.R ├── quickPlot.R ├── spades-functions.R ├── turtle-functions.R ├── world-functions.R └── worldNLR-classes-methods.R ├── README.md ├── _pkgdown.yml ├── codecov.yml ├── cran-comments.md ├── docs ├── 404.html ├── CNAME ├── CONTRIBUTING.html ├── articles │ ├── NLR-Dictionary.html │ ├── ProgrammingGuide.html │ └── index.html ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── docsearch.css ├── docsearch.js ├── index.html ├── link.svg ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── NLall.html │ ├── NLany.html │ ├── NLcount.html │ ├── NLdist.html │ ├── NLset.html │ ├── NLwith-1.png │ ├── NLwith.html │ ├── NLworldIndex.html │ ├── NetLogoR-package.html │ ├── PxcorPycorFromCell.html │ ├── Rplot001.png │ ├── Rplot002.png │ ├── Rplot003.png │ ├── Rplot004.png │ ├── agentMatrix-bind-methods.html │ ├── agentMatrix-class.html │ ├── agentMatrix-compare-methods.html │ ├── agentMatrix-show-methods.html │ ├── agentMatrix.html │ ├── bbox.html │ ├── bk-1.png │ ├── bk.html │ ├── canMove.html │ ├── cellFromPxcorPycor.html │ ├── clearPatches.html │ ├── coordinates.html │ ├── createOTurtles-1.png │ ├── createOTurtles.html │ ├── createTurtles-1.png │ ├── createTurtles.html │ ├── createWorld-1.png │ ├── createWorld.html │ ├── die.html │ ├── diffuse-1.png │ ├── diffuse-2.png │ ├── diffuse.html │ ├── dot-bboxCoords.html │ ├── downhill-1.png │ ├── downhill.html │ ├── dx.html │ ├── dy.html │ ├── extent.html │ ├── extract-methods.html │ ├── face-1.png │ ├── face.html │ ├── fargs.html │ ├── fd-1.png │ ├── fd.html │ ├── hatch.html │ ├── home-1.png │ ├── home.html │ ├── inCone.html │ ├── inRadius.html │ ├── index.html │ ├── initialize-agentMatrix-method.html │ ├── inspect.html │ ├── isNLclass.html │ ├── layoutCircle-1.png │ ├── layoutCircle.html │ ├── left.html │ ├── maxNof-1.png │ ├── maxNof.html │ ├── maxOneOf-1.png │ ├── maxOneOf.html │ ├── maxPxcor.html │ ├── maxPycor.html │ ├── minNof-1.png │ ├── minNof.html │ ├── minOneOf-1.png │ ├── minOneOf.html │ ├── minPxcor.html │ ├── minPycor.html │ ├── moveTo-1.png │ ├── moveTo.html │ ├── nOf.html │ ├── neighbors.html │ ├── noPatches.html │ ├── noTurtles.html │ ├── of.html │ ├── oneOf.html │ ├── other.html │ ├── pExist.html │ ├── patch.html │ ├── patchAhead.html │ ├── patchAt.html │ ├── patchDistDir.html │ ├── patchHere.html │ ├── patchLeft.html │ ├── patchRight.html │ ├── patchSet.html │ ├── patches.html │ ├── plotMethods-1.png │ ├── plotMethods-2.png │ ├── plotMethods-3.png │ ├── plotMethods.html │ ├── projNowhere.html │ ├── quickPlot-methods.html │ ├── randomPxcor.html │ ├── randomPycor.html │ ├── randomXYcor-1.png │ ├── randomXYcor.html │ ├── randomXcor-1.png │ ├── randomXcor.html │ ├── randomYcor-1.png │ ├── randomYcor.html │ ├── raster2world-1.png │ ├── raster2world-2.png │ ├── raster2world.html │ ├── right.html │ ├── setXY-1.png │ ├── setXY.html │ ├── sf2turtles.html │ ├── show-methods.html │ ├── sortOn-1.png │ ├── sortOn.html │ ├── spatRast2world-1.png │ ├── spatRast2world-2.png │ ├── spatRast2world-3.png │ ├── spatRast2world-4.png │ ├── spatRast2world.html │ ├── spdf2turtles.html │ ├── sprout.html │ ├── stackWorlds-1.png │ ├── stackWorlds.html │ ├── subHeadings.html │ ├── subsetting.html │ ├── tExist.html │ ├── towards.html │ ├── turtle.html │ ├── turtleSet.html │ ├── turtles2sf.html │ ├── turtles2spdf.html │ ├── turtlesAt.html │ ├── turtlesOn-1.png │ ├── turtlesOn.html │ ├── turtlesOwn.html │ ├── updateList.html │ ├── uphill-1.png │ ├── uphill.html │ ├── withMax-1.png │ ├── withMax.html │ ├── withMin-1.png │ ├── withMin.html │ ├── world2raster-1.png │ ├── world2raster.html │ ├── world2spatRast-1.png │ ├── world2spatRast-2.png │ ├── world2spatRast.html │ ├── worldArray-class.html │ ├── worldHeight.html │ ├── worldMatrix-class.html │ ├── worldNLR-class.html │ ├── worldWidth.html │ └── wrap.html └── sitemap.xml ├── ignore └── exampleInMS.R ├── inst ├── CITATION ├── WORDLIST └── examples │ ├── Ants │ ├── Ants.R │ └── Ants.nlogo │ ├── Butterfly │ ├── Butterfly-1.R │ └── Butterfly-1.nlogo │ └── Wolf-Sheep-Predation │ ├── README.txt │ ├── Wolf-Sheep-Predation-SpaDES.R │ ├── Wolf-Sheep-Predation.R │ ├── Wolf-Sheep-Predation.nlogo │ └── WolfSheepPredation │ ├── LICENSE │ ├── README.txt │ ├── WolfSheepPredation.R │ ├── WolfSheepPredation.Rmd │ ├── citation.bib │ ├── data │ └── CHECKSUMS.txt │ └── tests │ ├── testthat │ └── test-template.R │ └── unitTests.R ├── man ├── NLall.Rd ├── NLany.Rd ├── NLcount.Rd ├── NLdist.Rd ├── NLset.Rd ├── NLwith.Rd ├── NLworldIndex.Rd ├── NetLogoR-package.Rd ├── PxcorPycorFromCell.Rd ├── agentMatrix-bind-methods.Rd ├── agentMatrix-class.Rd ├── agentMatrix-compare-methods.Rd ├── agentMatrix-show-methods.Rd ├── agentMatrix.Rd ├── bbox.Rd ├── bk.Rd ├── canMove.Rd ├── cellFromPxcorPycor.Rd ├── clearPatches.Rd ├── coordinates.Rd ├── createOTurtles.Rd ├── createTurtles.Rd ├── createWorld.Rd ├── die.Rd ├── diffuse.Rd ├── dot-bboxCoords.Rd ├── downhill.Rd ├── dx.Rd ├── dy.Rd ├── extent.Rd ├── extract-methods.Rd ├── face.Rd ├── fargs.Rd ├── fd.Rd ├── hatch.Rd ├── home.Rd ├── inCone.Rd ├── inRadius.Rd ├── initialize-agentMatrix-method.Rd ├── inspect.Rd ├── isNLclass.Rd ├── layoutCircle.Rd ├── left.Rd ├── maxNof.Rd ├── maxOneOf.Rd ├── maxPxcor.Rd ├── maxPycor.Rd ├── minNof.Rd ├── minOneOf.Rd ├── minPxcor.Rd ├── minPycor.Rd ├── moveTo.Rd ├── nOf.Rd ├── neighbors.Rd ├── noPatches.Rd ├── noTurtles.Rd ├── of.Rd ├── oneOf.Rd ├── other.Rd ├── pExist.Rd ├── patch.Rd ├── patchAhead.Rd ├── patchAt.Rd ├── patchDistDir.Rd ├── patchHere.Rd ├── patchLeft.Rd ├── patchRight.Rd ├── patchSet.Rd ├── patches.Rd ├── plotMethods.Rd ├── projNowhere.Rd ├── quickPlot-methods.Rd ├── randomPxcor.Rd ├── randomPycor.Rd ├── randomXYcor.Rd ├── randomXcor.Rd ├── randomYcor.Rd ├── raster2world.Rd ├── right.Rd ├── setXY.Rd ├── sf2turtles.Rd ├── show-methods.Rd ├── sortOn.Rd ├── spatRast2world.Rd ├── spdf2turtles.Rd ├── sprout.Rd ├── stackWorlds.Rd ├── subHeadings.Rd ├── subsetting.Rd ├── tExist.Rd ├── towards.Rd ├── turtle.Rd ├── turtleSet.Rd ├── turtles2sf.Rd ├── turtles2spdf.Rd ├── turtlesAt.Rd ├── turtlesOn.Rd ├── turtlesOwn.Rd ├── updateList.Rd ├── uphill.Rd ├── withMax.Rd ├── withMin.Rd ├── world2raster.Rd ├── world2spatRast.Rd ├── worldArray-class.Rd ├── worldHeight.Rd ├── worldMatrix-class.Rd ├── worldNLR-class.Rd ├── worldWidth.Rd └── wrap.Rd ├── revdep ├── .gitignore ├── README.md ├── check.R ├── checks.rds ├── cran.md ├── email.yml ├── failures.md ├── problems.md └── timing.md ├── tests ├── test-all.R └── testthat │ ├── setup.R │ ├── test-NetLogoR-classes.R │ ├── test-agentMatrix.R │ ├── test-agentset-functions.R │ ├── test-patch-functions.R │ ├── test-plotting.R │ ├── test-turtle-functions.R │ └── test-world-functions.R └── vignettes ├── NLR-Dictionary.Rmd └── ProgrammingGuide.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^\.github$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | .*\.tar\.gz$ 5 | .*\.toc$ 6 | .*\.zip$ 7 | ^\.lintr$ 8 | ^codecov\.yml$ 9 | ^CONTRIBUTING\.md$ 10 | ^cran-comments\.md$ 11 | ^CRAN-RELEASE$ 12 | ^docs$ 13 | ^ignore$ 14 | ^LICENSE$ 15 | ^_pkgdown\.yml$ 16 | ^revdep$ 17 | ^travis_wait_.*\.log$ 18 | vignettes/.*_cache$ 19 | vignettes/.*\.log$ 20 | ^CRAN-SUBMISSION$ 21 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | - development 6 | - LandWeb 7 | pull_request: 8 | branches: 9 | - master 10 | - development 11 | 12 | name: R-CMD-check 13 | 14 | jobs: 15 | R-CMD-check: 16 | if: "!contains(github.event.commits[0].message, '[skip-ci]')" 17 | runs-on: ${{ matrix.config.os }} 18 | 19 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 20 | 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | config: 25 | - {os: macOS-latest, nosuggests: false, r: 'release'} 26 | - {os: windows-latest, nosuggests: false, r: 'devel'} 27 | - {os: windows-latest, nosuggests: false, r: 'release'} 28 | - {os: windows-latest, nosuggests: false, r: '4.1'} 29 | - {os: windows-latest, nosuggests: false, r: '4.0'} 30 | - {os: ubuntu-20.04, nosuggests: false, r: 'devel'} 31 | - {os: ubuntu-20.04, nosuggests: false, r: 'release'} 32 | - {os: ubuntu-20.04, nosuggests: true, r: 'release'} 33 | - {os: ubuntu-20.04, nosuggests: false, r: 'oldrel'} 34 | - {os: ubuntu-20.04, nosuggests: false, r: '4.0'} 35 | 36 | env: 37 | _R_CHECK_DEPENDS_ONLY_: ${{ matrix.config.nosuggests }} 38 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 39 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true 40 | 41 | steps: 42 | - uses: actions/checkout@v3 43 | 44 | - uses: r-lib/actions/setup-pandoc@v2 45 | 46 | - uses: PredictiveEcology/actions/install-spatial-deps@main 47 | 48 | - uses: r-lib/actions/setup-r@v2 49 | with: 50 | extra-repositories: 'https://predictiveecology.r-universe.dev/' 51 | Ncpus: 2 52 | use-public-rspm: false 53 | 54 | - uses: r-lib/actions/setup-r-dependencies@v2 55 | with: 56 | extra-packages: | 57 | any::rcmdcheck 58 | fastshp=?ignore 59 | PredictiveEcology/quickPlot@development 60 | PredictiveEcology/reproducible@development 61 | PredictiveEcology/Require@development 62 | PredictiveEcology/SpaDES.core@development 63 | PredictiveEcology/SpaDES.tools@development 64 | 65 | - name: Install additional package dependencies 66 | run: | 67 | pak::pkg_install("remotes") 68 | remotes::install_github("s-u/fastshp") 69 | shell: Rscript {0} 70 | 71 | - uses: r-lib/actions/check-r-package@v2 72 | 73 | - name: Show testthat output 74 | if: always() 75 | run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true 76 | shell: bash 77 | 78 | - name: Upload check results 79 | if: failure() 80 | uses: actions/upload-artifact@main 81 | with: 82 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 83 | path: check 84 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | name: pkgdown 13 | 14 | jobs: 15 | pkgdown: 16 | runs-on: ubuntu-latest 17 | # Only restrict concurrency for non-PR jobs 18 | concurrency: 19 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 20 | env: 21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - uses: r-lib/actions/setup-pandoc@v2 26 | 27 | - uses: PredictiveEcology/actions/install-spatial-deps@main 28 | 29 | - uses: r-lib/actions/setup-r@v2 30 | with: 31 | extra-repositories: 'https://predictiveecology.r-universe.dev/' 32 | Ncpus: 2 33 | use-public-rspm: false 34 | 35 | - uses: r-lib/actions/setup-r-dependencies@v2 36 | with: 37 | extra-packages: | 38 | any::pkgdown 39 | local::. 40 | fastshp=?ignore 41 | PredictiveEcology/quickPlot@development 42 | PredictiveEcology/reproducible@development 43 | PredictiveEcology/Require@development 44 | PredictiveEcology/SpaDES.core@development 45 | PredictiveEcology/SpaDES.tools@development 46 | needs: website 47 | 48 | - name: Install additional package dependencies 49 | run: | 50 | pak::pkg_install("remotes") 51 | remotes::install_github("s-u/fastshp") 52 | shell: Rscript {0} 53 | 54 | - name: Build site 55 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 56 | shell: Rscript {0} 57 | 58 | - name: Deploy to GitHub pages 🚀 59 | if: github.event_name != 'pull_request' 60 | uses: JamesIves/github-pages-deploy-action@4.1.4 61 | with: 62 | clean: false 63 | branch: gh-pages 64 | folder: docs 65 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | - development 6 | pull_request: 7 | branches: 8 | - master 9 | - development 10 | 11 | name: test-coverage 12 | 13 | jobs: 14 | test-coverage: 15 | if: "!contains(github.event.commits[0].message, '[skip-ci]')" 16 | runs-on: macOS-latest 17 | env: 18 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - uses: r-lib/actions/setup-pandoc@v2 24 | 25 | - uses: PredictiveEcology/actions/install-spatial-deps@main 26 | 27 | - uses: r-lib/actions/setup-r@v2 28 | with: 29 | extra-repositories: 'https://predictiveecology.r-universe.dev/' 30 | Ncpus: 2 31 | use-public-rspm: false 32 | 33 | - uses: r-lib/actions/setup-r-dependencies@v2 34 | with: 35 | extra-packages: | 36 | any::covr 37 | fastshp=?ignore 38 | PredictiveEcology/quickPlot@development 39 | PredictiveEcology/reproducible@development 40 | PredictiveEcology/Require@development 41 | PredictiveEcology/SpaDES.core@development 42 | PredictiveEcology/SpaDES.tools@development 43 | 44 | - name: Install additional package dependencies 45 | run: | 46 | pak::pkg_install("remotes") 47 | remotes::install_github("s-u/fastshp") 48 | shell: Rscript {0} 49 | 50 | - name: Test coverage 51 | run: covr::codecov() 52 | shell: Rscript {0} 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .csv 2 | .log 3 | .Rapp.history 4 | .RData 5 | .Rhistory 6 | .Rproj.user 7 | revdep/.cache.rds 8 | tests/testthat/*.pdf 9 | tests/testthat/*.RData 10 | vignettes/.build.timestamp 11 | vignettes/*_cache 12 | vignettes/*_files 13 | vignettes/*.html 14 | vignettes/*.R 15 | -------------------------------------------------------------------------------- /.lintr: -------------------------------------------------------------------------------- 1 | linters: linters_with_defaults(line_length_linter(100), object_name_linter("camelCase"), defaults = default_linters[-which(names(default_linters) == "object_usage_linter")]) 2 | exclusions: list("vignettes/ProgrammingGuide.R") 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | We welcome contributions to `NetLogoR`, both as bug reports or package enhancements. 2 | 3 | ## Report a bug 4 | 5 | 1. Use the [issue tracker](https://github.com/PredictiveEcology/NetLogoR/issues) to report a bug. 6 | 7 | 2. Please include a minimum reproducible example that triggers the bug. 8 | 9 | 3. Please include the output of `devtools::session_info()`. 10 | 11 | ## Submit an enhancement 12 | 13 | 1. [Fork](https://github.com/rstudio/rstudio/fork) the repository and make your changes. 14 | 15 | 2. Please follow our code [style guide](https://github.com/PredictiveEcology/SpaDES/wiki/Dev-Docs---Code-Style-Guide) and make your code as easy to follow as possible. 16 | 17 | 3. If adding new functionality, please include instructional examples and/or [unit tests](http://r-pkgs.had.co.nz/tests.html). 18 | 19 | 3. Submit a [pull request](https://docs.github.com/articles/using-pull-requests) against the development branch. 20 | 21 | We'll try to review your pull request and provide feedback / merge improvements as quickly as possible. 22 | 23 | Thank you! 24 | -------------------------------------------------------------------------------- /CRAN-SUBMISSION: -------------------------------------------------------------------------------- 1 | Version: 0.3.11 2 | Date: 2022-08-16 22:40:41 UTC 3 | SHA: 7b0ac6fe864346d0077e4e97f0b0288c54656a21 4 | -------------------------------------------------------------------------------- /NetLogoR.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --with-keep.source 21 | PackageCheckArgs: --as-cran 22 | PackageRoxygenize: rd,collate,namespace,vignette 23 | 24 | UseNativePipeOperator: Yes 25 | 26 | QuitChildProcessesOnExit: Yes 27 | -------------------------------------------------------------------------------- /R/Agent-classes.R: -------------------------------------------------------------------------------- 1 | utils::globalVariables(c("xcor", "ycor")) 2 | 3 | #' The `agentMatrix` class 4 | #' 5 | #' @name agentMatrix-class 6 | #' @rdname agentMatrix-class 7 | #' @author Eliot McIntire 8 | #' @exportClass agentMatrix 9 | #' @examples 10 | #' newAgent <- new("agentMatrix", 11 | #' coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 12 | #' char = letters[c(1, 2, 6)], 13 | #' nums2 = c(4.5, 2.6, 2343), 14 | #' char2 = LETTERS[c(4, 24, 3)], 15 | #' nums = 5:7 16 | #' ) 17 | #' 18 | #' # compare speeds -- about 5x faster 19 | #' if (requireNamespace("microbenchmark", quietly = TRUE) && 20 | #' requireNamespace("sp", quietly = TRUE)) { 21 | #' microbenchmark::microbenchmark( 22 | #' times = 499, 23 | #' spdf = { 24 | #' sp::SpatialPointsDataFrame( 25 | #' coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 26 | #' data = data.frame( 27 | #' char = letters[c(1, 2, 6)], 28 | #' nums2 = c(4.5, 2.6, 2343), 29 | #' char2 = LETTERS[c(4, 24, 3)], 30 | #' nums = 5:7 31 | #' ) 32 | #' ) 33 | #' }, 34 | #' agentMat = { 35 | #' agentMatrix( 36 | #' coords = cbind( 37 | #' pxcor = c(1, 2, 5), 38 | #' pycor = c(3, 4, 6) 39 | #' ), 40 | #' char = letters[c(1, 2, 6)], 41 | #' nums2 = c(4.5, 2.6, 2343), 42 | #' char2 = LETTERS[c(4, 24, 3)], 43 | #' nums = 5:7 44 | #' ) 45 | #' }, 46 | #' agentMatDirect = { 47 | #' new("agentMatrix", 48 | #' coords = cbind( 49 | #' pxcor = c(1, 2, 5), 50 | #' pycor = c(3, 4, 6) 51 | #' ), 52 | #' char = letters[c(1, 2, 6)], 53 | #' nums2 = c(4.5, 2.6, 2343), 54 | #' char2 = LETTERS[c(4, 24, 3)], 55 | #' nums = 5:7 56 | #' ) 57 | #' } 58 | #' ) 59 | #' } 60 | setClass("agentMatrix", 61 | contains = "matrix", 62 | slots = c(x = "matrix", levels = "list", bbox = "matrix"), 63 | prototype = prototype( 64 | x = matrix(numeric()), levels = list(), bbox = matrix(numeric()) 65 | ) 66 | ) 67 | -------------------------------------------------------------------------------- /R/NetLogoR-package.R: -------------------------------------------------------------------------------- 1 | #' The `NetLogoR` package 2 | #' 3 | #' The suggested package \pkg{fastshp} can be installed with 4 | #' `install.packages("fastshp", repos = "https://rforge.net", type = "source")`. 5 | #' The examples included with the package, are located in the R package "examples" folder, 6 | #' which can be found at `system.file(package = "NetLogoR", "examples")`. 7 | #' 8 | #' The 3 specific R examples can be opened here, but it's recommended to make copies of these 9 | #' for editing: 10 | #' 11 | #' ```r 12 | #' exPath <- file.path(system.file(package = "NetLogoR", "examples") 13 | #' file.edit(exPath, "Ants", "Ants.R")) 14 | #' file.edit(exPath, "Butterfly", "Butterfly-1.R")) 15 | #' file.edit(exPath, "Wolf-Sheep-Predation", "Wolf-Sheep-Predation.R")) 16 | #' ``` 17 | #' 18 | "_PACKAGE" 19 | 20 | #' @import methods 21 | NULL 22 | 23 | #' Internal CRS usage 24 | #' 25 | #' This is used in various places when converting `agentMatrix` objects to 26 | #' `SpatialPoints` for use with functions, such as `raster::buffer()`. 27 | #' None of these functions results in any real geospatial information being conserved, 28 | #' other than distance and angle calculations. Buffering still occurs on the 29 | #' unit-less World. This is therefore a way to allow `sp` and `raster` 30 | #' functions to work *as if a cell in the World was equal to 1 m*. The resulting 31 | #' answers will be converted back to units of "cells", not "m". 32 | #' The `CRS()` operation is relatively time consuming. 33 | #' Having a single object usable throughout is *much* faster. 34 | #' 35 | #' @keywords internal 36 | #' @rdname projNowhere 37 | .projNowhere <- terra::crs("+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs") 38 | # This is actually in central Europe; but exact 39 | # location is not relevant as this is used to calculate 40 | # distances .projNowhere <- CRS("EPSG:32632") 41 | -------------------------------------------------------------------------------- /R/helpers.R: -------------------------------------------------------------------------------- 1 | rename <- function(x, from, to) { 2 | to[match(x, from)] 3 | } 4 | 5 | resample <- function(x, ...) x[sample.int(length(x), ...)] 6 | 7 | sampleWithin <- function(group) { 8 | tapply(seq_along(group), group, resample, 1) 9 | } 10 | 11 | .coordsColNames <- c("xcor", "ycor") 12 | -------------------------------------------------------------------------------- /R/plot.R: -------------------------------------------------------------------------------- 1 | #' Basic plot methods for `agentMatrix`, `worldMatrix`, `worldArray` 2 | #' 3 | #' These pass to plot, as a matrix of points (`agentMatrix`), as a `raster` (`worldMatrix`), 4 | #' or a `rasterStack` (`worldArray`). 5 | #' They can be modified. 6 | #' 7 | #' @param x an `agentMatrix`, `worldMatrix` or `worldArray` object 8 | #' @param ... arguments passed to plot methods for matrix (`agentMatrix`) or `raster` (`world*`) 9 | #' 10 | #' @return none; invoked for side-effect of generating a plot. 11 | #' 12 | #' @export 13 | #' @method plot agentMatrix 14 | #' @rdname plotMethods 15 | #' 16 | #' @examples 17 | #' # agentMatrix 18 | #' newAgent <- new("agentMatrix", 19 | #' coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 20 | #' char = letters[c(1, 2, 6)], 21 | #' nums2 = c(4.5, 2.6, 2343), 22 | #' char2 = LETTERS[c(4, 24, 3)], 23 | #' nums = 5:7 24 | #' ) 25 | #' plot(newAgent) 26 | plot.agentMatrix <- function(x, ...) { 27 | plot(x@.Data, ...) 28 | } 29 | 30 | #' @export 31 | #' @method plot worldMatrix 32 | #' @rdname plotMethods 33 | #' 34 | #' @examples 35 | #' 36 | #' ## worldMatrix 37 | #' w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = 1:100) 38 | #' plot(w1) 39 | plot.worldMatrix <- function(x, ...) { 40 | Ras <- world2spatRast(x) 41 | terra::plot(Ras, ...) 42 | } 43 | 44 | #' @export 45 | #' @method plot worldArray 46 | #' @rdname plotMethods 47 | #' 48 | #' @examples 49 | #' 50 | #' ## worldArray 51 | #' w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = 1:25) 52 | #' w2 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = 25:1) 53 | #' w3 <- stackWorlds(w1, w2) 54 | #' plot(w3) 55 | plot.worldArray <- function(x, ...) { 56 | Ras <- world2spatRast(x) 57 | terra::plot(Ras, ...) 58 | } 59 | 60 | #' @export 61 | #' @importFrom graphics points 62 | #' @method points agentMatrix 63 | #' @rdname plotMethods 64 | #' 65 | #' @examples 66 | #' 67 | #' # agentMatrix 68 | #' newAgent <- new("agentMatrix", 69 | #' coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 70 | #' char = letters[c(1, 2, 6)], 71 | #' nums2 = c(4.5, 2.6, 2343), 72 | #' char2 = LETTERS[c(4, 24, 3)], 73 | #' nums = 5:7 74 | #' ) 75 | #' points(newAgent) 76 | points.agentMatrix <- function(x, ...) { 77 | points(x@.Data, ...) 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NetLogoR 2 | 3 | 4 | [![R build status](https://github.com/PredictiveEcology/NetLogoR/workflows/R-CMD-check/badge.svg)](https://github.com/PredictiveEcology/NetLogoR/actions) 5 | [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/NetLogoR)](https://cran.r-project.org/package=NetLogoR) 6 | [![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/NetLogoR)](https://cran.r-project.org/package=NetLogoR) 7 | [![Codecov test coverage](https://codecov.io/gh/PredictiveEcology/NetLogoR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/PredictiveEcology/NetLogoR?branch=master) 8 | 9 | 10 | ## Build and run spatially explicit agent-based models in R 11 | 12 | `NetLogoR` is an R package to build and run spatially explicit agent-based models using only the R platform ([Bauduin et al., 2019](https://doi.org/10.1111/ecog.04516)). 13 | It follows the same framework as NetLogo ([Wilensky, 1999](http://ccl.northwestern.edu/netlogo/)) and is a translation in R language of the structure and functions of NetLogo ([NetLogo primitives](https://ccl.northwestern.edu/netlogo/docs/dictionary.html)). 14 | `NetLogoR` provides new R classes to define model agents and functions to implement spatially explicit agent-based models in the R environment. 15 | This package allows benefiting of the fast and easy coding phase from the highly developed NetLogo's framework, coupled with the versatility, power and massive resources of the R software. 16 | 17 | ## Getting Started 18 | 19 | Examples of three models ([Ants](http://ccl.northwestern.edu/netlogo/models/Ants), Butterfly (Railsback and Grimm, 2012) and [Wolf-Sheep-Predation](http://ccl.northwestern.edu/netlogo/models/WolfSheepPredation)) written using `NetLogoR` are available. The NetLogo code of the original version of these models is provided alongside. 20 | A programming guide inspired from the [NetLogo Programming Guide](https://ccl.northwestern.edu/netlogo/docs/programming.html) and a dictionary of [NetLogo primitives](https://ccl.northwestern.edu/netlogo/docs/dictionary.html) equivalences are also available. 21 | A model simulating the wolf life cycle written using `NetLogoR` has been published ([Bauduin et al., 2020](https://www.sciencedirect.com/science/article/pii/S0304380020302799?via%3Dihub)) with the ([code available on GitHub](https://github.com/SarahBauduin/appendix_wolfIBM)). 22 | 23 | ## Installing `NetLogoR` 24 | 25 | ### From CRAN 26 | 27 | Currently, the package is not on CRAN due to some dependencies that were removed from CRAN. It will be there soon. 28 | 29 | In the mean time, please use: 30 | ```r 31 | # install.packages("NetLogoR") 32 | install.packages("NetLogoR", repos = c(https://predictiveecology.r-universe.dev, getOption("repos"))) 33 | ``` 34 | 35 | ### From GitHub 36 | 37 | ```r 38 | #install.packages("devtools") 39 | devtools::install_github("PredictiveEcology/NetLogoR") 40 | ``` 41 | 42 | ## Getting help 43 | 44 | Please email developers or start an issue on the [NetLogoR](https://Github.com/PredictiveEcology/NetLogoR) web page. 45 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://netlogor.predictiveecology.org 2 | 3 | template: 4 | params: 5 | bootswatch: flatly 6 | ganalytics: UA-58633549-3 7 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | informational: true 10 | patch: 11 | default: 12 | target: auto 13 | threshold: 1% 14 | informational: true 15 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Updated release 2 | 3 | This release is to put the package back on CRAN after being removed due to a dependency removal. There are other minor changes. 4 | See `NEWS.md` for a full list of changes. 5 | 6 | ## Test environments 7 | 8 | ### Previous R versions 9 | * Ubuntu 20.04 (GitHub), R 4.2.3 10 | * Ubuntu 20.04 (GitHub), R 4.2.3 11 | * Windows (GitHub), R 4.2.3 12 | * Windows (GitHub), R 4.2.3 13 | * Windows (win-builder), R 4.2.3 14 | 15 | ### Current R versions 16 | * macOS 12.6.3 Monterey (GitHub), 4.3.2 (2023-10-31) 17 | * Ubuntu 20.04 (GitHub), 4.3.2 (2023-10-31) 18 | * Ubuntu 20.04 (local), 4.3.2 (2023-10-31) 19 | * Windows (GitHub), 4.3.2 (2023-10-31 ucrt) 20 | * Windows (local), 4.3.2 (2023-10-31 ucrt) 21 | * Windows (win-builder), 4.3.2 (2023-10-31 ucrt) 22 | 23 | ### Development R version 24 | * Ubuntu 20.04 (GitHub), R-devel (2023-07-03 r84633) 25 | * Ubuntu 20.04 (local), R-devel (2023-07-03 r84633) 26 | * Windows (GitHub), R-devel (2023-12-20 r85711 ucrt) 27 | * Windows (win-builder), R-devel (2023-12-20 r85711 ucrt) 28 | * Windows (local), R-devel (2023-12-20 r85711 ucrt) 29 | 30 | ## R CMD check results 31 | 32 | There were no ERRORs or WARNINGs. 33 | 34 | There was 2 NOTEs: 35 | 36 | 1. Package suggested but not available for checking: 'fastshp'. This is available at an "Additional_repositories" and the instructions are given: 37 | Suggests or Enhances not in mainstream repositories: 38 | fastshp 39 | Availability using Additional_repositories specification: 40 | fastshp yes https://predictiveecology.r-universe.dev/ 41 | 2. The other is 3 possible spelling errors. These are all in the WORDLIST file and are correct. 42 | 43 | ## Downstream dependencies 44 | 45 | There are currently no downstream dependencies of this package. 46 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | netlogor.predictiveecology.org -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 3.1.1 2 | pkgdown: 2.0.7 3 | pkgdown_sha: ~ 4 | articles: 5 | NLR-Dictionary: NLR-Dictionary.html 6 | ProgrammingGuide: ProgrammingGuide.html 7 | last_built: 2023-12-20T18:26Z 8 | urls: 9 | reference: https://netlogor.predictiveecology.org/reference 10 | article: https://netlogor.predictiveecology.org/articles 11 | 12 | -------------------------------------------------------------------------------- /docs/reference/NLwith-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/NLwith-1.png -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/Rplot002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/Rplot002.png -------------------------------------------------------------------------------- /docs/reference/Rplot003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/Rplot003.png -------------------------------------------------------------------------------- /docs/reference/Rplot004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/Rplot004.png -------------------------------------------------------------------------------- /docs/reference/bk-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/bk-1.png -------------------------------------------------------------------------------- /docs/reference/createOTurtles-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/createOTurtles-1.png -------------------------------------------------------------------------------- /docs/reference/createTurtles-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/createTurtles-1.png -------------------------------------------------------------------------------- /docs/reference/createWorld-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/createWorld-1.png -------------------------------------------------------------------------------- /docs/reference/diffuse-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/diffuse-1.png -------------------------------------------------------------------------------- /docs/reference/diffuse-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/diffuse-2.png -------------------------------------------------------------------------------- /docs/reference/downhill-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/downhill-1.png -------------------------------------------------------------------------------- /docs/reference/face-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/face-1.png -------------------------------------------------------------------------------- /docs/reference/fd-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/fd-1.png -------------------------------------------------------------------------------- /docs/reference/home-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/home-1.png -------------------------------------------------------------------------------- /docs/reference/layoutCircle-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/layoutCircle-1.png -------------------------------------------------------------------------------- /docs/reference/maxNof-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/maxNof-1.png -------------------------------------------------------------------------------- /docs/reference/maxOneOf-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/maxOneOf-1.png -------------------------------------------------------------------------------- /docs/reference/minNof-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/minNof-1.png -------------------------------------------------------------------------------- /docs/reference/minOneOf-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/minOneOf-1.png -------------------------------------------------------------------------------- /docs/reference/moveTo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/moveTo-1.png -------------------------------------------------------------------------------- /docs/reference/plotMethods-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/plotMethods-1.png -------------------------------------------------------------------------------- /docs/reference/plotMethods-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/plotMethods-2.png -------------------------------------------------------------------------------- /docs/reference/plotMethods-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/plotMethods-3.png -------------------------------------------------------------------------------- /docs/reference/randomXYcor-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/randomXYcor-1.png -------------------------------------------------------------------------------- /docs/reference/randomXcor-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/randomXcor-1.png -------------------------------------------------------------------------------- /docs/reference/randomYcor-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/randomYcor-1.png -------------------------------------------------------------------------------- /docs/reference/raster2world-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/raster2world-1.png -------------------------------------------------------------------------------- /docs/reference/raster2world-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/raster2world-2.png -------------------------------------------------------------------------------- /docs/reference/setXY-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/setXY-1.png -------------------------------------------------------------------------------- /docs/reference/sortOn-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/sortOn-1.png -------------------------------------------------------------------------------- /docs/reference/spatRast2world-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/spatRast2world-1.png -------------------------------------------------------------------------------- /docs/reference/spatRast2world-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/spatRast2world-2.png -------------------------------------------------------------------------------- /docs/reference/spatRast2world-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/spatRast2world-3.png -------------------------------------------------------------------------------- /docs/reference/spatRast2world-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/spatRast2world-4.png -------------------------------------------------------------------------------- /docs/reference/stackWorlds-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/stackWorlds-1.png -------------------------------------------------------------------------------- /docs/reference/turtlesOn-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/turtlesOn-1.png -------------------------------------------------------------------------------- /docs/reference/uphill-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/uphill-1.png -------------------------------------------------------------------------------- /docs/reference/withMax-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/withMax-1.png -------------------------------------------------------------------------------- /docs/reference/withMin-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/withMin-1.png -------------------------------------------------------------------------------- /docs/reference/world2raster-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/world2raster-1.png -------------------------------------------------------------------------------- /docs/reference/world2spatRast-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/world2spatRast-1.png -------------------------------------------------------------------------------- /docs/reference/world2spatRast-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/docs/reference/world2spatRast-2.png -------------------------------------------------------------------------------- /ignore/exampleInMS.R: -------------------------------------------------------------------------------- 1 | library(NetLogoR) 2 | # install.packages("nnls") 3 | # install.packages("lcmix", repos="http://R-Forge.R-project.org") 4 | # install.packagse("MASS") 5 | library(lcmix) 6 | library(MASS) 7 | 8 | # AGENTS 9 | # Create a square landscape of 9 by 9 cells (81 cells total) 10 | # Cell values are randomly chosen either 1 or 2 11 | land <- createWorld(minPxcor = 1, maxPxcor = 9, 12 | minPycor = 1, maxPycor = 9, 13 | sample(c(1, 2), 81, replace = TRUE)) 14 | plot(land) # visualize the landscape 15 | # Create three moving individuals (Three turtles) 16 | # Place the turtles in the middle of the landscape just created 17 | t1 <- createTurtles(n = 3, world = land) 18 | points(t1) # visualize the turtles on the landscape 19 | distRate <- 0.5 20 | # MODEL 21 | for(i in 1:10){ # run the model 10 times 22 | # Are the turtles on a 1 or a 2 cell 23 | # If it is on a 1, it will move a 1-cell distance 24 | # If it is on a 2, it will move a 2-cell distance 25 | # First, identify the cell the turtles are on 26 | cellTurtle <- patchHere(world = land, turtles = t1) 27 | # Then, what is the value of this cell 28 | distMove <- of(world = land, agents = cellTurtle) 29 | # The tutle moves with a mean of 1 or 2-cell distance 30 | # at the time (distMove), drawn from a multivariate gamma 31 | # distribution to show that agents move similar distances, 32 | # i.e., part of a social group or affected by unmeasured 33 | # conditions. 34 | distShape <- distMove * distRate 35 | rho <- matrix(rep(0.8, length = nrow(t1)* nrow(t1)), ncol = nrow(t1)) 36 | diag(rho) <- 1 37 | distMoveRan <- rmvgamma(2, distShape, distRate, rho)[1,] # vector 38 | # The landscape is not a torus 39 | # And the turtles cannot move outside of the landscape 40 | t1 <- fd(turtles = t1, dist = distMoveRan, 41 | world = land, torus = FALSE, out = FALSE) 42 | # Then the turtles rotate with a multivariate normal turn 43 | # angle, based on the mean of the group, correlated at 0.8 44 | meanHeading <- mean(of(agents = t1, var = "heading")) 45 | Sigma <- matrix(rep(0.8 * meanHeading, length = nrow(t1) * nrow(t1)), ncol = nrow(t1)) 46 | diag(Sigma) <- meanHeading 47 | angleInd = mvrnorm(n = 1, mu = rep(meanHeading, nrow(t1)), Sigma = Sigma)#sd = 45) 48 | # The turtles rotate to the right (angleInd positive) 49 | # Or to the left (angleInd negative) 50 | t1 <- right(turtles = t1, angle = angleInd) 51 | points(t1) # visualize the turtles' new position 52 | } 53 | 54 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite NetLogoR in publications use:") 2 | 3 | bibentry( 4 | bibtype = "Article", 5 | title = "{NetLogoR}: A package to build and run spatially explicit agent‐based models in R", 6 | author = c(person("Sarah", "Bauduin"), 7 | person("Eliot J B", "McIntire"), 8 | person("Alex M", "Chubaty")), 9 | journal = "Ecography", 10 | year = "2019", 11 | volume = "42", 12 | number = "11", 13 | pages = "1841-1849", 14 | doi = "10.1111/ecog.04516" 15 | ) 16 | 17 | bibentry( 18 | bibtype = "Manual", 19 | title = "{NetLogoR}: Build and Run Spatially Explicit Agent-Based Models", 20 | author = c(person("Sarah", "Bauduin"), 21 | person("Eliot J B", "McIntire"), 22 | person("Alex M", "Chubaty")), 23 | year = sub("-.*", "", meta$Date), 24 | note = sprintf("R package version %s", meta$Version), 25 | url = "https://CRAN.R-project.org/package=NetLogoR" 26 | ) 27 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | 1m 2 | 2x2 3 | Agentsets 4 | BehaviorSpace 5 | Bugfixes 6 | CRS 7 | Center 8 | Codecov 9 | DescTools 10 | Ecography 11 | Evanston 12 | GDAL 13 | GitHub 14 | HubNet 15 | IDPmisc 16 | Indices 17 | Modeling 18 | Neighbors 19 | NetLogo 20 | ORCID 21 | PROJ 22 | Predation 23 | PredictiveEcology 24 | RStudio 25 | Railsback 26 | SpaDES 27 | SpatialLines 28 | Subelements 29 | Tinn 30 | Wilensky 31 | acos 32 | agentMatrix 33 | agentset 34 | agentsets 35 | al 36 | asin 37 | atan 38 | autoplot 39 | backtick 40 | bbox 41 | beepr 42 | behaviorspace 43 | bugfixes 44 | butfirst 45 | ccl 46 | cd 47 | center 48 | centered 49 | color 50 | colors 51 | coordiantes 52 | correponds 53 | cp 54 | cro 55 | crs 56 | crt 57 | diffuse4 58 | dimensioned 59 | distancexy 60 | downhill4 61 | dx 62 | dy 63 | edu 64 | end1 65 | end2 66 | et 67 | explicitely 68 | facexy 69 | fastshp 70 | fd 71 | foreach 72 | fput 73 | geospatial 74 | github 75 | globals 76 | google 77 | gray 78 | hsb 79 | http 80 | https 81 | hubnet 82 | ifelse 83 | indices 84 | ln 85 | lput 86 | lt 87 | modeest 88 | neighbor 89 | neighboring 90 | neighbors 91 | neighbors4 92 | netlogo 93 | netlogor 94 | num 95 | pcolor 96 | pcolors 97 | pe 98 | plabel 99 | plotxy 100 | poisson 101 | pu 102 | pxcor 103 | pycor 104 | radians 105 | repos 106 | rforge 107 | rgb 108 | rp 109 | runresult 110 | s4 111 | se 112 | setxy 113 | sp 114 | towardsxy 115 | tutte 116 | undirected 117 | uphill4 118 | versa 119 | worldArray 120 | worldMatrix 121 | xcor 122 | xy 123 | ycor 124 | -------------------------------------------------------------------------------- /inst/examples/Butterfly/Butterfly-1.R: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Butterfly Hilltopping model (Butterfly-1.nlogo) 3 | # by Railsback and Grimm (2012), pages 47-59 4 | # 5 | # Converted into R using the NetLogoR package 6 | # by Sarah Bauduin 7 | # 8 | # 9 | 10 | library(NetLogoR) 11 | 12 | # Create a world with the desired extent 13 | elevation <- createWorld(minPxcor = 0, maxPxcor = 149, minPycor = 0, maxPycor = 149) 14 | 15 | # Define the patches values 16 | # Elevation decreases linearly with distance from the center of the hill 17 | # Hills are at (30,30) and (120,100) 18 | # The 1st hill is 100 units high, the 2nd hill is 50 units high 19 | elev1 <- 100 - NLdist(agents = patches(elevation), agents2 = cbind(x = 30, y = 30)) 20 | elev2 <- 50 - NLdist(agents = patches(elevation), agents2 = cbind(x = 120, y = 100)) 21 | pElevation <- ifelse(elev1 > elev2, elev1, elev2) 22 | # Assign the elevation values to the patches 23 | elevation <- NLset(world = elevation, agents = patches(elevation), val = pElevation) 24 | 25 | # Visualize the world 26 | plot(elevation) 27 | 28 | # Create turtles (one butterfly in this model) 29 | # The butterfly's initial location is [85, 95] 30 | t1 <- createTurtles(n = 1, coords = cbind(xcor = 85, ycor = 95)) 31 | # Can try with 100 butterflies by changing n to 100 in the line above 32 | # Visualize the turtle 33 | points(t1, pch = 16) 34 | 35 | # Define the global variable needed 36 | q <- 0.4 # q is the probability to move directly to the highest surrounding patch 37 | 38 | # Create a go procedure with a for loop 39 | # what is inside this loop will be iterated 1000 times 40 | for (time in 1:1000) { 41 | # The "move" function can be written directly here 42 | # or before in the script as a separate function and then called here 43 | # The output of the NetLogoR functions is the turtle t1 and it needs to be reassigned to t1 44 | # so that the updated turtle t1 is used at each time step 45 | 46 | if (runif(n = 1, min = 0, max = 1) < q) { 47 | # Move the turtle t1 uphill considering 8 neighbor patches in the elevation world 48 | t1 <- uphill(world = elevation, turtles = t1, nNeighbors = 8) 49 | } else { 50 | # Or move the turtle t1 to one of its neighbor patches at random in the elevation world 51 | # Creating local variables 52 | # instead of putting everything in the same one line code helps to understand 53 | # It is also useful for debugging 54 | allNeighbors <- neighbors(world = elevation, agents = t1, nNeighbors = 8) 55 | oneNeighbor <- oneOf(allNeighbors) 56 | t1 <- moveTo(turtles = t1, agents = oneNeighbor) 57 | } 58 | 59 | # Visualize each new position for t1 60 | # Very slow, remove for speed 61 | points(t1, pch = 16) 62 | 63 | # Show the time step on the screen 64 | # Slow, remove for speed 65 | print(time) 66 | } 67 | -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/README.txt: -------------------------------------------------------------------------------- 1 | The file "Wolf-Sheep-Predation.R" contains the code to run the model built using a for loop to manage time. 2 | The code for the model is in the same file. 3 | 4 | The file "Wolf-Sheep-Predation-SpaDES.R" contains the code to run the model built using the pacakage SpaDES and its scheduler function to manage time. 5 | The SpaDES version of the model (called "module") is in the folder "WolfSheepPredation". -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/Wolf-Sheep-Predation-SpaDES.R: -------------------------------------------------------------------------------- 1 | # Run the WolfSheepPredation SpaDES module 2 | library(NetLogoR) 3 | library(quickPlot) 4 | if (requireNamespace("SpaDES.core") && requireNamespace("SpaDES.tools")) { 5 | 6 | # Parameters values 7 | wolfSheepParams <- list(.plotInitialTime = 0, .plotInterval = 10, 8 | .saveInitialTime = 0, .saveInterval = 1, 9 | grassOn = TRUE, grassTGrowth = 30, 10 | nSheep = 100, gainFoodSheep = 4, reproSheep = 4, 11 | nWolf = 50, gainFoodWolf = 20, reproWolf = 5) 12 | 13 | # Model init 14 | wolfSheepSim <- SpaDES.core::simInit( 15 | times = list(start = 0, end = 500), 16 | params = list(WolfSheepPredation = wolfSheepParams), 17 | modules = list("WolfSheepPredation"), 18 | paths = list(modulePath = system.file("examples/Wolf-Sheep-Predation", package = "NetLogoR")) 19 | ) 20 | # Run the model 21 | wolfSheepRun <- SpaDES.core::spades(wolfSheepSim) # use debug=FALSE for no messaging 22 | 23 | # Plot outputs 24 | dev(6) 25 | clearPlot() 26 | timeStep <- seq_along(wolfSheepRun$numSheep) 27 | 28 | maxSheep <- max(wolfSheepRun$numSheep) 29 | maxWolves <- max(wolfSheepRun$numWolves) 30 | maxGreen <- max(wolfSheepRun$numGreen / 4) 31 | 32 | if (wolfSheepParams$grassOn == TRUE) { 33 | plot(timeStep, wolfSheepRun$numSheep, type = "l", col = "blue", lwd = 2, 34 | ylab = "Population size", xlab = "Time step", 35 | ylim = c(min = 0, max = max(c(maxSheep, maxWolves, maxGreen)))) 36 | lines(timeStep, wolfSheepRun$numWolves, col = "red", lwd = 2) 37 | lines(timeStep, wolfSheepRun$numGreen / 4, col = "green", lwd = 2) 38 | 39 | legend("topleft", legend = c("Sheep", "Wolves", "Grass / 4"), lwd = c(2, 2, 2), 40 | col = c("blue", "red", "green"), bg = "white") 41 | } else { 42 | plot(timeStep, wolfSheepRun$numSheep, type = "l", col = "blue", lwd = 2, 43 | ylab = "Population size", xlab = "Time step", 44 | ylim = c(min = 0, max = max(c(maxSheep, maxWolves)))) 45 | lines(timeStep, wolfSheepRun$numWolves, col = "red", lwd = 2) 46 | 47 | legend("topleft", legend = c("Sheep", "Wolves"), lwd = c(2, 2), 48 | col = c("blue", "red"), bg = "white") 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/WolfSheepPredation/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Bauduin Sarah 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/WolfSheepPredation/README.txt: -------------------------------------------------------------------------------- 1 | Wolf sheep predation 2 | Original model by Wilensky (1997) NetLogo Wolf Sheep Predation model 3 | http://ccl.northwestern.edu/netlogo/models/WolfSheepPredation 4 | -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/WolfSheepPredation/WolfSheepPredation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "WolfSheepPredation" 3 | author: "Sarah Bauduin" 4 | date: "15 avril 2016" 5 | output: html_document 6 | --- 7 | 8 | # Overview 9 | 10 | This module is a reimplementation in R using the SpaDES and NetLogoR packages of the "Wolf sheep predation" NetLogo model by [Wilensky (1997, NetLogo Wolf Sheep Predation model)](http://ccl.northwestern.edu/netlogo/models/WolfSheepPredation). 11 | Please refer to the NetLogo documentation for information on the model. 12 | 13 | # Usage 14 | 15 | ```{r, eval=FALSE} 16 | library(SpaDES.core) 17 | library(SpaDES.tools) 18 | library(NetLogoR) 19 | 20 | # Define the parameters 21 | wolfSheepParams <- list(.plotInitialTime = NA, .plotInterval = NA, 22 | .saveInitialTime = 0, .saveInterval = 1, 23 | grassOn = TRUE, grassTGrowth = 30, 24 | nSheep = 100, gainFoodSheep = 4, reproSheep = 4, 25 | nWolf = 50, gainFoodWolf = 20, reproWolf = 5) 26 | 27 | # Model init 28 | wolfSheepSim <- simInit( 29 | times = list(start = 0, end = 500), 30 | params = list(WolfSheepPredation = wolfSheepParams), 31 | modules = list("WolfSheepPredation"), 32 | paths = list(modulePath = "./examples/Wolf-Sheep-Predation") 33 | ) 34 | 35 | # Run the model 36 | wolfSheepRun <- spades(wolfSheepSim) 37 | ``` 38 | 39 | # Events 40 | 41 | The module events recreate the model procedures from the NetLogo model which are: 42 | 43 | * the sheep move, 44 | * if `grassOn = TRUE`, the sheep loose energy by moving and gain energy by eating grass if there is grass to eat at their location, 45 | * the sheep with low energy die, 46 | * some sheep reproduce, 47 | * the wolves move, 48 | * the wolves loose energy by moving, 49 | * the wolves gain energy by eating a sheep if there is a sheep to eat at their location, 50 | * the eaten sheep die, 51 | * the wolves with low energy die, 52 | * some wolves reproduce, 53 | * if `grassOn = TRUE`, grass grow where grass has been eaten by sheep after a certain time period. 54 | 55 | ## Plotting 56 | 57 | The sheep (red) and the wolves (black) positions are plotted on the world. The world is homogeneous if `grassOn = FALSE`, or it is heterogeneous if `grassOn = TRUE` with green (1) and white (0) patches. 58 | 59 | ## Saving 60 | 61 | The size of the wolf and sheep populations are recorded in the saving event, as well as the number of green patches in the world if `grassOn = TRUE`. 62 | 63 | # Data dependencies 64 | 65 | ## Input data 66 | 67 | Model parameters must be defined beforehand. Otherwise, no other input data are necessary for this module. 68 | 69 | ## Output data 70 | 71 | The size of the sheep and wolf populations saved during the simulation, as well as the number of green patches if `grassOn = TRUE`, are available at the end of the simulation. 72 | You can access to it with `wolfSheepRun$numSheep`, `wolfSheepRun$numWolves` and `wolfSheepRun$numGreen`. 73 | 74 | # Links to other modules 75 | 76 | No anticipated linkages to other modules. 77 | 78 | -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/WolfSheepPredation/citation.bib: -------------------------------------------------------------------------------- 1 | 2 | @Manual{, 3 | title = {WolfSheepPredation}, 4 | author = {{Bauduin Sarah}}, 5 | organization = {Pacific Forestry Centre, Natural Resources Canada}, 6 | address = {506 West Burnside Road, Victoria, BC V8Z 1M5, Canada}, 7 | year = {2016}, 8 | url = {}, 9 | } 10 | -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/WolfSheepPredation/data/CHECKSUMS.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/inst/examples/Wolf-Sheep-Predation/WolfSheepPredation/data/CHECKSUMS.txt -------------------------------------------------------------------------------- /inst/examples/Wolf-Sheep-Predation/WolfSheepPredation/tests/unitTests.R: -------------------------------------------------------------------------------- 1 | 2 | # Please build your own test file from test-Template.R, and place it in tests folder 3 | # please specify the package you need to run the sim function in the test files. 4 | 5 | # to test all the test files in the tests folder: 6 | test_dir("tests/testthat") 7 | 8 | # Alternative, you can use test_file to test individual test file, e.g.: 9 | test_file("tests/testthat/test-template.R") 10 | -------------------------------------------------------------------------------- /man/NLall.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentset-functions.R 3 | \name{NLall} 4 | \alias{NLall} 5 | \alias{all} 6 | \alias{NLall,matrix,worldMatrix,missing-method} 7 | \alias{NLall,matrix,worldArray,character-method} 8 | \alias{NLall,agentMatrix,missing,character-method} 9 | \title{All agents?} 10 | \usage{ 11 | NLall(agents, world, var, val) 12 | 13 | \S4method{NLall}{matrix,worldMatrix,missing}(agents, world, val) 14 | 15 | \S4method{NLall}{matrix,worldArray,character}(agents, world, var, val) 16 | 17 | \S4method{NLall}{agentMatrix,missing,character}(agents, var, val) 18 | } 19 | \arguments{ 20 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 21 | column \code{pycor} representing the \code{patches} coordinates, or 22 | 23 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 24 | }\if{html}{\out{
}}} 25 | 26 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 27 | 28 | \item{var}{Character. The name of the selected \code{agents} variable. 29 | If \code{agents} are \code{patches} and the \code{world} is a 30 | \code{worldMatrix} object, \code{var} must not be provided. If 31 | \code{agents} are \code{patches} and the \code{world} is a \code{worldArray} 32 | object, \code{var} is the name of the layer to use to define the \code{patches} 33 | values. If \code{agents} are \code{turtles}, \code{var} is one of 34 | the \code{turtles}' variable and can be equal to \code{xcor}, 35 | \code{ycor}, any of the variables created when \code{turtles} were created, 36 | as well as any variable created using \code{turtlesOwn()}.} 37 | 38 | \item{val}{Numeric or character. Vector of any length.} 39 | } 40 | \value{ 41 | Logical. \code{TRUE} if all the \code{agents} have their variable equal to 42 | \code{val}, \code{FALSE} otherwise. 43 | } 44 | \description{ 45 | Report \code{TRUE} if all \code{agents} have their variable equal to a given value, 46 | report \code{FALSE} otherwise. 47 | } 48 | \details{ 49 | \code{world} must not be provided if \code{agents} are turtles. 50 | } 51 | \examples{ 52 | # Patches 53 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = runif(25)) 54 | NLall(agents = patches(w1), world = w1, val = 5) 55 | w2 <- w1 56 | w2 <- NLset(world = w1, agents = patches(w1), val = 5) 57 | NLall(agents = patches(w2), world = w2, val = 5) 58 | 59 | # Turtles 60 | t1 <- createTurtles(n = 5, coords = cbind(xcor = 1, ycor = 1), heading = c(1, 2, 2, 1, 2)) 61 | NLall(agents = t1, var = "xcor", val = 1) 62 | NLall(agents = t1, var = "heading", val = 2) 63 | 64 | } 65 | \references{ 66 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 67 | Center for Connected Learning and Computer-Based Modeling, 68 | Northwestern University. Evanston, IL. 69 | } 70 | \seealso{ 71 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#all} 72 | } 73 | \author{ 74 | Sarah Bauduin 75 | } 76 | -------------------------------------------------------------------------------- /man/NLany.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentset-functions.R 3 | \name{NLany} 4 | \alias{NLany} 5 | \alias{any} 6 | \alias{NLany,matrix-method} 7 | \title{Any agents?} 8 | \usage{ 9 | NLany(agents) 10 | 11 | \S4method{NLany}{matrix}(agents) 12 | } 13 | \arguments{ 14 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 15 | column \code{pycor} representing the \code{patches} coordinates, or 16 | 17 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 18 | }\if{html}{\out{
}}} 19 | } 20 | \value{ 21 | Logical. \code{TRUE} if there is at least one patch or one turtle in the 22 | \code{agents}, \code{FALSE} otherwise. 23 | } 24 | \description{ 25 | Report \code{TRUE} if \code{agents} is non empty, report \code{FALSE} otherwise. 26 | } 27 | \examples{ 28 | # Patches 29 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 30 | p1 <- noPatches() 31 | p2 <- patch(w1, 0, 0) 32 | NLany(p1) 33 | NLany(p2) 34 | 35 | # Turtles 36 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 37 | t2 <- noTurtles() 38 | NLany(t1) 39 | NLany(t2) 40 | 41 | } 42 | \references{ 43 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 44 | Center for Connected Learning and Computer-Based Modeling, 45 | Northwestern University. Evanston, IL. 46 | } 47 | \seealso{ 48 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#any} 49 | } 50 | \author{ 51 | Sarah Bauduin 52 | } 53 | -------------------------------------------------------------------------------- /man/NLcount.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentset-functions.R 3 | \name{NLcount} 4 | \alias{NLcount} 5 | \alias{count} 6 | \alias{NLcount,matrix-method} 7 | \title{Count agents} 8 | \usage{ 9 | NLcount(agents) 10 | 11 | \S4method{NLcount}{matrix}(agents) 12 | } 13 | \arguments{ 14 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 15 | column \code{pycor} representing the \code{patches} coordinates, or 16 | 17 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 18 | }\if{html}{\out{
}}} 19 | } 20 | \value{ 21 | Integer. 22 | } 23 | \description{ 24 | Report the number of patches or turtles inside \code{agents}. 25 | } 26 | \examples{ 27 | # Patches 28 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 29 | p1 <- patches(w1) 30 | NLcount(p1) # 25 patches 31 | 32 | # Turtles 33 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 34 | NLcount(t1) # 10 turtles 35 | 36 | } 37 | \references{ 38 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 39 | Center for Connected Learning and Computer-Based Modeling, 40 | Northwestern University. Evanston, IL. 41 | } 42 | \seealso{ 43 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#count} 44 | } 45 | \author{ 46 | Sarah Bauduin 47 | } 48 | -------------------------------------------------------------------------------- /man/NLworldIndex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \name{NLworldIndex} 4 | \alias{NLworldIndex} 5 | \alias{NLworldIndex,worldMatrix,numeric-method} 6 | \title{\code{WorldMatrix} indices from vector indices} 7 | \usage{ 8 | NLworldIndex(world, cellNum) 9 | 10 | \S4method{NLworldIndex}{worldMatrix,numeric}(world, cellNum) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{cellNum}{Integer. Vector of cells number.} 16 | } 17 | \value{ 18 | Numeric. Vector of \code{worldMatrix} indices. 19 | } 20 | \description{ 21 | Convert vector indices or \verb{Raster*} cell numbers into \code{worldMatrix} indices. 22 | } 23 | \examples{ 24 | if (requireNamespace("raster", quietly = TRUE)) { 25 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = 1:100) 26 | w1Ras <- world2raster(w1) 27 | index <- 24 28 | pxpy <- PxcorPycorFromCell(world = w1, cellNum = index) 29 | 30 | rasValue <- as.integer(unname(w1Ras[index])) 31 | # Not correct index: 32 | identical(w1[index], rasValue) 33 | 34 | # Correct index 35 | identical(w1[NLworldIndex(w1, index)], rasValue) 36 | } 37 | 38 | } 39 | \author{ 40 | Eliot McIntire 41 | } 42 | -------------------------------------------------------------------------------- /man/NetLogoR-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/NetLogoR-package.R 3 | \docType{package} 4 | \name{NetLogoR-package} 5 | \alias{NetLogoR} 6 | \alias{NetLogoR-package} 7 | \title{The \code{NetLogoR} package} 8 | \description{ 9 | The suggested package \pkg{fastshp} can be installed with 10 | \code{install.packages("fastshp", repos = "https://rforge.net", type = "source")}. 11 | The examples included with the package, are located in the R package "examples" folder, 12 | which can be found at \code{system.file(package = "NetLogoR", "examples")}. 13 | } 14 | \details{ 15 | The 3 specific R examples can be opened here, but it's recommended to make copies of these 16 | for editing: 17 | 18 | \if{html}{\out{
}}\preformatted{exPath <- file.path(system.file(package = "NetLogoR", "examples") 19 | file.edit(exPath, "Ants", "Ants.R")) 20 | file.edit(exPath, "Butterfly", "Butterfly-1.R")) 21 | file.edit(exPath, "Wolf-Sheep-Predation", "Wolf-Sheep-Predation.R")) 22 | }\if{html}{\out{
}} 23 | } 24 | \seealso{ 25 | Useful links: 26 | \itemize{ 27 | \item \url{https://netlogor.predictiveecology.org} 28 | \item \url{https://github.com/PredictiveEcology/NetLogoR/} 29 | \item \url{https://groups.google.com/g/netlogor} 30 | \item Report bugs at \url{https://github.com/PredictiveEcology/NetLogoR/issues} 31 | } 32 | 33 | } 34 | \author{ 35 | \strong{Maintainer}: Eliot J B McIntire \email{eliot.mcintire@canada.ca} (\href{https://orcid.org/0000-0002-6914-8316}{ORCID}) 36 | 37 | Authors: 38 | \itemize{ 39 | \item Sarah Bauduin \email{sarahbauduin@hotmail.fr} (\href{https://orcid.org/0000-0002-3252-5894}{ORCID}) 40 | \item Alex M Chubaty \email{achubaty@for-cast.ca} (\href{https://orcid.org/0000-0001-7146-8135}{ORCID}) 41 | } 42 | 43 | Other contributors: 44 | \itemize{ 45 | \item His Majesty the King in Right of Canada, as represented by the Minister of Natural Resources Canada [copyright holder] 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /man/PxcorPycorFromCell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \name{PxcorPycorFromCell} 4 | \alias{PxcorPycorFromCell} 5 | \alias{PxcorPycorFromCell,worldNLR,numeric-method} 6 | \title{\code{Patches} coordinates from cells numbers} 7 | \usage{ 8 | PxcorPycorFromCell(world, cellNum) 9 | 10 | \S4method{PxcorPycorFromCell}{worldNLR,numeric}(world, cellNum) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{cellNum}{Integer. Vector of cells number.} 16 | } 17 | \value{ 18 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 19 | column \code{pycor} in the order of the given \code{cellNum}. 20 | } 21 | \description{ 22 | Report the \code{patches} coordinates \code{pxcor} and \code{pycor} given the cells 23 | numbers as defined for a \verb{Raster*} object. 24 | } 25 | \examples{ 26 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 27 | cellNum <- cellFromPxcorPycor(world = w1, pxcor = 0, pycor = 9) 28 | PxcorPycorFromCell(world = w1, cellNum = cellNum) 29 | cellNum <- cellFromPxcorPycor(world = w1, pxcor = c(0, 1, 2), pycor = 0) 30 | PxcorPycorFromCell(world = w1, cellNum = cellNum) 31 | 32 | } 33 | \author{ 34 | Sarah Bauduin 35 | } 36 | -------------------------------------------------------------------------------- /man/agentMatrix-bind-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \name{cbind} 4 | \alias{cbind} 5 | \alias{cbind.agentMatrix} 6 | \alias{rbind} 7 | \alias{rbind.agentMatrix} 8 | \title{Combine R Objects by Rows or Columns} 9 | \usage{ 10 | \method{cbind}{agentMatrix}(..., deparse.level) 11 | 12 | \method{rbind}{agentMatrix}(..., deparse.level = 1) 13 | } 14 | \arguments{ 15 | \item{...}{Two \code{agentMatrix} objects.} 16 | 17 | \item{deparse.level}{See \code{\link[base:cbind]{base::cbind()}}.} 18 | } 19 | \value{ 20 | An \code{agentMatrix} object. 21 | } 22 | \description{ 23 | Take a sequence of \code{agentMatrix} arguments and combine by columns or rows, respectively. 24 | This will take the coordinates of the first argument and remove the coordinates 25 | of the second object. 26 | } 27 | -------------------------------------------------------------------------------- /man/agentMatrix-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Agent-classes.R 3 | \docType{class} 4 | \name{agentMatrix-class} 5 | \alias{agentMatrix-class} 6 | \title{The \code{agentMatrix} class} 7 | \description{ 8 | The \code{agentMatrix} class 9 | } 10 | \examples{ 11 | newAgent <- new("agentMatrix", 12 | coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 13 | char = letters[c(1, 2, 6)], 14 | nums2 = c(4.5, 2.6, 2343), 15 | char2 = LETTERS[c(4, 24, 3)], 16 | nums = 5:7 17 | ) 18 | 19 | # compare speeds -- about 5x faster 20 | if (requireNamespace("microbenchmark", quietly = TRUE) && 21 | requireNamespace("sp", quietly = TRUE)) { 22 | microbenchmark::microbenchmark( 23 | times = 499, 24 | spdf = { 25 | sp::SpatialPointsDataFrame( 26 | coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 27 | data = data.frame( 28 | char = letters[c(1, 2, 6)], 29 | nums2 = c(4.5, 2.6, 2343), 30 | char2 = LETTERS[c(4, 24, 3)], 31 | nums = 5:7 32 | ) 33 | ) 34 | }, 35 | agentMat = { 36 | agentMatrix( 37 | coords = cbind( 38 | pxcor = c(1, 2, 5), 39 | pycor = c(3, 4, 6) 40 | ), 41 | char = letters[c(1, 2, 6)], 42 | nums2 = c(4.5, 2.6, 2343), 43 | char2 = LETTERS[c(4, 24, 3)], 44 | nums = 5:7 45 | ) 46 | }, 47 | agentMatDirect = { 48 | new("agentMatrix", 49 | coords = cbind( 50 | pxcor = c(1, 2, 5), 51 | pycor = c(3, 4, 6) 52 | ), 53 | char = letters[c(1, 2, 6)], 54 | nums2 = c(4.5, 2.6, 2343), 55 | char2 = LETTERS[c(4, 24, 3)], 56 | nums = 5:7 57 | ) 58 | } 59 | ) 60 | } 61 | } 62 | \author{ 63 | Eliot McIntire 64 | } 65 | -------------------------------------------------------------------------------- /man/agentMatrix-compare-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \name{==,agentMatrix,character-method} 4 | \alias{==,agentMatrix,character-method} 5 | \alias{==,agentMatrix,numeric-method} 6 | \title{Relational Operators} 7 | \usage{ 8 | \S4method{==}{agentMatrix,character}(e1, e2) 9 | 10 | \S4method{==}{agentMatrix,numeric}(e1, e2) 11 | } 12 | \arguments{ 13 | \item{e1}{An \code{agentMatrix} object.} 14 | 15 | \item{e2}{atomic vector, symbol, call, or other object for which methods have been written.} 16 | } 17 | \value{ 18 | A logical vector indicating the result of the element by element comparison. 19 | } 20 | \description{ 21 | Binary operators which allow the comparison of values in an \code{agentMatrix}. 22 | } 23 | -------------------------------------------------------------------------------- /man/agentMatrix-show-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \name{show,agentMatrix-method} 4 | \alias{show,agentMatrix-method} 5 | \alias{length,agentMatrix-method} 6 | \alias{nrow,agentMatrix-method} 7 | \alias{head} 8 | \alias{head.agentMatrix} 9 | \alias{tail} 10 | \alias{tail.agentMatrix} 11 | \title{Key base R functions for \code{agentMatrix} class} 12 | \usage{ 13 | \S4method{show}{agentMatrix}(object) 14 | 15 | \S4method{length}{agentMatrix}(x) 16 | 17 | \S4method{nrow}{agentMatrix}(x) 18 | 19 | \method{head}{agentMatrix}(x, n = 6L, ...) 20 | 21 | \method{tail}{agentMatrix}(x, n = 6L, ...) 22 | } 23 | \arguments{ 24 | \item{object}{An \code{agentMatrix} object.} 25 | 26 | \item{x}{An \code{agentMatrix} object} 27 | 28 | \item{n}{an integer vector of length up to dim(x) (or 1, for non-dimensioned objects).} 29 | 30 | \item{...}{arguments to be passed to or from other methods (currently, none used).} 31 | } 32 | \value{ 33 | \code{show} is called for its side effects. It shows all columns of data, 34 | except for the coordinates. To access those, use \code{coordinates()}. 35 | \code{length} returns a non-negative integer of length 1, 36 | except for vectors of more than 2^31 - 1 elements, when it returns a double. 37 | \code{nrow} returns an integer of length 1 or \code{NULL}. 38 | 39 | An \code{agentMatrix} object, like \code{x}, but generally smaller. 40 | } 41 | \description{ 42 | Slight modifications from the default versions. 43 | } 44 | -------------------------------------------------------------------------------- /man/agentMatrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \docType{methods} 4 | \name{agentMatrix} 5 | \alias{agentMatrix} 6 | \alias{agentMatrix,matrix-method} 7 | \alias{agentMatrix,missing-method} 8 | \title{Create a new \code{agentMatrix} object} 9 | \usage{ 10 | agentMatrix(..., coords) 11 | 12 | \S4method{agentMatrix}{matrix}(..., coords) 13 | 14 | \S4method{agentMatrix}{missing}(..., coords) 15 | } 16 | \arguments{ 17 | \item{...}{Vectors, a data.frame, or a matrix of extra columns to add to the coordinates, 18 | or a \code{SpatialPointsDataFrame}.} 19 | 20 | \item{coords}{A matrix with 2 columns representing \code{x} and \code{y} coordinates} 21 | } 22 | \value{ 23 | An \code{agentMatrix} object 24 | } 25 | \description{ 26 | This is a fast alternative to the \code{SpatialPointsDataFrame}. 27 | It is meant to replace that functionality, though there are not as many methods (yet). 28 | The object is primarily a numeric matrix. 29 | Any character column passed to \code{...} will be converted to a numeric, using \code{as.factor} 30 | internally, and stored as a numeric. 31 | Methods using this class will automatically convert character queries to the correct numeric 32 | alternative. 33 | } 34 | \examples{ 35 | newAgent <- agentMatrix( 36 | coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 37 | char = letters[c(1, 2, 6)], 38 | nums2 = c(4.5, 2.6, 2343), 39 | char2 = LETTERS[c(4, 24, 3)], 40 | nums = 5:7 41 | ) 42 | 43 | w1 <- createWorld( 44 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 45 | data = runif(25) 46 | ) 47 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 48 | 49 | } 50 | \seealso{ 51 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#clear-turtles} 52 | } 53 | \author{ 54 | Eliot McIntire 55 | } 56 | -------------------------------------------------------------------------------- /man/bbox.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \docType{methods} 4 | \name{bbox} 5 | \alias{bbox} 6 | \alias{bbox,agentMatrix-method} 7 | \alias{bbox,ANY-method} 8 | \alias{bbox<-} 9 | \alias{bbox<-,agentMatrix,matrix-method} 10 | \alias{bbox,worldNLR-method} 11 | \alias{bbox,SpatExtent-method} 12 | \title{Extract or set bounding box} 13 | \usage{ 14 | bbox(obj) 15 | 16 | \S4method{bbox}{agentMatrix}(obj) 17 | 18 | \S4method{bbox}{ANY}(obj) 19 | 20 | bbox(obj) <- value 21 | 22 | \S4method{bbox}{agentMatrix,matrix}(obj) <- value 23 | 24 | \S4method{bbox}{worldNLR}(obj) 25 | 26 | \S4method{bbox}{SpatExtent}(obj) 27 | } 28 | \arguments{ 29 | \item{obj}{object deriving from class "agentMatrix", 30 | or for \code{bbox} and \code{extent}, a "worldMatrix" or "worldArray"} 31 | 32 | \item{value}{2x2 matrix representing the bounding box. See \code{sp::bbox}.} 33 | } 34 | \value{ 35 | The replacement method returns the same object as supplied to 36 | obj, i.e., an \code{agentMatrix}, with the \code{bbox} attribute set to \code{value}. 37 | } 38 | \description{ 39 | These are methods for classes in NetLogoR, i.e., \code{agentMatrix}, \code{worldMatrix}, 40 | and \code{worldArray}. 41 | 42 | Replacement method sets the bbox attribute of an \code{agentMatrix}. 43 | } 44 | \examples{ 45 | newAgent <- agentMatrix( 46 | coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 47 | char = letters[c(1, 2, 6)], 48 | nums2 = c(4.5, 2.6, 2343), 49 | char2 = LETTERS[c(4, 24, 3)], 50 | nums = 5:7 51 | ) 52 | bbox(newAgent) 53 | extent(newAgent) 54 | coordinates(newAgent) 55 | } 56 | \seealso{ 57 | \code{\link[=extent]{extent()}}, \code{\link[=coordinates]{coordinates()}}, \code{sp::bbox} 58 | } 59 | -------------------------------------------------------------------------------- /man/canMove.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{canMove} 4 | \alias{canMove} 5 | \alias{canMove,worldNLR,agentMatrix,numeric-method} 6 | \title{Can the \code{turtles} move?} 7 | \usage{ 8 | canMove(world, turtles, dist) 9 | 10 | \S4method{canMove}{worldNLR,agentMatrix,numeric}(world, turtles, dist) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 16 | 17 | \item{dist}{Numeric. Vector of distances to move. Must 18 | be of length 1 or of length \code{turtles}.} 19 | } 20 | \value{ 21 | Logical. Vector of length \code{turtles}. 22 | } 23 | \description{ 24 | Report \code{TRUE} if a \code{turtle} can move the given distance without leaving 25 | the \code{world}'s extent, report \code{FALSE} otherwise. 26 | } 27 | \examples{ 28 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 29 | t1 <- createTurtles(n = 10, world = w1) 30 | canMove(world = w1, turtles = t1, dist = 1:10) 31 | 32 | } 33 | \references{ 34 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 35 | Center for Connected Learning and Computer-Based Modeling, 36 | Northwestern University. Evanston, IL. 37 | } 38 | \seealso{ 39 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#can-move} 40 | } 41 | \author{ 42 | Sarah Bauduin 43 | } 44 | -------------------------------------------------------------------------------- /man/cellFromPxcorPycor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \name{cellFromPxcorPycor} 4 | \alias{cellFromPxcorPycor} 5 | \alias{cellFromPxcorPycor,worldNLR,numeric,numeric-method} 6 | \title{Cells numbers from \code{patches} coordinates} 7 | \usage{ 8 | cellFromPxcorPycor(world, pxcor, pycor) 9 | 10 | \S4method{cellFromPxcorPycor}{worldNLR,numeric,numeric}(world, pxcor, pycor) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{pxcor}{Integer. Vector of patches \code{pxcor} coordinates. Must be of length 1 16 | or of the same length as \code{pycor}.} 17 | 18 | \item{pycor}{Integer. Vector of patches \code{pycor} coordinates. Must be of length 1 19 | or of the same length as \code{pxcor}.} 20 | } 21 | \value{ 22 | Numeric. Vector of cells number. 23 | } 24 | \description{ 25 | Report the cells numbers as defined for a \verb{Raster*} object given the \code{patches} 26 | coordinates \code{pxcor} and \code{pycor}. 27 | } 28 | \examples{ 29 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 30 | cellFromPxcorPycor(world = w1, pxcor = 0, pycor = 9) 31 | cellFromPxcorPycor(world = w1, pxcor = c(0, 1, 2), pycor = 0) 32 | 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/clearPatches.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{clearPatches} 4 | \alias{clearPatches} 5 | \alias{clearPatches,worldMatrix-method} 6 | \alias{clearPatches,worldArray-method} 7 | \title{Clear \code{world}'s \code{patches}} 8 | \usage{ 9 | clearPatches(world) 10 | 11 | \S4method{clearPatches}{worldMatrix}(world) 12 | 13 | \S4method{clearPatches}{worldArray}(world) 14 | } 15 | \arguments{ 16 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 17 | } 18 | \value{ 19 | \code{WorldMatrix} object with \code{NA} values for all \code{patches}. 20 | } 21 | \description{ 22 | Reset all \code{patches} values to \code{NA}. 23 | } 24 | \examples{ 25 | w1 <- createWorld() 26 | w1 <- NLset(world = w1, agents = patches(w1), val = runif(NLcount(patches(w1)))) 27 | w1Val <- of(world = w1, agents = patches(w1)) 28 | summary(w1Val) 29 | 30 | w1 <- clearPatches(w1) 31 | w1Val <- of(world = w1, agents = patches(w1)) 32 | summary(w1Val) 33 | 34 | } 35 | \references{ 36 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 37 | Center for Connected Learning and Computer-Based Modeling, 38 | Northwestern University. Evanston, IL. 39 | } 40 | \seealso{ 41 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#clear-patches} 42 | } 43 | \author{ 44 | Sarah Bauduin 45 | } 46 | -------------------------------------------------------------------------------- /man/coordinates.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \name{coordinates,agentMatrix-method} 4 | \alias{coordinates,agentMatrix-method} 5 | \title{Spatial accessors and setters for NetLogoR classes} 6 | \usage{ 7 | \S4method{coordinates}{agentMatrix}(obj, ...) 8 | } 9 | \arguments{ 10 | \item{obj}{object deriving from class "agentMatrix"} 11 | 12 | \item{...}{additional arguments that may be used by particular methods} 13 | } 14 | \value{ 15 | \code{coordinates} returns a matrix of coordinates of the \code{obj}. 16 | } 17 | \description{ 18 | Spatial accessors and setters for NetLogoR classes 19 | } 20 | \seealso{ 21 | \code{\link[=bbox]{bbox()}}, \code{\link[=extent]{extent()}} 22 | } 23 | -------------------------------------------------------------------------------- /man/createOTurtles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{createOTurtles} 4 | \alias{createOTurtles} 5 | \alias{createOTurtles,numeric-method} 6 | \title{Create ordered \code{turtles}} 7 | \usage{ 8 | createOTurtles(n, world, breed, color) 9 | 10 | \S4method{createOTurtles}{numeric}(n, world, breed, color) 11 | } 12 | \arguments{ 13 | \item{n}{Integer.} 14 | 15 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 16 | 17 | \item{breed}{Character. Vector of \code{breed} names. Must be of length 1 or of length 18 | \code{n}. If missing, \code{breed = "turtle"} for all \code{turtles}.} 19 | 20 | \item{color}{Character. Vector of \code{color} names. Must be of length \code{n}. 21 | If missing, \code{colors} are assigned using the function \code{rainbow(n)}.} 22 | } 23 | \value{ 24 | \code{AgentMatrix} object of length \code{n} with data for the 25 | turtles being: \code{xcor}, \code{ycor}, \code{who}, \code{heading}, \code{prevX}, \code{prevY}, \code{breed}, 26 | and \code{color}. 27 | } 28 | \description{ 29 | Create \code{n} \code{turtles} at the center of the \code{world} with their \code{headings} evenly 30 | distributed. 31 | } 32 | \details{ 33 | The identity of the \code{turtles} is defined by their \code{who} number. This 34 | numbering starts at 0 and increments by 1. 35 | 36 | \if{html}{\out{
}}\preformatted{ The coordinates from the previous time step are stored in `prevX` and 37 | `prevY`. The initial values are `NA`. 38 | }\if{html}{\out{
}} 39 | } 40 | \examples{ 41 | w1 <- createWorld( 42 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 43 | data = runif(25) 44 | ) 45 | t1 <- createOTurtles(n = 10, world = w1) 46 | plot(w1) 47 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 48 | 49 | t1 <- fd(turtles = t1, dist = 1) 50 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 51 | 52 | } 53 | \references{ 54 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 55 | Center for Connected Learning and Computer-Based Modeling, 56 | Northwestern University. Evanston, IL. 57 | } 58 | \seealso{ 59 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#create-ordered-turtles} 60 | } 61 | \author{ 62 | Sarah Bauduin and Eliot McIntire 63 | } 64 | -------------------------------------------------------------------------------- /man/createTurtles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{createTurtles} 4 | \alias{createTurtles} 5 | \alias{createTurtles,numeric,matrix,missing-method} 6 | \alias{createTurtles,numeric,missing,ANY-method} 7 | \title{Create \code{turtles}} 8 | \usage{ 9 | createTurtles(n, coords, world, heading, breed, color) 10 | 11 | \S4method{createTurtles}{numeric,matrix,missing}(n, coords, world, heading, breed, color) 12 | 13 | \S4method{createTurtles}{numeric,missing,ANY}(n, coords, world, heading, breed, color) 14 | } 15 | \arguments{ 16 | \item{n}{Integer.} 17 | 18 | \item{coords}{Matrix (\code{ncol} = 2) with the first column \code{xcor} and the second 19 | column \code{ycor} representing the \code{turtles} initial locations. 20 | \code{nrow(coords)} must be equal to 1 or to \code{n}. 21 | Given coordinates must be inside the \code{world}'s extent. If missing, 22 | \code{turtles} are put in the center of the \code{world}.} 23 | 24 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 25 | 26 | \item{heading}{Numeric. Vector of values between 0 and 360. Must be of length 1 or 27 | of length \code{n}. If missing, a random \code{heading} is assigned to 28 | each \code{turtle}.} 29 | 30 | \item{breed}{Character. Vector of \code{breed} names. Must be of length 1 or of length 31 | \code{n}. If missing, \code{breed = "turtle"} for all \code{turtles}.} 32 | 33 | \item{color}{Character. Vector of \code{color} names. Must be of length \code{n}. 34 | If missing, \code{colors} are assigned using the function \code{rainbow(n)}.} 35 | } 36 | \value{ 37 | \code{AgentMatrix} object of length \code{n} with data for the 38 | \code{turtles} being: \code{xcor}, \code{ycor}, \code{who}, \code{heading}, \code{prevX}, \code{prevY}, 39 | \code{breed}, and \code{color}. 40 | } 41 | \description{ 42 | Create \code{n} moving \code{agents} with a set of defined variables. 43 | } 44 | \details{ 45 | If \code{coords} is provided, \code{world} must not be provided. 46 | 47 | \if{html}{\out{
}}\preformatted{ The identity of the `turtles` is defined by their `who` number. This 48 | numbering starts at 0 and increments by 1. 49 | 50 | The coordinates from the previous time step are stored in `prevX` and 51 | `prevY`. The initial values are `NA`. 52 | }\if{html}{\out{
}} 53 | } 54 | \examples{ 55 | w1 <- createWorld( 56 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 57 | data = runif(25) 58 | ) 59 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 60 | plot(w1) 61 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 62 | 63 | } 64 | \references{ 65 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 66 | Center for Connected Learning and Computer-Based Modeling, 67 | Northwestern University. Evanston, IL. 68 | } 69 | \seealso{ 70 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#create-turtles} 71 | } 72 | \author{ 73 | Sarah Bauduin 74 | } 75 | -------------------------------------------------------------------------------- /man/createWorld.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \name{createWorld} 4 | \alias{createWorld} 5 | \alias{createWorld,numeric,numeric,numeric,numeric,ANY-method} 6 | \alias{createWorld,missing,missing,missing,missing,missing-method} 7 | \title{Create a \code{world}} 8 | \usage{ 9 | createWorld(minPxcor, maxPxcor, minPycor, maxPycor, data = NA) 10 | 11 | \S4method{createWorld}{numeric,numeric,numeric,numeric,ANY}(minPxcor, maxPxcor, minPycor, maxPycor, data = NA) 12 | 13 | \S4method{createWorld}{missing,missing,missing,missing,missing}() 14 | } 15 | \arguments{ 16 | \item{minPxcor}{Integer. Minimum \code{pxcor} for the \code{patches} (\code{world}'s left border).} 17 | 18 | \item{maxPxcor}{Integer. Maximum \code{pxcor} for the \code{patches} (\code{world}'s right border).} 19 | 20 | \item{minPycor}{Integer. Minimum \code{pycor} for the \code{patches} (\code{world}'s bottom border).} 21 | 22 | \item{maxPycor}{Integer. Maximum \code{pycor} for the \code{patches} (\code{world}'s top border).} 23 | 24 | \item{data}{Vector of length 1 or length 25 | \code{(maxPxcor - minPxcor + 1) * (maxPycor - minPycor + 1)}. 26 | Default is \code{NA}.} 27 | } 28 | \value{ 29 | \code{WorldMatrix} object composed of 30 | \code{(maxPxcor - minPxcor + 1) * (maxPycor - minPycor + 1)} 31 | patches (i.e., matrix cells). 32 | } 33 | \description{ 34 | Create a \code{world} of \code{patches} of class \code{worldMatrix}. 35 | } 36 | \details{ 37 | If \code{data} is provided, values are assigned by rows. 38 | 39 | \if{html}{\out{
}}\preformatted{ If no parameters value are provided, default values are: 40 | `minPxcor = -16`, 41 | `maxPxcor = 16`, `minPycor = -16`, and `maxPycor = 16`. 42 | 43 | See `help("worldMatrix-class")` for more details on the `worldMatrix` class. 44 | }\if{html}{\out{
}} 45 | } 46 | \examples{ 47 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = 1:25) 48 | plot(w1) 49 | 50 | } 51 | \references{ 52 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 53 | Center for Connected Learning and Computer-Based Modeling, 54 | Northwestern University. Evanston, IL. 55 | } 56 | \author{ 57 | Sarah Bauduin, Eliot McIntire, and Alex Chubaty 58 | } 59 | -------------------------------------------------------------------------------- /man/die.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{die} 4 | \alias{die} 5 | \alias{die,agentMatrix,numeric-method} 6 | \title{Kill \code{turtles}} 7 | \usage{ 8 | die(turtles, who) 9 | 10 | \S4method{die}{agentMatrix,numeric}(turtles, who) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{who}{Integer. Vector of the \code{who} numbers for the selected \code{turtles}.} 16 | } 17 | \value{ 18 | \code{AgentMatrix} representing the \code{turtles} with the selected 19 | ones removed. 20 | } 21 | \description{ 22 | Kill selected \code{turtles}. 23 | } 24 | \details{ 25 | The \code{who} numbers of the remaining \code{turtles} are unchanged. 26 | } 27 | \examples{ 28 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 29 | t1 <- createTurtles(n = 10, world = w1) 30 | NLcount(t1) 31 | t1 <- die(turtles = t1, who = c(2, 3, 4)) 32 | NLcount(t1) 33 | 34 | } 35 | \references{ 36 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 37 | Center for Connected Learning and Computer-Based Modeling, 38 | Northwestern University. Evanston, IL. 39 | } 40 | \seealso{ 41 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#die} 42 | } 43 | \author{ 44 | Sarah Bauduin 45 | } 46 | -------------------------------------------------------------------------------- /man/diffuse.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{diffuse} 4 | \alias{diffuse} 5 | \alias{diffuse,worldMatrix,missing,numeric,numeric-method} 6 | \alias{diffuse,worldArray,character,numeric,numeric-method} 7 | \title{Diffuse values in a \code{world}} 8 | \usage{ 9 | diffuse(world, pVar, share, nNeighbors, torus = FALSE) 10 | 11 | \S4method{diffuse}{worldMatrix,missing,numeric,numeric}(world, share, nNeighbors, torus) 12 | 13 | \S4method{diffuse}{worldArray,character,numeric,numeric}(world, pVar, share, nNeighbors, torus = FALSE) 14 | } 15 | \arguments{ 16 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 17 | 18 | \item{pVar}{Character. If the \code{world} is a \code{worldArray} object, \code{pVar} 19 | is the name of the layer to use to define the \code{patches} values. 20 | \code{pVar} must not be provided if the \code{world} is a \code{worldMatrix} object.} 21 | 22 | \item{share}{Numeric. Value between 0 and 1 representing the portion of 23 | the \code{patches} values to be diffused among the neighbors.} 24 | 25 | \item{nNeighbors}{Integer: 4 or 8. Represents the number of neighbor \code{patches} 26 | considered.} 27 | 28 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 29 | \code{torus = FALSE}.} 30 | } 31 | \value{ 32 | \code{WorldMatrix} or \code{worldArray} object with \code{patches} values updated. 33 | } 34 | \description{ 35 | Each \code{patch} gives an equal share of a portion of its value to its neighbor \code{patches}. 36 | } 37 | \details{ 38 | What is given is lost for the patches. 39 | 40 | \if{html}{\out{
}}\preformatted{ If `torus = TRUE`, all `patches` have `nNeighbors` `patches` around 41 | them, which 42 | some may be on the other sides of the `world`. If `torus = FALSE`, 43 | `patches` located on the edges of the `world` have less than 44 | `nNeighbors` `patches` around them. 45 | However, each neighbor still gets 1/4 or 1/8 of the shared amount 46 | and the diffusing 47 | patch keeps the leftover. 48 | }\if{html}{\out{
}} 49 | } 50 | \examples{ 51 | w1 <- createWorld( 52 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 53 | data = sample(1:3, size = 25, replace = TRUE) 54 | ) 55 | plot(w1) 56 | # Diffuse 50\% of each patch value to its 8 neighbors 57 | if (requireNamespace("SpaDES.tools", quietly = TRUE)) { 58 | w2 <- diffuse(world = w1, share = 0.5, nNeighbors = 8) 59 | plot(w2) 60 | } 61 | 62 | } 63 | \references{ 64 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 65 | Center for Connected Learning and Computer-Based Modeling, 66 | Northwestern University. Evanston, IL. 67 | } 68 | \seealso{ 69 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#diffuse} 70 | 71 | \if{html}{\out{
}}\preformatted{ 72 | }\if{html}{\out{
}} 73 | } 74 | \author{ 75 | Sarah Bauduin 76 | } 77 | -------------------------------------------------------------------------------- /man/dot-bboxCoords.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \name{.bboxCoords} 4 | \alias{.bboxCoords} 5 | \title{\code{.bboxCoords} is a drop in replacement for \code{raster::.bboxCoords}.} 6 | \usage{ 7 | .bboxCoords(coords) 8 | } 9 | \arguments{ 10 | \item{coords}{xy coordinates for all cells, e.g., produced by \code{raster::coordinates}.} 11 | } 12 | \description{ 13 | \code{.bboxCoords} is a drop in replacement for \code{raster::.bboxCoords}. 14 | } 15 | -------------------------------------------------------------------------------- /man/dx.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{dx} 4 | \alias{dx} 5 | \alias{dx,agentMatrix,numeric-method} 6 | \alias{dx,agentMatrix,missing-method} 7 | \title{x-increment} 8 | \usage{ 9 | dx(turtles, dist = 1) 10 | 11 | \S4method{dx}{agentMatrix,numeric}(turtles, dist = 1) 12 | 13 | \S4method{dx}{agentMatrix,missing}(turtles) 14 | } 15 | \arguments{ 16 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 17 | 18 | \item{dist}{Numeric. Vector of distances the \code{turtles} would have to 19 | move forward to 20 | compute the increment values. Must be of length 1 or of length 21 | \code{turtles}. The default value is \code{dist = 1}.} 22 | } 23 | \value{ 24 | Numeric. Vector of length \code{turtles}. 25 | } 26 | \description{ 27 | Report the amount by which the \code{turtles}' coordinates \code{xcor} would change 28 | if the \code{turtles} were 29 | to move forward the given distances with their current \code{headings}. 30 | } 31 | \details{ 32 | Report the sine of the \code{turtles}' \code{heading} multiplied by the \code{dist} 33 | values. Heading 0 is north and angles are calculated in degrees in a 34 | clockwise manner. 35 | } 36 | \examples{ 37 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 38 | t1 <- createOTurtles(world = w1, n = 10) 39 | dx(turtles = t1) 40 | 41 | } 42 | \references{ 43 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 44 | Center for Connected Learning and Computer-Based Modeling, 45 | Northwestern University. Evanston, IL. 46 | } 47 | \seealso{ 48 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#dxy} 49 | } 50 | \author{ 51 | Sarah Bauduin 52 | } 53 | -------------------------------------------------------------------------------- /man/dy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{dy} 4 | \alias{dy} 5 | \alias{dy,agentMatrix,numeric-method} 6 | \alias{dy,agentMatrix,missing-method} 7 | \title{y-increment} 8 | \usage{ 9 | dy(turtles, dist = 1) 10 | 11 | \S4method{dy}{agentMatrix,numeric}(turtles, dist = 1) 12 | 13 | \S4method{dy}{agentMatrix,missing}(turtles) 14 | } 15 | \arguments{ 16 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 17 | 18 | \item{dist}{Numeric. Vector of distances the \code{turtles} would have to 19 | move forward to 20 | compute the increment values. Must be of length 1 or of length 21 | \code{turtles}. The default value is \code{dist = 1}.} 22 | } 23 | \value{ 24 | Numeric. Vector of length \code{turtles}. 25 | } 26 | \description{ 27 | Report the amount by which the \code{turtles}' coordinates \code{ycor} would change 28 | if the \code{turtles} were 29 | to move forward the given distances with their current \code{headings}. 30 | } 31 | \details{ 32 | Report the cosine of the \code{turtles}' \code{heading} multiplied by the \code{dist} 33 | values. Heading 0 is north and angles are calculated in degrees in a 34 | clockwise manner. 35 | } 36 | \examples{ 37 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 38 | t1 <- createOTurtles(world = w1, n = 10) 39 | dy(turtles = t1) 40 | 41 | } 42 | \references{ 43 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 44 | Center for Connected Learning and Computer-Based Modeling, 45 | Northwestern University. Evanston, IL. 46 | } 47 | \seealso{ 48 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#dxy} 49 | } 50 | \author{ 51 | Sarah Bauduin 52 | } 53 | -------------------------------------------------------------------------------- /man/extent.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \docType{methods} 4 | \name{extent,worldNLR-method} 5 | \alias{extent,worldNLR-method} 6 | \alias{extent,agentMatrix-method} 7 | \title{Bounding box and extent methods for NetLogoR classes} 8 | \usage{ 9 | \S4method{extent}{worldNLR}(x, ...) 10 | 11 | \S4method{extent}{agentMatrix}(x, ...) 12 | } 13 | \arguments{ 14 | \item{x}{object deriving from class "agentMatrix", 15 | or a "worldMatrix" or "worldArray"} 16 | 17 | \item{...}{Ignored.} 18 | } 19 | \value{ 20 | \code{bbox} returns a two-column matrix; the first column has the minimum, 21 | the second the maximum values; rows represent the spatial dimensions. 22 | \code{extent} returns an \code{SpatExtent} object from the package \code{terra}. 23 | } 24 | \description{ 25 | Same as \code{sp::bbox} and \code{raster::extent}. 26 | } 27 | \seealso{ 28 | \code{\link[=bbox]{bbox()}}, \code{\link[=coordinates]{coordinates()}} 29 | } 30 | -------------------------------------------------------------------------------- /man/face.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{face} 4 | \alias{face} 5 | \alias{face,agentMatrix,matrix-method} 6 | \title{Face something} 7 | \usage{ 8 | face(turtles, agents2, world, torus = FALSE) 9 | 10 | \S4method{face}{agentMatrix,matrix}(turtles, agents2, world, torus = FALSE) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{agents2}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 16 | column \code{pycor} representing the \code{patches} coordinates, or 17 | 18 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`, or 19 | 20 | Matrix (`ncol` = 2) with the first column `x` and the second column 21 | `y` representing locations coordinates. 22 | }\if{html}{\out{
}}} 23 | 24 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 25 | 26 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 27 | \code{torus = FALSE}.} 28 | } 29 | \value{ 30 | \code{AgentMatrix} representing the \code{turtles} with updated \code{headings}. 31 | } 32 | \description{ 33 | Set the \code{turtles}' \code{heading} towards \code{agents2}. 34 | } 35 | \details{ 36 | The number of agents/locations in \code{agents2} must be equal to 1 or 37 | to the length of \code{turtles}. 38 | 39 | \if{html}{\out{
}}\preformatted{ If `torus = FALSE`, `world` does not need to be provided. 40 | 41 | If `torus = TRUE` and the distance from one `turtles` to 42 | its corresponding agent/location `agents2` is smaller around the 43 | sides of the `world` than across it, then the direction to the agent/location 44 | `agents2` going around the sides of the `world` is given to the `turtle`. 45 | 46 | If a turtle is facing its own location, its heading does not change. 47 | }\if{html}{\out{
}} 48 | } 49 | \examples{ 50 | w1 <- createWorld( 51 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 52 | data = runif(25) 53 | ) 54 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 55 | plot(w1) 56 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 57 | 58 | t1 <- face(turtles = t1, agents2 = cbind(x = 0, y = 0)) 59 | t1 <- fd(turtles = t1, dist = 0.5) 60 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 61 | 62 | } 63 | \references{ 64 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 65 | Center for Connected Learning and Computer-Based Modeling, 66 | Northwestern University. Evanston, IL. 67 | } 68 | \seealso{ 69 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#face} 70 | 71 | \if{html}{\out{
}}\preformatted{ 72 | }\if{html}{\out{
}} 73 | } 74 | \author{ 75 | Sarah Bauduin 76 | } 77 | -------------------------------------------------------------------------------- /man/fd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{fd} 4 | \alias{fd} 5 | \alias{fd,agentMatrix,numeric-method} 6 | \title{Move forward} 7 | \usage{ 8 | fd(turtles, dist, world, torus = FALSE, out = TRUE) 9 | 10 | \S4method{fd}{agentMatrix,numeric}(turtles, dist, world, torus = FALSE, out = TRUE) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{dist}{Numeric. Vector of distances to move. Must 16 | be of length 1 or of length \code{turtles}.} 17 | 18 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 19 | 20 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 21 | \code{torus = FALSE}.} 22 | 23 | \item{out}{Logical. Determine if a \code{turtle} should move when 24 | \code{torus = FALSE} and its ending position will be outside of 25 | the \code{world}'s extent. Default is \code{out = TRUE}.} 26 | } 27 | \value{ 28 | \code{AgentMatrix} representing the \code{turtles} with updated 29 | coordinates and updated data for their previous coordinates \code{prevX} 30 | and \code{prevY}. 31 | } 32 | \description{ 33 | Move the \code{turtles} forward with their \code{headings} as directions. 34 | } 35 | \details{ 36 | If \code{torus = FALSE} and \code{out = TRUE}, \code{world} 37 | does not need to be provided. 38 | 39 | \if{html}{\out{
}}\preformatted{ If a distance to move leads a `turtle` outside of the `world`'s extent 40 | and `torus = TRUE`, the `turtle` is 41 | relocated on the other side of the `world`, inside its extent; if 42 | `torus = FALSE` and `out = TRUE`, the `turtle` moves past the 43 | `world`'s extent; if `torus = FALSE` and `out = FALSE`, the 44 | `turtle` does not move at all. In the event that a `turtle` does not move, 45 | its previous coordinates are still updated with its position before 46 | running `fd()` (i.e., its current position). 47 | 48 | If a given `dist` value is negative, then the `turtle` moves 49 | backward. 50 | }\if{html}{\out{
}} 51 | } 52 | \examples{ 53 | w1 <- createWorld( 54 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 55 | data = runif(25) 56 | ) 57 | t1 <- createOTurtles(n = 10, world = w1) 58 | plot(w1) 59 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 60 | 61 | t1 <- fd(turtles = t1, dist = 1) 62 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 63 | 64 | } 65 | \references{ 66 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 67 | Center for Connected Learning and Computer-Based Modeling, 68 | Northwestern University. Evanston, IL. 69 | } 70 | \seealso{ 71 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#forward} 72 | 73 | \if{html}{\out{
}}\preformatted{ 74 | }\if{html}{\out{
}} 75 | } 76 | \author{ 77 | Sarah Bauduin 78 | } 79 | -------------------------------------------------------------------------------- /man/hatch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{hatch} 4 | \alias{hatch} 5 | \alias{hatch,agentMatrix,numeric,numeric-method} 6 | \title{Hatch new \code{turtles}} 7 | \usage{ 8 | hatch(turtles, who, n, breed) 9 | 10 | \S4method{hatch}{agentMatrix,numeric,numeric}(turtles, who, n, breed) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{who}{Integer. Vector of the \code{who} numbers for the selected \code{turtles}.} 16 | 17 | \item{n}{Integer. Vector of length 1 or of length \code{who}. Number of new \code{turtles} 18 | to create for each parent.} 19 | 20 | \item{breed}{Character. One \code{breed} name. If missing, 21 | the created \code{turtles} are of the same \code{breed} as their parent \code{turtle}.} 22 | } 23 | \value{ 24 | \code{AgentMatrix} representing the \code{turtles} with the new 25 | hatched ones. 26 | } 27 | \description{ 28 | Create new \code{turtles} from parent \code{turtles}. 29 | } 30 | \details{ 31 | The parent \code{turtle} must be contained in the \code{turtles}. 32 | 33 | \if{html}{\out{
}}\preformatted{ The created `turtles` inherit of all the data from the parent `turtle`, 34 | except for the `breed` if specified otherwise, and for the `who` numbers. 35 | The `who`" numbers of the `turtles` created take on following the highest 36 | `who` number among the `turtles`. 37 | 38 | All new hatched `turtles` are placed at the end of the `agentMatrix` object. 39 | }\if{html}{\out{
}} 40 | } 41 | \examples{ 42 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 43 | t1 <- createTurtles(n = 10, world = w1) 44 | NLcount(t1) 45 | t1 <- hatch(turtles = t1, who = 0, n = 2) 46 | NLcount(t1) 47 | 48 | } 49 | \references{ 50 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 51 | Center for Connected Learning and Computer-Based Modeling, 52 | Northwestern University. Evanston, IL. 53 | } 54 | \seealso{ 55 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#hatch} 56 | } 57 | \author{ 58 | Sarah Bauduin 59 | } 60 | -------------------------------------------------------------------------------- /man/home.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{home} 4 | \alias{home} 5 | \alias{home,worldNLR,agentMatrix,character-method} 6 | \title{Return home} 7 | \usage{ 8 | home(world, turtles, home) 9 | 10 | \S4method{home}{worldNLR,agentMatrix,character}(world, turtles, home) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 16 | 17 | \item{home}{Character. Can take one of the following options to define where 18 | to relocate the \code{turtles}: 19 | 20 | \if{html}{\out{
}}\preformatted{ `home = "home0"` will place the `turtles` at the location 21 | `x = 0, y = 0`. 22 | 23 | `home = "center"` will place the `turtles` at the center of 24 | the `world`. 25 | 26 | `home = "pCorner"` will place the `turtles` at the center of 27 | the `patch` located in the left bottom corner of the `world`. 28 | 29 | `home = "corner"` will place the `turtles` at the left bottom 30 | corner of the `world`. 31 | }\if{html}{\out{
}}} 32 | } 33 | \value{ 34 | \code{AgentMatrix} representing the \code{turtles} with updated 35 | coordinates and updated data for their previous coordinates \code{prevX} 36 | and \code{prevY}. 37 | } 38 | \description{ 39 | Move the \code{turtles} back \code{home}. 40 | } 41 | \examples{ 42 | w1 <- createWorld( 43 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 44 | data = runif(25) 45 | ) 46 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 47 | plot(w1) 48 | points(t1, col = "black", pch = 16) 49 | 50 | t1 <- home(world = w1, turtles = t1, home = "pCorner") 51 | points(t1, col = "red", pch = 16) 52 | 53 | } 54 | \references{ 55 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 56 | Center for Connected Learning and Computer-Based Modeling, 57 | Northwestern University. Evanston, IL. 58 | } 59 | \seealso{ 60 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#home} 61 | } 62 | \author{ 63 | Sarah Bauduin 64 | } 65 | -------------------------------------------------------------------------------- /man/initialize-agentMatrix-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentMatrix-Class-methods.R 3 | \docType{methods} 4 | \name{initialize,agentMatrix-method} 5 | \alias{initialize,agentMatrix-method} 6 | \title{Initialize for \code{agentMatrix} Class} 7 | \usage{ 8 | \S4method{initialize}{agentMatrix}(.Object = "agentMatrix", coords, ..., levelsAM) 9 | } 10 | \arguments{ 11 | \item{.Object}{ An object: see the \dQuote{Initialize Methods} section.} 12 | 13 | \item{coords}{2 column matrix of coordinates} 14 | 15 | \item{...}{arguments to specify properties of the new object, to 16 | be passed to \code{initialize()}.} 17 | 18 | \item{levelsAM}{A list with named character vectors. Each name should 19 | match with elements in \code{...}, and each character vector 20 | should be the length of unique elements in the \code{...} element.} 21 | } 22 | \value{ 23 | An \code{agentMatrix} object. 24 | } 25 | \description{ 26 | To create a new \code{agentMatrix} object. 27 | } 28 | -------------------------------------------------------------------------------- /man/inspect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{inspect} 4 | \alias{inspect} 5 | \alias{inspect,agentMatrix,numeric-method} 6 | \title{Inspect \code{turtles}} 7 | \usage{ 8 | inspect(turtles, who) 9 | 10 | \S4method{inspect}{agentMatrix,numeric}(turtles, who) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{who}{Integer. Vector of the \code{who} numbers for the selected \code{turtles}.} 16 | } 17 | \value{ 18 | \code{Dataframe} (\code{nrow} = \code{length(who)}) of the variables of the selected 19 | individuals among the \code{turtles}. 20 | } 21 | \description{ 22 | Display all variables values for the selected individuals among the \code{turtles}. 23 | } 24 | \examples{ 25 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 26 | t1 <- createOTurtles(world = w1, n = 10) 27 | inspect(turtles = t1, who = c(2, 3)) 28 | 29 | } 30 | \references{ 31 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 32 | Center for Connected Learning and Computer-Based Modeling, 33 | Northwestern University. Evanston, IL. 34 | } 35 | \seealso{ 36 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#inspect} 37 | } 38 | \author{ 39 | Sarah Bauduin 40 | } 41 | -------------------------------------------------------------------------------- /man/isNLclass.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentset-functions.R 3 | \name{isNLclass} 4 | \alias{isNLclass} 5 | \alias{isNLclass,matrix,character-method} 6 | \title{Type of object} 7 | \usage{ 8 | isNLclass(agents, class) 9 | 10 | \S4method{isNLclass}{matrix,character}(agents, class) 11 | } 12 | \arguments{ 13 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 14 | column \code{pycor} representing the \code{patches} coordinates, or 15 | 16 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 17 | }\if{html}{\out{
}}} 18 | 19 | \item{class}{Character. Can take one of the following options to define 20 | the \code{class}: \code{"agent"}, \code{"agentset"}, 21 | \code{"patch"}, \code{"patchset"}. \code{"turtle"} or \code{"turtleset"}.} 22 | } 23 | \value{ 24 | Logical. \code{TRUE} if \code{agents} is of the \code{class} tested. 25 | } 26 | \description{ 27 | Report \code{TRUE} if the \code{agents} is of the \code{class} tested, 28 | report \code{FALSE} otherwise. 29 | } 30 | \details{ 31 | Careful! The \code{class} tested does not correspond to actual R classes. 32 | 33 | \if{html}{\out{
}}\preformatted{ `agents` is `"patch"` if it is a matrix (`ncol` = 2) with the 34 | first column `pxcor` and the second column `pycor` with only 35 | one row. `agents` is `"patcheset"` if the matrix has more than 36 | one row. 37 | 38 | `agents` is `"turtle"` if it is an `agentMatrix` 39 | containing only one `turtle`. 40 | `agents` is `"turtleset"` if the 41 | `agentMatrix` contains more than one `turtle`. 42 | 43 | `agents` is `"agent"` if it is either `"patch"` or 44 | `"turtle"`. `agents` is `"agentset"` if it is either 45 | `"patcheset"` or `"turtleset"`. 46 | }\if{html}{\out{
}} 47 | } 48 | \examples{ 49 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 50 | t1 <- createTurtles( 51 | n = 10, coords = randomXYcor(w1, n = 10), 52 | heading = sample(1:3, size = 10, replace = TRUE) 53 | ) 54 | isNLclass(agents = patches(w1), class = "patch") 55 | isNLclass(agents = patches(w1), class = "patcheset") 56 | isNLclass(agents = t1, class = "agentset") 57 | isNLclass(agents = t1, class = "turtleset") 58 | 59 | } 60 | \references{ 61 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 62 | Center for Connected Learning and Computer-Based Modeling, 63 | Northwestern University. Evanston, IL. 64 | } 65 | \seealso{ 66 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#is-of-type} 67 | } 68 | \author{ 69 | Sarah Bauduin 70 | } 71 | -------------------------------------------------------------------------------- /man/layoutCircle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{layoutCircle} 4 | \alias{layoutCircle} 5 | \alias{layoutCircle,worldNLR,agentMatrix,numeric-method} 6 | \title{Layout \code{turtles} on a circle} 7 | \usage{ 8 | layoutCircle(world, turtles, radius, torus = FALSE) 9 | 10 | \S4method{layoutCircle}{worldNLR,agentMatrix,numeric}(world, turtles, radius, torus = FALSE) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 16 | 17 | \item{radius}{Numeric. Radius of the circle.} 18 | 19 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 20 | \code{torus = FALSE}.} 21 | } 22 | \value{ 23 | \code{AgentMatrix} representing the \code{turtles} with updated 24 | coordinates and updated data for their \code{heading} values and 25 | previous coordinates \code{prevX} 26 | and \code{prevY}. 27 | } 28 | \description{ 29 | Relocate the \code{turtles} on a circle centered on the \code{world}. 30 | } 31 | \details{ 32 | The \code{turtles} point outwards. 33 | 34 | \if{html}{\out{
}}\preformatted{ If the 35 | `radius` value leads `turtles` outside of the `world`'s extent 36 | and `torus = TRUE`, they are 37 | relocated on the other sides of the `world`, inside its extent; if 38 | `torus = FALSE`, the `turtles` are located past 39 | the `world`'s extent. 40 | }\if{html}{\out{
}} 41 | } 42 | \examples{ 43 | w1 <- createWorld( 44 | minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, 45 | data = runif(100) 46 | ) 47 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 48 | plot(w1) 49 | points(t1, col = "black", pch = 16) 50 | 51 | t1 <- layoutCircle(world = w1, turtles = t1, radius = 3) 52 | points(t1, col = "red", pch = 16) 53 | 54 | } 55 | \references{ 56 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 57 | Center for Connected Learning and Computer-Based Modeling, 58 | Northwestern University. Evanston, IL. 59 | } 60 | \seealso{ 61 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#layout-circle} 62 | } 63 | \author{ 64 | Sarah Bauduin 65 | } 66 | -------------------------------------------------------------------------------- /man/left.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{left} 4 | \alias{left} 5 | \alias{left,agentMatrix,numeric-method} 6 | \title{Rotate to the left} 7 | \usage{ 8 | left(turtles, angle) 9 | 10 | \S4method{left}{agentMatrix,numeric}(turtles, angle) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{angle}{Numeric. Vector of angles in degrees by which to rotate the \code{turtles}' 16 | headings. Must be of length 1 or of length \code{turtles}.} 17 | } 18 | \value{ 19 | \code{AgentMatrix} representing the \code{turtles} with updated \code{heading} values. 20 | } 21 | \description{ 22 | Rotate the \code{turtles}'s headings to the left of \code{angle} degrees. 23 | } 24 | \details{ 25 | If a given \code{angle} value is negative, then the \code{turtle} rotates to the right. 26 | } 27 | \examples{ 28 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 29 | t1 <- createTurtles(n = 10, world = w1) 30 | of(agents = t1, var = "heading") 31 | t1 <- left(turtles = t1, angle = 180) 32 | of(agents = t1, var = "heading") 33 | 34 | } 35 | \references{ 36 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 37 | Center for Connected Learning and Computer-Based Modeling, 38 | Northwestern University. Evanston, IL. 39 | } 40 | \seealso{ 41 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#left} 42 | } 43 | \author{ 44 | Sarah Bauduin 45 | } 46 | -------------------------------------------------------------------------------- /man/maxPxcor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{maxPxcor} 4 | \alias{maxPxcor} 5 | \alias{maxPxcor,worldNLR-method} 6 | \title{Maximum \code{pxcor}} 7 | \usage{ 8 | maxPxcor(world) 9 | 10 | \S4method{maxPxcor}{worldNLR}(world) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | } 15 | \value{ 16 | Integer. 17 | } 18 | \description{ 19 | Report the patches maximum \code{pxcor} in the \code{world}. 20 | } 21 | \examples{ 22 | w1 <- createWorld() 23 | maxPxcor(w1) 24 | 25 | } 26 | \references{ 27 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 28 | Center for Connected Learning and Computer-Based Modeling, 29 | Northwestern University. Evanston, IL. 30 | } 31 | \seealso{ 32 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#max-pcor} 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/maxPycor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{maxPycor} 4 | \alias{maxPycor} 5 | \alias{maxPycor,worldNLR-method} 6 | \title{Maximum \code{pycor}} 7 | \usage{ 8 | maxPycor(world) 9 | 10 | \S4method{maxPycor}{worldNLR}(world) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | } 15 | \value{ 16 | Integer. 17 | } 18 | \description{ 19 | Report the patches maximum \code{pycor} in the \code{world}. 20 | } 21 | \examples{ 22 | w1 <- createWorld() 23 | maxPycor(w1) 24 | 25 | } 26 | \references{ 27 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 28 | Center for Connected Learning and Computer-Based Modeling, 29 | Northwestern University. Evanston, IL. 30 | } 31 | \seealso{ 32 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#max-pcor} 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/minPxcor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{minPxcor} 4 | \alias{minPxcor} 5 | \alias{minPxcor,worldNLR-method} 6 | \title{Minimum \code{pxcor}} 7 | \usage{ 8 | minPxcor(world) 9 | 10 | \S4method{minPxcor}{worldNLR}(world) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | } 15 | \value{ 16 | Integer. 17 | } 18 | \description{ 19 | Report the patches minimum \code{pxcor} in the \code{world}. 20 | } 21 | \examples{ 22 | w1 <- createWorld() 23 | minPxcor(w1) 24 | 25 | } 26 | \references{ 27 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 28 | Center for Connected Learning and Computer-Based Modeling, 29 | Northwestern University. Evanston, IL. 30 | } 31 | \seealso{ 32 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#min-pcor} 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/minPycor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{minPycor} 4 | \alias{minPycor} 5 | \alias{minPycor,worldNLR-method} 6 | \title{Minimum \code{pycor}} 7 | \usage{ 8 | minPycor(world) 9 | 10 | \S4method{minPycor}{worldNLR}(world) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | } 15 | \value{ 16 | Integer. 17 | } 18 | \description{ 19 | Report the patches minimum \code{pycor} in the \code{world}. 20 | } 21 | \examples{ 22 | w1 <- createWorld() 23 | minPycor(w1) 24 | 25 | } 26 | \references{ 27 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 28 | Center for Connected Learning and Computer-Based Modeling, 29 | Northwestern University. Evanston, IL. 30 | } 31 | \seealso{ 32 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#min-pcor} 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/moveTo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{moveTo} 4 | \alias{moveTo} 5 | \alias{moveTo,agentMatrix,matrix-method} 6 | \title{Move to} 7 | \usage{ 8 | moveTo(turtles, agents) 9 | 10 | \S4method{moveTo}{agentMatrix,matrix}(turtles, agents) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 16 | column \code{pycor} representing the \code{patches} coordinates, or 17 | 18 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 19 | }\if{html}{\out{
}}} 20 | } 21 | \value{ 22 | \code{AgentMatrix} representing the \code{turtles} with updated coordinates 23 | and updated data for their previous coordinates \code{prevX} and \code{prevY}. 24 | } 25 | \description{ 26 | Move the \code{turtles} to the \code{agents}' locations. 27 | } 28 | \details{ 29 | The number of \code{agents} must be equal to 1 or to 30 | length \code{turtles}. 31 | 32 | \if{html}{\out{
}}\preformatted{ The `turtle`'s `headings` are not affected with this function. 33 | 34 | If a `turtle` is moving to a `patch` location, it will be located at 35 | the `patch` center. 36 | }\if{html}{\out{
}} 37 | } 38 | \examples{ 39 | w1 <- createWorld( 40 | minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, 41 | data = runif(100) 42 | ) 43 | t1 <- createTurtles(n = 5, coords = randomXYcor(w1, n = 5)) 44 | plot(w1) 45 | points(t1, col = "black", pch = 16) 46 | 47 | t1 <- moveTo(turtles = t1, agents = turtle(t1, who = 0)) 48 | points(t1, col = "red", pch = 16) 49 | 50 | t1 <- moveTo(turtles = t1, agents = patch(w1, 9, 9)) 51 | points(t1, col = "blue", pch = 16) 52 | 53 | } 54 | \references{ 55 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 56 | Center for Connected Learning and Computer-Based Modeling, 57 | Northwestern University. Evanston, IL. 58 | } 59 | \seealso{ 60 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#move-to} 61 | } 62 | \author{ 63 | Sarah Bauduin 64 | } 65 | -------------------------------------------------------------------------------- /man/neighbors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{neighbors} 4 | \alias{neighbors} 5 | \alias{neighbors,worldNLR,matrix,numeric-method} 6 | \title{Neighbors \code{patches}} 7 | \usage{ 8 | neighbors(world, agents, nNeighbors, torus = FALSE) 9 | 10 | \S4method{neighbors}{worldNLR,matrix,numeric}(world, agents, nNeighbors, torus = FALSE) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 16 | column \code{pycor} representing the \code{patches} coordinates, or 17 | 18 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 19 | }\if{html}{\out{
}}} 20 | 21 | \item{nNeighbors}{Integer: 4 or 8. Represents the number of neighbor \code{patches} 22 | considered.} 23 | 24 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 25 | \code{torus = FALSE}.} 26 | } 27 | \value{ 28 | Matrix (\code{ncol} = 3) with the first column \code{pxcor} 29 | and the second column \code{pycor} representing the coordinates of the neighbors 30 | \code{patches} around the \code{agents} and the third column \code{id} representing 31 | the \code{id} of the \code{agents} in the order provided. 32 | } 33 | \description{ 34 | Report the coordinates of the neighbors \code{patches} around the \code{agents}. 35 | } 36 | \details{ 37 | The \code{patch} around which the neighbors are identified, or the \code{patch} where 38 | the \code{turtle} is located on around which the neighbors are identified, is not 39 | returned. 40 | 41 | \if{html}{\out{
}}\preformatted{ If `torus = FALSE`, `agents` located on the edges of the 42 | `world` have less than `nNeighbors` patches around them. 43 | If `torus = TRUE`, all `agents` located on the edges of the 44 | `world` have `nNeighbors` patches around them, 45 | which some may be on the other sides of the `world`. 46 | }\if{html}{\out{
}} 47 | } 48 | \examples{ 49 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 50 | if (requireNamespace("SpaDES.tools", quietly = TRUE)) { 51 | neighbors(world = w1, agents = patch(w1, c(0, 9), c(0, 7)), nNeighbors = 8) 52 | t1 <- createTurtles(n = 3, coords = randomXYcor(w1, n = 3)) 53 | neighbors(world = w1, agents = t1, nNeighbors = 4) 54 | } 55 | 56 | } 57 | \references{ 58 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 59 | Center for Connected Learning and Computer-Based Modeling, 60 | Northwestern University. Evanston, IL. 61 | } 62 | \seealso{ 63 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#neighbors} 64 | } 65 | \author{ 66 | Sarah Bauduin 67 | } 68 | -------------------------------------------------------------------------------- /man/noPatches.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{noPatches} 4 | \alias{noPatches} 5 | \title{No \code{patches}} 6 | \usage{ 7 | noPatches() 8 | } 9 | \value{ 10 | Matrix (\code{ncol} = 2, \code{nrow} = 0) with the first column \code{pxcor} and the 11 | second column \code{pycor}. 12 | } 13 | \description{ 14 | Report an empty \code{patch} \code{agentset}. 15 | } 16 | \examples{ 17 | p1 <- noPatches() 18 | NLcount(p1) 19 | 20 | } 21 | \references{ 22 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 23 | Center for Connected Learning and Computer-Based Modeling, 24 | Northwestern University. Evanston, IL. 25 | } 26 | \seealso{ 27 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#no-patches} 28 | } 29 | \author{ 30 | Sarah Bauduin 31 | } 32 | -------------------------------------------------------------------------------- /man/noTurtles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{noTurtles} 4 | \alias{noTurtles} 5 | \title{No \code{turtles}} 6 | \usage{ 7 | noTurtles() 8 | } 9 | \value{ 10 | \code{AgentMatrix} with the \code{turtle} variables defined as when using 11 | \code{createTurtles()} but with 0 \code{turtle}. 12 | } 13 | \description{ 14 | Report an empty \code{turtle} \code{agentset}. 15 | } 16 | \examples{ 17 | t1 <- noTurtles() 18 | NLcount(t1) 19 | 20 | } 21 | \references{ 22 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 23 | Center for Connected Learning and Computer-Based Modeling, 24 | Northwestern University. Evanston, IL. 25 | } 26 | \seealso{ 27 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#no-turtles} 28 | } 29 | \author{ 30 | Sarah Bauduin 31 | } 32 | -------------------------------------------------------------------------------- /man/of.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{of} 4 | \alias{of} 5 | \alias{of,missing,agentMatrix,character-method} 6 | \alias{of,worldMatrix,matrix,missing-method} 7 | \alias{of,worldArray,matrix,character-method} 8 | \title{Values of an \code{agents} variable} 9 | \usage{ 10 | of(world, agents, var) 11 | 12 | \S4method{of}{missing,agentMatrix,character}(agents, var) 13 | 14 | \S4method{of}{worldMatrix,matrix,missing}(world, agents) 15 | 16 | \S4method{of}{worldArray,matrix,character}(world, agents, var) 17 | } 18 | \arguments{ 19 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 20 | 21 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 22 | column \code{pycor} representing the \code{patches} coordinates, or 23 | 24 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 25 | }\if{html}{\out{
}}} 26 | 27 | \item{var}{Character. Vector of the names of the selected \code{agents} variables. 28 | If \code{agents} are \code{patches} and the \code{world} is a 29 | \code{worldMatrix} object, \code{var} must not be provided. If 30 | \code{agents} are \code{patches} and the \code{world} is a 31 | \code{worldArray} object, \code{var} is the name of the layers to 32 | use to define the \code{patches} 33 | values. If \code{agents} are \code{turtles}, \code{var} is some of 34 | the \code{turtles}' variable and can be any of the variables created 35 | when \code{turtles} were created, 36 | as well as any variable created with \code{turtlesOwn()}.} 37 | } 38 | \value{ 39 | Vector of values for the \code{agents} if one variable is 40 | requested. The class depends 41 | of the variable class. The order of the vector follows the order 42 | of the \code{agents}, or 43 | 44 | \if{html}{\out{
}}\preformatted{ Matrix or `Dataframe` (`ncol` = `length(var)`, `nrow` = `NLcount(agents)`) 45 | if more than one variable is requested. The row order 46 | follows the order of the `agents`. 47 | }\if{html}{\out{
}} 48 | } 49 | \description{ 50 | Report the \code{agents} values for the requested variable. 51 | } 52 | \details{ 53 | \code{world} must be provided only if \code{agents} are \code{patches}. 54 | } 55 | \examples{ 56 | # Patches 57 | w1 <- createWorld( 58 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 59 | data = 1:25 60 | ) 61 | of(world = w1, agents = patch(w1, c(0, 0), c(4, 0))) 62 | 63 | # Turtles 64 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 65 | of(agents = t1, var = "heading") 66 | 67 | } 68 | \references{ 69 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 70 | Center for Connected Learning and Computer-Based Modeling, 71 | Northwestern University. Evanston, IL. 72 | } 73 | \seealso{ 74 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#of} 75 | } 76 | \author{ 77 | Sarah Bauduin 78 | } 79 | -------------------------------------------------------------------------------- /man/oneOf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/agentset-functions.R 3 | \name{oneOf} 4 | \alias{oneOf} 5 | \alias{oneOf,matrix-method} 6 | \title{One random \code{agent}} 7 | \usage{ 8 | oneOf(agents) 9 | 10 | \S4method{oneOf}{matrix}(agents) 11 | } 12 | \arguments{ 13 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 14 | column \code{pycor} representing the \code{patches} coordinates, or 15 | 16 | \if{html}{\out{
}}\preformatted{ Matrix (`ncol` = 3) with the first column "`pxcor` and the second 17 | column `pycor` representing the `patches` coordinates and the 18 | third column `id`, or 19 | 20 | `AgentMatrix` object representing the moving `agents`, or 21 | 22 | Matrix (`ncol` = 2) with the first column `whoTurtles` and the 23 | second column `id`. 24 | }\if{html}{\out{
}}} 25 | } 26 | \value{ 27 | Matrix (\code{ncol} = 2, \code{nrow} = 1) with the first column \code{pxcor} 28 | and the second column \code{pycor} representing the coordinates of the 29 | selected \code{patch} from \code{agents}, or 30 | 31 | \if{html}{\out{
}}\preformatted{ Matrix (`ncol` = 2) with the first column `pxcor` 32 | and the second column `pycor` representing the coordinates of the 33 | selected `patches` from `agents`, one per individual `id`, or 34 | 35 | `AgentMatrix` object representing the `turtle` 36 | selected from `agents`, or 37 | 38 | Integer. Vector of `who` numbers for the selected `turtles` from 39 | `agents`, one per individual `id`. 40 | }\if{html}{\out{
}} 41 | } 42 | \description{ 43 | Report one \code{patch} or \code{turtle} randomly selected among \code{agents}. 44 | } 45 | \details{ 46 | If \code{agents} is a matrix with \code{ncol} = 3, the selection of one 47 | random \code{patch} is done per individual \code{id}. The order of the \code{patches} 48 | coordinates returned follow the order of \code{id}. 49 | If \code{agents} is a matrix (\code{ncol} = 2) with columns \code{whoTurtles} and 50 | \code{id}, the selection of one random \code{turtle} (defined by their \code{whoTurtles}) 51 | is done per individual \code{id}. The order of the \code{who} numbers returned 52 | follow the order of \code{id}. 53 | } 54 | \examples{ 55 | # Patches 56 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 57 | pSelect <- oneOf(agents = patches(w1)) 58 | 59 | # Turtles 60 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 61 | tSelect <- oneOf(agents = t1) 62 | 63 | } 64 | \references{ 65 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 66 | Center for Connected Learning and Computer-Based Modeling, 67 | Northwestern University. Evanston, IL. 68 | } 69 | \seealso{ 70 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#one-of} 71 | } 72 | \author{ 73 | Sarah Bauduin 74 | } 75 | -------------------------------------------------------------------------------- /man/other.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{other} 4 | \alias{other} 5 | \alias{other,matrix,matrix-method} 6 | \title{Others} 7 | \usage{ 8 | other(agents, except) 9 | 10 | \S4method{other}{matrix,matrix}(agents, except) 11 | } 12 | \arguments{ 13 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 14 | column \code{pycor} representing the \code{patches} coordinates, or 15 | 16 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 17 | }\if{html}{\out{
}}} 18 | 19 | \item{except}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 20 | column \code{pycor} representing the \code{patches} coordinates, or 21 | 22 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 23 | }\if{html}{\out{
}}} 24 | } 25 | \value{ 26 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 27 | column \code{pycor} representing the \code{patches} in \code{agents} without 28 | the ones in \code{except}, or 29 | 30 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` representing the `turtles` in `agents` without 31 | the ones in `except`. 32 | }\if{html}{\out{
}} 33 | } 34 | \description{ 35 | Report an \code{agentset} of the \code{agents} except specific ones. 36 | } 37 | \details{ 38 | Both \code{agents} and \code{except} must be of the same class (e.g., both 39 | \code{patches} or both \code{turtles}). 40 | 41 | \if{html}{\out{
}}\preformatted{ Warning: this function removes `turtles` only based on similar `who` numbers 42 | and `breed` names. 43 | }\if{html}{\out{
}} 44 | } 45 | \examples{ 46 | # Patches 47 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 48 | p1 <- other(agents = patches(w1), except = patch(w1, 0, 0)) 49 | NLcount(p1) # 99 patches 50 | 51 | # Turtles 52 | t1 <- createTurtles(n = 10, coords = cbind(xcor = 0, ycor = 0)) 53 | t2 <- other(agents = t1, except = turtle(t1, who = 0)) 54 | NLcount(t2) # 9 turtles 55 | 56 | } 57 | \references{ 58 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 59 | Center for Connected Learning and Computer-Based Modeling, 60 | Northwestern University. Evanston, IL. 61 | } 62 | \seealso{ 63 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#other} 64 | } 65 | \author{ 66 | Sarah Bauduin 67 | } 68 | -------------------------------------------------------------------------------- /man/pExist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{pExist} 4 | \alias{pExist} 5 | \alias{pExist,worldNLR,numeric,numeric-method} 6 | \title{Do the patches exist?} 7 | \usage{ 8 | pExist(world, pxcor, pycor) 9 | 10 | \S4method{pExist}{worldNLR,numeric,numeric}(world, pxcor, pycor) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{pxcor}{Integer. Vector of patches \code{pxcor} coordinates. Must be of length 1 16 | or of the same length as \code{pycor}.} 17 | 18 | \item{pycor}{Integer. Vector of patches \code{pycor} coordinates. Must be of length 1 19 | or of the same length as \code{pxcor}.} 20 | } 21 | \value{ 22 | Logical. 23 | } 24 | \description{ 25 | Report \code{TRUE} if a patch exists inside the \code{world}'s extent, report 26 | \code{FALSE} otherwise. 27 | } 28 | \examples{ 29 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 30 | pExist(world = w1, pxcor = -1, pycor = 2) 31 | 32 | } 33 | \references{ 34 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 35 | Center for Connected Learning and Computer-Based Modeling, 36 | Northwestern University. Evanston, IL. 37 | } 38 | \seealso{ 39 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#member} 40 | } 41 | \author{ 42 | Sarah Bauduin 43 | } 44 | -------------------------------------------------------------------------------- /man/patch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{patch} 4 | \alias{patch} 5 | \alias{patch,worldNLR,numeric,numeric-method} 6 | \title{\code{Patches} coordinates} 7 | \usage{ 8 | patch(world, x, y, duplicate = FALSE, torus = FALSE, out = FALSE) 9 | 10 | \S4method{patch}{worldNLR,numeric,numeric}(world, x, y, duplicate = FALSE, torus = FALSE, out = FALSE) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{x}{Numeric. Vector of \code{x} coordinates. Must be of same 16 | length as \code{y}.} 17 | 18 | \item{y}{Numeric. Vector of \code{y} coordinates. Must be of same 19 | length as \code{x}.} 20 | 21 | \item{duplicate}{Logical. If more than one location \verb{[x, y]} 22 | fall into the same \code{patch} and \code{duplicate == TRUE}, the 23 | \code{patch} coordinates are returned the number of times the locations. 24 | If \code{duplicate == FALSE}, the \code{patch} coordinates 25 | are only returned once. 26 | Default is \code{duplicate == FALSE}.} 27 | 28 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 29 | \code{torus = FALSE}.} 30 | 31 | \item{out}{Logical. If \code{out = FALSE}, no \code{patch} coordinates are returned 32 | for \code{patches} outside of the \code{world}'s extent, if \code{out = TRUE}, 33 | \code{NA} are returned. 34 | Default is \code{out = FALSE}.} 35 | } 36 | \value{ 37 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second column 38 | \code{pycor} representing the \code{patches} coordinates at \verb{[x, y]}. 39 | } 40 | \description{ 41 | Report the coordinates of the \code{patches} at the given \verb{[x, y]} locations. 42 | } 43 | \details{ 44 | If a location \verb{[x, y]} is outside the \code{world}'s extent and 45 | \code{torus = FALSE} and \code{out = FALSE}, no \code{patch} coordinates are returned; 46 | if \code{torus = FALSE} and \code{out = TRUE}, \code{NA} are returned; 47 | if \code{torus = TRUE}, the \code{patch} coordinates from a wrapped \code{world} are 48 | returned. 49 | } 50 | \examples{ 51 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 52 | patch(world = w1, x = c(0, 9.1, 8.9, 5, 5.3), y = c(0, 0, -0.1, 12.4, 12.4)) 53 | patch( 54 | world = w1, x = c(0, 9.1, 8.9, 5, 5.3), y = c(0, 0, -0.1, 12.4, 12.4), 55 | duplicate = TRUE 56 | ) 57 | patch( 58 | world = w1, x = c(0, 9.1, 8.9, 5, 5.3), y = c(0, 0, -0.1, 12.4, 12.4), 59 | torus = TRUE 60 | ) 61 | patch( 62 | world = w1, x = c(0, 9.1, 8.9, 5, 5.3), y = c(0, 0, -0.1, 12.4, 12.4), 63 | torus = TRUE, duplicate = TRUE 64 | ) 65 | 66 | } 67 | \references{ 68 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 69 | Center for Connected Learning and Computer-Based Modeling, 70 | Northwestern University. Evanston, IL. 71 | } 72 | \seealso{ 73 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patch} 74 | } 75 | \author{ 76 | Sarah Bauduin 77 | } 78 | -------------------------------------------------------------------------------- /man/patchAhead.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{patchAhead} 4 | \alias{patchAhead} 5 | \alias{patchAhead,worldNLR,agentMatrix,numeric-method} 6 | \title{\code{Patches} ahead} 7 | \usage{ 8 | patchAhead(world, turtles, dist, torus = FALSE) 9 | 10 | \S4method{patchAhead}{worldNLR,agentMatrix,numeric}(world, turtles, dist, torus = FALSE) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 16 | 17 | \item{dist}{Numeric. Vector of distances from the \code{turtles}. \code{dist} must be 18 | of length 1 or of length \code{turtles}.} 19 | 20 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 21 | \code{torus = FALSE}.} 22 | } 23 | \value{ 24 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second column 25 | \code{pycor} representing the coordinates of the \code{patches} at the distances \code{dist} 26 | and \code{turtles}'s \code{headings} directions 27 | of \code{turtles}. The order of the \code{patches} follows the order of the \code{turtles}. 28 | } 29 | \description{ 30 | Report the coordinates of the \code{patches} at the given 31 | distances of the \code{turtles} in the direction of their \code{headings}. 32 | } 33 | \details{ 34 | If \code{torus = FALSE} and the \code{patch} at distance \code{dist} of a \code{turtle} 35 | is outside the \code{world}'s extent, \code{NA} 36 | are returned for the \code{patch} coordinates. If \code{torus = TRUE}, the \code{patch} 37 | coordinates from a wrapped \code{world} are returned. 38 | } 39 | \examples{ 40 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 41 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 42 | patchAhead(world = w1, turtles = t1, dist = 1) 43 | 44 | } 45 | \references{ 46 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 47 | Center for Connected Learning and Computer-Based Modeling, 48 | Northwestern University. Evanston, IL. 49 | } 50 | \seealso{ 51 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patch-ahead} 52 | } 53 | \author{ 54 | Sarah Bauduin 55 | } 56 | -------------------------------------------------------------------------------- /man/patchAt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{patchAt} 4 | \alias{patchAt} 5 | \alias{patchAt,worldNLR,matrix,numeric,numeric-method} 6 | \title{\code{Patches} at} 7 | \usage{ 8 | patchAt(world, agents, dx, dy, torus = FALSE) 9 | 10 | \S4method{patchAt}{worldNLR,matrix,numeric,numeric}(world, agents, dx, dy, torus = FALSE) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 16 | column \code{pycor} representing the \code{patches} coordinates, or 17 | 18 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 19 | }\if{html}{\out{
}}} 20 | 21 | \item{dx}{Numeric. Vector of distances to the east (right) from the \code{agents}. 22 | If \code{dx} is negative, the distance to the west (left) is computed. 23 | \code{dx} must be of length 1 or of the same length as number of \code{patches} 24 | or \code{turtles} in \code{agents}.} 25 | 26 | \item{dy}{Numeric. Vector of distances to the north (up) from the \code{agents}. 27 | If \code{dy} is negative, the distance to the south is computed (down). 28 | \code{dy} must be of length 1 or of the same length as number of \code{patches} 29 | or \code{turtles} in \code{agents}.} 30 | 31 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 32 | \code{torus = FALSE}.} 33 | } 34 | \value{ 35 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second column 36 | \code{pycor} representing the coordinates of the \code{patches} at \verb{(dx, dy)} 37 | distances of the \code{agents}. The order of the \code{patches} follows the order 38 | of the \code{agents}. 39 | } 40 | \description{ 41 | Report the coordinates of the \code{patches} at \verb{(dx, dy)} distances of the \code{agents}. 42 | } 43 | \details{ 44 | If the \code{patch} at distance \verb{(dx, dy)} 45 | of an \code{agent} is outside of the \code{world}'s extent and \code{torus = FALSE}, 46 | \code{NA} are returned 47 | for the \code{patch} coordinates; 48 | if \code{torus = TRUE}, the \code{patch} coordinates from a wrapped \code{world} are 49 | returned. 50 | } 51 | \examples{ 52 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 53 | patchCorner <- patchAt(world = w1, agents = patch(w1, 0, 0), dx = 1, dy = 1) 54 | t1 <- createTurtles(n = 1, coords = cbind(xcor = 0, ycor = 0)) 55 | patchCorner <- patchAt(world = w1, agents = t1, dx = 1, dy = 1) 56 | 57 | } 58 | \references{ 59 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 60 | Center for Connected Learning and Computer-Based Modeling, 61 | Northwestern University. Evanston, IL. 62 | } 63 | \seealso{ 64 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patch-at} 65 | 66 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#at-points} 67 | } 68 | \author{ 69 | Sarah Bauduin 70 | } 71 | -------------------------------------------------------------------------------- /man/patchHere.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{patchHere} 4 | \alias{patchHere} 5 | \alias{patchHere,worldNLR,agentMatrix-method} 6 | \title{\code{Patches} here} 7 | \usage{ 8 | patchHere(world, turtles) 9 | 10 | \S4method{patchHere}{worldNLR,agentMatrix}(world, turtles) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 16 | } 17 | \value{ 18 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second column 19 | \code{pycor} representing the coordinates of the \code{patches} at the \code{turtles} 20 | location. The order of the \code{patches} follows the order of the \code{turtles}. 21 | } 22 | \description{ 23 | Report the coordinates of the \code{patches} under the \code{turtles} 24 | locations. 25 | } 26 | \details{ 27 | If a \code{turtle} is located outside of the \code{world}'s extent, 28 | \code{NA} are returned 29 | for the \code{patch} coordinates. 30 | } 31 | \examples{ 32 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 33 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 34 | patchHere(world = w1, turtles = t1) 35 | 36 | } 37 | \references{ 38 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 39 | Center for Connected Learning and Computer-Based Modeling, 40 | Northwestern University. Evanston, IL. 41 | } 42 | \seealso{ 43 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patch-here} 44 | } 45 | \author{ 46 | Sarah Bauduin 47 | } 48 | -------------------------------------------------------------------------------- /man/patchLeft.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{patchLeft} 4 | \alias{patchLeft} 5 | \alias{patchLeft,worldNLR,agentMatrix,numeric,numeric-method} 6 | \title{\code{Patches} on the left} 7 | \usage{ 8 | patchLeft(world, turtles, dist, angle, torus = FALSE) 9 | 10 | \S4method{patchLeft}{worldNLR,agentMatrix,numeric,numeric}(world, turtles, dist, angle, torus = FALSE) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 16 | 17 | \item{dist}{Numeric. Vector of distances from the \code{turtles}. \code{dist} must be 18 | of length 1 or of length \code{turtles}.} 19 | 20 | \item{angle}{Numeric. Vector of angles in degrees by which the \code{turtle}'s 21 | \code{headings} should rotate to locate the patches. Must be of length 1 or of 22 | length \code{turtles}.} 23 | 24 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 25 | \code{torus = FALSE}.} 26 | } 27 | \value{ 28 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 29 | column \code{pycor} representing the coordinates of the \code{patches} at \code{dist} 30 | distances of the \code{turtles} and \code{angle} to the left of their \code{headings}. 31 | The order of the \code{patches} follows the order of the \code{turtles}. 32 | } 33 | \description{ 34 | Report the coordinates of the \code{patches} at the given distances of the \code{turtles} 35 | and given \code{angle} left of their \code{headings}. 36 | } 37 | \details{ 38 | If a given \code{dist} value is negative, then the \code{turtle} would look backward. 39 | If a given \code{angle} value is negative, then the \code{turtle} would look to the right. 40 | 41 | \if{html}{\out{
}}\preformatted{ If `torus = FALSE` and the `patch` at distance `dist` of a `turtle` 42 | and `angle` degrees to the left of its `heading` is outside the 43 | `world`'s extent, `NA` 44 | are returned for the `patch` coordinates. If `torus = TRUE`, the `patch` 45 | coordinates from a wrapped `world` are returned. 46 | }\if{html}{\out{
}} 47 | } 48 | \examples{ 49 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 50 | t1 <- createTurtles(n = 1, coords = cbind(xcor = 2, ycor = 2), heading = 90) 51 | patchLeft(world = w1, turtles = t1, dist = 2, angle = 90) 52 | 53 | } 54 | \references{ 55 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 56 | Center for Connected Learning and Computer-Based Modeling, 57 | Northwestern University. Evanston, IL. 58 | } 59 | \seealso{ 60 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patch-lr-and-ahead} 61 | } 62 | \author{ 63 | Sarah Bauduin 64 | } 65 | -------------------------------------------------------------------------------- /man/patchRight.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{patchRight} 4 | \alias{patchRight} 5 | \alias{patchRight,worldNLR,agentMatrix,numeric,numeric-method} 6 | \title{\code{Patches} on the right} 7 | \usage{ 8 | patchRight(world, turtles, dist, angle, torus = FALSE) 9 | 10 | \S4method{patchRight}{worldNLR,agentMatrix,numeric,numeric}(world, turtles, dist, angle, torus = FALSE) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 16 | 17 | \item{dist}{Numeric. Vector of distances from the \code{turtles}. \code{dist} must be 18 | of length 1 or of length \code{turtles}.} 19 | 20 | \item{angle}{Numeric. Vector of angles in degrees by which the \code{turtle}'s 21 | \code{headings} should rotate to locate the patches. Must be of length 1 or of 22 | length \code{turtles}.} 23 | 24 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 25 | \code{torus = FALSE}.} 26 | } 27 | \value{ 28 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 29 | column \code{pycor} representing the coordinates of the \code{patches} at \code{dist} 30 | distances of the \code{turtles} and \code{angle} to the right of their \code{headings}. 31 | The order of the \code{patches} follows the order of the \code{turtles}. 32 | } 33 | \description{ 34 | Report the coordinates of the \code{patches} at the given distances of the \code{turtles} 35 | and given \code{angle} right of their \code{headings}. 36 | } 37 | \details{ 38 | If a given \code{dist} value is negative, then the \code{turtle} would look backward. 39 | If a given \code{angle} value is negative, then the \code{turtle} would 40 | look to the left. 41 | 42 | \if{html}{\out{
}}\preformatted{ If `torus = FALSE` and the `patch` at distance `dist` of a `turtle` 43 | and `angle` degrees to the right of its `heading` is outside the 44 | `world`'s extent, `NA` 45 | are returned for the `patch` coordinates. If `torus = TRUE`, the `patch` 46 | coordinates from a wrapped `world` are returned. 47 | }\if{html}{\out{
}} 48 | } 49 | \examples{ 50 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 51 | t1 <- createTurtles(n = 1, coords = cbind(xcor = 2, ycor = 2), heading = 90) 52 | patchRight(world = w1, turtles = t1, dist = 2, angle = 90) 53 | 54 | } 55 | \references{ 56 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 57 | Center for Connected Learning and Computer-Based Modeling, 58 | Northwestern University. Evanston, IL. 59 | } 60 | \seealso{ 61 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patch-lr-and-ahead} 62 | } 63 | \author{ 64 | Sarah Bauduin 65 | } 66 | -------------------------------------------------------------------------------- /man/patchSet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{patchSet} 4 | \alias{patchSet} 5 | \alias{patchSet,matrix-method} 6 | \title{\code{Patch} set} 7 | \usage{ 8 | patchSet(...) 9 | 10 | \S4method{patchSet}{matrix}(...) 11 | } 12 | \arguments{ 13 | \item{...}{Matrices (\code{ncol} = 2) of \code{patches} coordinates with the first column 14 | \code{pxcor} and the second column \code{pycor}.} 15 | } 16 | \value{ 17 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second column 18 | \code{pycor} representing the \code{patches} coordinates. 19 | } 20 | \description{ 21 | Report the \code{patch} coordinates of all the unique \code{patches} contained in the inputs. 22 | } 23 | \details{ 24 | Duplicate \code{patches} among the inputs are removed in the returned matrix. 25 | } 26 | \examples{ 27 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 28 | p1 <- patchAt(world = w1, agents = patch(w1, c(0, 1, 2), c(0, 0, 0)), dx = 1, dy = 1) 29 | p2 <- patchDistDir(world = w1, agents = patch(w1, 0, 0), dist = 1, angle = 45) 30 | p3 <- patch(world = w1, x = 4.3, y = 8) 31 | p4 <- patchSet(p1, p2, p3) 32 | 33 | } 34 | \references{ 35 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 36 | Center for Connected Learning and Computer-Based Modeling, 37 | Northwestern University. Evanston, IL. 38 | } 39 | \seealso{ 40 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patch-set} 41 | } 42 | \author{ 43 | Sarah Bauduin 44 | } 45 | -------------------------------------------------------------------------------- /man/patches.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{patches} 4 | \alias{patches} 5 | \alias{patches,worldNLR-method} 6 | \title{All the \code{patches} in a \code{world}} 7 | \usage{ 8 | patches(world) 9 | 10 | \S4method{patches}{worldNLR}(world) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | } 15 | \value{ 16 | Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second column 17 | \code{pycor} representing the \code{patches} coordinates. The order of the \code{patches} 18 | follows the order of the cells numbers as defined for a \verb{Raster*} object. 19 | } 20 | \description{ 21 | Report the coordinates of all the \code{patches} in the \code{world}. 22 | } 23 | \examples{ 24 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 25 | allPatches <- patches(world = w1) 26 | NLcount(allPatches) # 100 patches 27 | 28 | } 29 | \references{ 30 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 31 | Center for Connected Learning and Computer-Based Modeling, 32 | Northwestern University. Evanston, IL. 33 | } 34 | \seealso{ 35 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#patches} 36 | } 37 | \author{ 38 | Sarah Bauduin 39 | } 40 | -------------------------------------------------------------------------------- /man/plotMethods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{plot.agentMatrix} 4 | \alias{plot.agentMatrix} 5 | \alias{plot.worldMatrix} 6 | \alias{plot.worldArray} 7 | \alias{points.agentMatrix} 8 | \title{Basic plot methods for \code{agentMatrix}, \code{worldMatrix}, \code{worldArray}} 9 | \usage{ 10 | \method{plot}{agentMatrix}(x, ...) 11 | 12 | \method{plot}{worldMatrix}(x, ...) 13 | 14 | \method{plot}{worldArray}(x, ...) 15 | 16 | \method{points}{agentMatrix}(x, ...) 17 | } 18 | \arguments{ 19 | \item{x}{an \code{agentMatrix}, \code{worldMatrix} or \code{worldArray} object} 20 | 21 | \item{...}{arguments passed to plot methods for matrix (\code{agentMatrix}) or \code{raster} (\verb{world*})} 22 | } 23 | \value{ 24 | none; invoked for side-effect of generating a plot. 25 | } 26 | \description{ 27 | These pass to plot, as a matrix of points (\code{agentMatrix}), as a \code{raster} (\code{worldMatrix}), 28 | or a \code{rasterStack} (\code{worldArray}). 29 | They can be modified. 30 | } 31 | \examples{ 32 | # agentMatrix 33 | newAgent <- new("agentMatrix", 34 | coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 35 | char = letters[c(1, 2, 6)], 36 | nums2 = c(4.5, 2.6, 2343), 37 | char2 = LETTERS[c(4, 24, 3)], 38 | nums = 5:7 39 | ) 40 | plot(newAgent) 41 | 42 | ## worldMatrix 43 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = 1:100) 44 | plot(w1) 45 | 46 | ## worldArray 47 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = 1:25) 48 | w2 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = 25:1) 49 | w3 <- stackWorlds(w1, w2) 50 | plot(w3) 51 | 52 | # agentMatrix 53 | newAgent <- new("agentMatrix", 54 | coords = cbind(pxcor = c(1, 2, 5), pycor = c(3, 4, 6)), 55 | char = letters[c(1, 2, 6)], 56 | nums2 = c(4.5, 2.6, 2343), 57 | char2 = LETTERS[c(4, 24, 3)], 58 | nums = 5:7 59 | ) 60 | points(newAgent) 61 | } 62 | -------------------------------------------------------------------------------- /man/projNowhere.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/NetLogoR-package.R 3 | \docType{data} 4 | \name{.projNowhere} 5 | \alias{.projNowhere} 6 | \title{Internal CRS usage} 7 | \format{ 8 | An object of class \code{character} of length 1. 9 | } 10 | \usage{ 11 | .projNowhere 12 | } 13 | \description{ 14 | This is used in various places when converting \code{agentMatrix} objects to 15 | \code{SpatialPoints} for use with functions, such as \code{raster::buffer()}. 16 | None of these functions results in any real geospatial information being conserved, 17 | other than distance and angle calculations. Buffering still occurs on the 18 | unit-less World. This is therefore a way to allow \code{sp} and \code{raster} 19 | functions to work \emph{as if a cell in the World was equal to 1 m}. The resulting 20 | answers will be converted back to units of "cells", not "m". 21 | The \code{CRS()} operation is relatively time consuming. 22 | Having a single object usable throughout is \emph{much} faster. 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /man/quickPlot-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/quickPlot.R 3 | \name{numLayers.worldArray} 4 | \alias{numLayers.worldArray} 5 | \alias{numLayers.worldMatrix} 6 | \alias{layerNames,worldArray-method} 7 | \alias{.identifyGrobToPlot,worldArray,.quickPlotGrob-method} 8 | \title{Methods for \code{quickPlot}} 9 | \usage{ 10 | \method{numLayers}{worldArray}(x) 11 | 12 | \method{numLayers}{worldMatrix}(x) 13 | 14 | \S4method{layerNames}{worldArray}(object) 15 | 16 | \S4method{.identifyGrobToPlot}{worldArray,.quickPlotGrob}(toPlot, sGrob, takeFromPlotObj) 17 | } 18 | \arguments{ 19 | \item{x}{An object or list of objects.} 20 | 21 | \item{object}{An object from which to extract the layer names.} 22 | 23 | \item{toPlot}{The object to plot. Should be a single layer if from a multi-layer 24 | object such as a \code{RasterStack}.} 25 | 26 | \item{sGrob}{\code{quickPlot} grob object} 27 | 28 | \item{takeFromPlotObj}{Logical. Should the data come from the argument passed 29 | into \code{Plot} (\code{TRUE}), or from the (\code{.quickPlotEnv}) (\code{FALSE}).} 30 | } 31 | \value{ 32 | \code{numLayers} returns an integer representing the number of 33 | layers in a \code{worldArray} or \code{worldMatrix} (which is always \code{1L}) 34 | 35 | \code{layerNames} returns an character vector representing the names 36 | of the layers in a \code{worldArray} 37 | } 38 | \description{ 39 | These are required to create plotting methods to work with \pkg{quickPlot}. 40 | } 41 | -------------------------------------------------------------------------------- /man/randomPxcor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{randomPxcor} 4 | \alias{randomPxcor} 5 | \alias{randomPxcor,worldNLR,numeric-method} 6 | \title{Random \code{pxcor}} 7 | \usage{ 8 | randomPxcor(world, n) 9 | 10 | \S4method{randomPxcor}{worldNLR,numeric}(world, n) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{n}{Integer.} 16 | } 17 | \value{ 18 | Integer. Vector of length \code{n} of \code{pxcor} coordinates. 19 | } 20 | \description{ 21 | Report \code{n} random \code{pxcor} coordinates within the \code{world}'s extent. 22 | } 23 | \examples{ 24 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 25 | pxcor <- randomPxcor(world = w1, n = 10) 26 | 27 | } 28 | \references{ 29 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 30 | Center for Connected Learning and Computer-Based Modeling, 31 | Northwestern University. Evanston, IL. 32 | } 33 | \seealso{ 34 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-pcor} 35 | } 36 | \author{ 37 | Sarah Bauduin 38 | } 39 | -------------------------------------------------------------------------------- /man/randomPycor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/patch-functions.R 3 | \name{randomPycor} 4 | \alias{randomPycor} 5 | \alias{randomPycor,worldNLR,numeric-method} 6 | \title{Random \code{pycor}} 7 | \usage{ 8 | randomPycor(world, n) 9 | 10 | \S4method{randomPycor}{worldNLR,numeric}(world, n) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{n}{Integer.} 16 | } 17 | \value{ 18 | Integer. Vector of length \code{n} of \code{pycor} coordinates. 19 | } 20 | \description{ 21 | Report \code{n} random \code{pycor} coordinates within the \code{world}'s extent. 22 | } 23 | \examples{ 24 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 25 | pycor <- randomPycor(world = w1, n = 10) 26 | 27 | } 28 | \references{ 29 | Wilensky, U. 1999. NetLogo. \url{http://ccl.northwestern.edu/netlogo/}. 30 | Center for Connected Learning and Computer-Based Modeling, 31 | Northwestern University. Evanston, IL. 32 | } 33 | \seealso{ 34 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-pcor} 35 | } 36 | \author{ 37 | Sarah Bauduin 38 | } 39 | -------------------------------------------------------------------------------- /man/randomXYcor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{randomXYcor} 4 | \alias{randomXYcor} 5 | \alias{randomXYcor,worldNLR,numeric-method} 6 | \title{Random \code{turtles} coordinates} 7 | \usage{ 8 | randomXYcor(world, n) 9 | 10 | \S4method{randomXYcor}{worldNLR,numeric}(world, n) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{n}{Integer.} 16 | } 17 | \value{ 18 | Matrix (\code{ncol} = 2, \code{nrow} = \code{n}) with the first column \code{xcor} and the second 19 | column \code{ycor}. 20 | } 21 | \description{ 22 | Report \code{n} random \code{xcor} and \code{ycor} coordinates within the \code{world}'s extent. 23 | } 24 | \examples{ 25 | w1 <- createWorld( 26 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 27 | data = runif(25) 28 | ) 29 | t1 <- createTurtles(n = 10, coords = randomXYcor(world = w1, n = 10)) 30 | plot(w1) 31 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 32 | 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/randomXcor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{randomXcor} 4 | \alias{randomXcor} 5 | \alias{randomXcor,worldNLR,numeric-method} 6 | \title{Random \code{xcor}} 7 | \usage{ 8 | randomXcor(world, n) 9 | 10 | \S4method{randomXcor}{worldNLR,numeric}(world, n) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{n}{Integer.} 16 | } 17 | \value{ 18 | Numeric. Vector of length \code{n} of \code{xcor} coordinates. 19 | } 20 | \description{ 21 | Report \code{n} random \code{xcor} coordinates within the \code{world}'s extent. 22 | } 23 | \examples{ 24 | w1 <- createWorld( 25 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 26 | data = runif(25) 27 | ) 28 | t1 <- createTurtles(n = 10, coords = cbind( 29 | xcor = randomXcor(world = w1, n = 10), 30 | ycor = randomYcor(world = w1, n = 10) 31 | )) 32 | plot(w1) 33 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 34 | 35 | } 36 | \references{ 37 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 38 | Center for Connected Learning and Computer-Based Modeling, 39 | Northwestern University. Evanston, IL. 40 | } 41 | \seealso{ 42 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-cor} 43 | } 44 | \author{ 45 | Sarah Bauduin 46 | } 47 | -------------------------------------------------------------------------------- /man/randomYcor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{randomYcor} 4 | \alias{randomYcor} 5 | \alias{randomYcor,worldNLR,numeric-method} 6 | \title{Random \code{ycor}} 7 | \usage{ 8 | randomYcor(world, n) 9 | 10 | \S4method{randomYcor}{worldNLR,numeric}(world, n) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | 15 | \item{n}{Integer.} 16 | } 17 | \value{ 18 | Numeric. Vector of length \code{n} of \code{ycor} coordinates. 19 | } 20 | \description{ 21 | Report \code{n} random \code{ycor} coordinates within the \code{world}'s extent. 22 | } 23 | \examples{ 24 | w1 <- createWorld( 25 | minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, 26 | data = runif(25) 27 | ) 28 | t1 <- createTurtles(n = 10, coords = cbind( 29 | xcor = randomXcor(world = w1, n = 10), 30 | ycor = randomYcor(world = w1, n = 10) 31 | )) 32 | plot(w1) 33 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 34 | 35 | } 36 | \references{ 37 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 38 | Center for Connected Learning and Computer-Based Modeling, 39 | Northwestern University. Evanston, IL. 40 | } 41 | \seealso{ 42 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-cor} 43 | } 44 | \author{ 45 | Sarah Bauduin 46 | } 47 | -------------------------------------------------------------------------------- /man/raster2world.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{raster2world} 4 | \alias{raster2world} 5 | \alias{raster2world,ANY-method} 6 | \title{Convert a \verb{Raster*} object into a \code{worldMatrix} or \code{worldArray} object} 7 | \usage{ 8 | raster2world(raster) 9 | 10 | \S4method{raster2world}{ANY}(raster) 11 | } 12 | \arguments{ 13 | \item{raster}{\code{RasterLayer} or \code{RasterStack} object.} 14 | } 15 | \value{ 16 | \code{WorldMatrix} or \code{worldArray} object depending on the input \code{raster}. 17 | \code{Patches} value are retained from the \code{raster}. 18 | } 19 | \description{ 20 | Convert a \code{RasterLayer} object into a \code{worldMatrix} object or a \code{RasterStack} object 21 | into a \code{worldArray} object. 22 | } 23 | \details{ 24 | See \code{help("worldMatrix-class")} or \code{help("worldArray-class")} 25 | for more details on the classes. 26 | 27 | \if{html}{\out{
}}\preformatted{ The number of rows and columns, as well as the cell values of the `raster` 28 | are kept the same. However, to match the coordinates system and resolution of a 29 | `worldMatrix` or `worldArray`, the grid is shifted by a 1/2 cell to have 30 | round coordinate values at the center of the patches and patch size is equal to (1,1). 31 | The bottom left corner cell coordinates of the `worldMatrix` or `worldArray` 32 | will be (pxcor = 0, pycor = 0). 33 | }\if{html}{\out{
}} 34 | } 35 | \examples{ 36 | if (requireNamespace("raster")) { 37 | r1 <- raster::raster(raster::extent(c(0, 10, 0, 10)), nrows = 10, ncols = 10) 38 | r1[] <- runif(100) 39 | w1 <- raster2world(r1) 40 | terra::plot(r1) 41 | terra::plot(w1) 42 | } 43 | 44 | } 45 | \author{ 46 | Sarah Bauduin 47 | } 48 | -------------------------------------------------------------------------------- /man/right.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{right} 4 | \alias{right} 5 | \alias{right,agentMatrix,numeric-method} 6 | \title{Rotate to the right} 7 | \usage{ 8 | right(turtles, angle) 9 | 10 | \S4method{right}{agentMatrix,numeric}(turtles, angle) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | 15 | \item{angle}{Numeric. Vector of angles in degrees by which to rotate the \code{turtles}' 16 | headings. Must be of length 1 or of length \code{turtles}.} 17 | } 18 | \value{ 19 | \code{AgentMatrix} representing the \code{turtles} with updated \code{heading} values. 20 | } 21 | \description{ 22 | Rotate the \code{turtles}'s headings to the right of \code{angle} degrees. 23 | } 24 | \details{ 25 | If a given \code{angle} value is negative, then the turtle rotates to the left. 26 | } 27 | \examples{ 28 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) 29 | t1 <- createTurtles(n = 10, world = w1) 30 | of(agents = t1, var = "heading") 31 | t1 <- right(turtles = t1, angle = 180) 32 | of(agents = t1, var = "heading") 33 | 34 | } 35 | \references{ 36 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 37 | Center for Connected Learning and Computer-Based Modeling, 38 | Northwestern University. Evanston, IL. 39 | } 40 | \seealso{ 41 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#right} 42 | } 43 | \author{ 44 | Sarah Bauduin 45 | } 46 | -------------------------------------------------------------------------------- /man/setXY.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{setXY} 4 | \alias{setXY} 5 | \alias{setXY,agentMatrix,numeric,numeric,missing,ANY-method} 6 | \alias{setXY,agentMatrix,numeric,numeric,worldNLR,logical-method} 7 | \title{Set \code{turtles}' locations} 8 | \usage{ 9 | setXY(turtles, xcor, ycor, world, torus = FALSE) 10 | 11 | \S4method{setXY}{agentMatrix,numeric,numeric,missing,ANY}(turtles, xcor, ycor, torus) 12 | 13 | \S4method{setXY}{agentMatrix,numeric,numeric,worldNLR,logical}(turtles, xcor, ycor, world, torus = FALSE) 14 | } 15 | \arguments{ 16 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 17 | 18 | \item{xcor}{Numeric. Vector of \code{x} coordinates. Must be of length 1 or 19 | of length \code{turtles}.} 20 | 21 | \item{ycor}{Numeric. Vector of \code{y} coordinates. Must be of length 1 or 22 | of length \code{turtles}.} 23 | 24 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 25 | 26 | \item{torus}{Logical to determine if the \code{world} is wrapped. Default is 27 | \code{torus = FALSE}.} 28 | } 29 | \value{ 30 | \code{AgentMatrix} representing the \code{turtles} with updated coordinates 31 | and updated data for their previous coordinates \code{prevX} and \code{prevY}. 32 | } 33 | \description{ 34 | Set the \code{turtles} \code{xcor} and \code{ycor} coordinates. 35 | } 36 | \details{ 37 | \code{world} must be provided only if \code{torus = TRUE}. 38 | 39 | \if{html}{\out{
}}\preformatted{ If the given coordinates `[xcor, ycor]` 40 | are located outside of the `world`'s extent and `torus = TRUE`, 41 | then the coordinates assigned to the `turtle` 42 | are the ones from a wrapped `word`; if `torus = FALSE`, the `turtle` 43 | is located outside of the `world`'s extent with the given coordinates. 44 | }\if{html}{\out{
}} 45 | } 46 | \examples{ 47 | w1 <- createWorld( 48 | minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, 49 | data = runif(100) 50 | ) 51 | t1 <- createTurtles(n = 5, coords = randomXYcor(w1, n = 5)) 52 | plot(w1) 53 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 54 | 55 | t1 <- setXY(turtles = t1, xcor = 1:5, ycor = 1:5) 56 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 57 | 58 | } 59 | \references{ 60 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 61 | Center for Connected Learning and Computer-Based Modeling, 62 | Northwestern University. Evanston, IL. 63 | } 64 | \seealso{ 65 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#setxy} 66 | } 67 | \author{ 68 | Sarah Bauduin 69 | } 70 | -------------------------------------------------------------------------------- /man/sf2turtles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{sf2turtles} 4 | \alias{sf2turtles} 5 | \alias{sf2turtles,ANY-method} 6 | \title{From \code{sf} to \code{agentMatrix}} 7 | \usage{ 8 | sf2turtles(turtles_sf) 9 | 10 | \S4method{sf2turtles}{ANY}(turtles_sf) 11 | } 12 | \arguments{ 13 | \item{turtles_sf}{\code{sf} object of \verb{POINT geometry} representing moving \code{agents}.} 14 | } 15 | \value{ 16 | \code{AgentMatrix} object representing the moving \code{agents} (coordinates and data) 17 | as contained in \code{turtles_sf}. 18 | } 19 | \description{ 20 | Convert a \code{sf} object into an \code{agentMatrix} object. 21 | } 22 | \details{ 23 | If the \code{turtles_sf} does not contain the variables created with 24 | \code{createTurtles()}, these variables will be created with the 25 | default values as in \code{createTurtles()}. 26 | } 27 | \examples{ 28 | if (requireNamespace("sf", quietly = TRUE)) { 29 | turtles_sf1 <- sf::st_as_sf( 30 | cbind.data.frame( 31 | x = c(1, 2, 3), y = c(1, 2, 3), 32 | age = c(0, 0, 3), sex = c("F", "F", "M") 33 | ), 34 | coords = c("x", "y") 35 | ) 36 | t1 <- sf2turtles(turtles_sf = turtles_sf1) 37 | } 38 | 39 | } 40 | \author{ 41 | Sarah Bauduin 42 | } 43 | -------------------------------------------------------------------------------- /man/show-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{show,worldArray-method} 4 | \alias{show,worldArray-method} 5 | \alias{show,worldMatrix-method} 6 | \title{Key base R functions for \code{worldNLR} classes} 7 | \usage{ 8 | \S4method{show}{worldArray}(object) 9 | 10 | \S4method{show}{worldMatrix}(object) 11 | } 12 | \arguments{ 13 | \item{object}{An \code{agentMatrix} object.} 14 | } 15 | \value{ 16 | \code{show} is called for its side effects. It shows key metadata elements 17 | of the \code{worldArray} or \code{worldMatrix}, plus the first 4 columns and rows of data 18 | } 19 | \description{ 20 | Slight modifications from the default versions. 21 | } 22 | -------------------------------------------------------------------------------- /man/spatRast2world.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{spatRast2world} 4 | \alias{spatRast2world} 5 | \alias{spatRast2world,SpatRaster-method} 6 | \title{Convert a \code{SpatRaster} object into a \code{worldMatrix} or \code{worldArray} object} 7 | \usage{ 8 | spatRast2world(raster) 9 | 10 | \S4method{spatRast2world}{SpatRaster}(raster) 11 | } 12 | \arguments{ 13 | \item{raster}{\code{SpatRaster} object.} 14 | } 15 | \value{ 16 | \code{WorldMatrix} or \code{worldArray} object depending on the number of layers 17 | of the input \code{raster}. 18 | \code{Patches} value are retained from the \code{raster}. 19 | } 20 | \description{ 21 | Convert a \code{SpatRaster} object into a \code{worldMatrix} 22 | object or a \code{worldArray} object depending on the number of layers of the 23 | \code{SpatRaster} object. 24 | } 25 | \details{ 26 | See \code{help("worldMatrix-class")} or \code{help("worldArray-class")} 27 | for more details on the classes. 28 | 29 | \if{html}{\out{
}}\preformatted{ If the `SpatRaster` object has only one layer, a `worldMatrix` object 30 | will be returned. If the `SpatRaster` object has more than one layer, 31 | layers must have unique names and a `worldArray` object will be returned. 32 | 33 | The number of rows and columns, as well as the cell values of the `raster` 34 | are kept the same. However, to match the coordinates system and resolution of a 35 | `worldMatrix` or `worldArray`, the grid is shifted by a 1/2 cell to have 36 | round coordinate values at the center of the patches and patch size is equal to (1,1). 37 | The bottom left corner cell coordinates of the `worldMatrix` or `worldArray` 38 | will be (pxcor = 0, pycor = 0). 39 | }\if{html}{\out{
}} 40 | } 41 | \examples{ 42 | library(terra) 43 | r1 <- rast(xmin = 0, xmax = 10, ymin = 0, ymax = 10, nrows = 10, ncols = 10) 44 | r1[] <- runif(100) 45 | w1 <- spatRast2world(r1) 46 | terra::plot(r1) 47 | plot(w1) 48 | 49 | r2 <- rast(xmin = 0, xmax = 10, ymin = 0, ymax = 10, nrows = 10, ncols = 10) 50 | r2[] <- 0 51 | r3 <- c(r1, r2) 52 | names(r3) <- c("layer1", "layer2") 53 | w3 <- spatRast2world(r3) 54 | terra::plot(r3) 55 | plot(w3) 56 | 57 | } 58 | \author{ 59 | Sarah Bauduin 60 | } 61 | -------------------------------------------------------------------------------- /man/spdf2turtles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{spdf2turtles} 4 | \alias{spdf2turtles} 5 | \alias{spdf2turtles,ANY-method} 6 | \title{From \code{SpatialPointsDataFrame} to \code{agentMatrix}} 7 | \usage{ 8 | spdf2turtles(spdf) 9 | 10 | \S4method{spdf2turtles}{ANY}(spdf) 11 | } 12 | \arguments{ 13 | \item{spdf}{\code{SpatialPointsDataFrame} object representing moving \code{agents}.} 14 | } 15 | \value{ 16 | \code{AgentMatrix} object representing the moving \code{agents} (coordinates and data) 17 | as contained in \code{spdf}. 18 | } 19 | \description{ 20 | Convert a \code{SpatialPointsDataFrame} object into an \code{agentMatrix} object. 21 | } 22 | \details{ 23 | If the \code{spdf} does not contain the variables created with 24 | \code{createTurtles()}, these variables will be created with the 25 | default values as in \code{createTurtles()}. 26 | } 27 | \examples{ 28 | if (requireNamespace("sp", quietly = TRUE)) { 29 | sp1 <- sp::SpatialPointsDataFrame( 30 | coords = cbind(x = c(1, 2, 3), y = c(1, 2, 3)), 31 | data = cbind.data.frame( 32 | age = c(0, 0, 3), 33 | sex = c("F", "F", "M") 34 | ) 35 | ) 36 | t1 <- spdf2turtles(spdf = sp1) 37 | } 38 | 39 | } 40 | \author{ 41 | Sarah Bauduin 42 | } 43 | -------------------------------------------------------------------------------- /man/sprout.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{sprout} 4 | \alias{sprout} 5 | \alias{sprout,numeric,matrix-method} 6 | \title{Sprout new \code{turtles}} 7 | \usage{ 8 | sprout(n, patches, breed, heading, color, turtles) 9 | 10 | \S4method{sprout}{numeric,matrix}(n, patches, breed, heading, color, turtles) 11 | } 12 | \arguments{ 13 | \item{n}{Integer. Vector of length 1 or of length the number of \code{patches}. 14 | Number of new \code{turtles} 15 | to create on each \code{patch}.} 16 | 17 | \item{patches}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 18 | column \code{pycor} representing the \code{patches} coordinates.} 19 | 20 | \item{breed}{Character. Vector of \code{breed} names. 21 | Must be of length 1 or of length the number of \code{patches}. 22 | If missing, \code{breed} = \code{turtle} for all the sprouted \code{turtles}.} 23 | 24 | \item{heading}{Numeric. Vector of values between 0 and 360. 25 | Must be of length 1 or of length the number of \code{patches}. 26 | If missing, a random \code{heading} is assigned to each sprouted \code{turtle}.} 27 | 28 | \item{color}{Character. Vector of \code{color} names. 29 | Must be of length 1, of length the number of \code{patches} or 30 | of length \code{sum(n)}. 31 | If missing, \code{colors} are assigned using the function \code{rainbow(n)}.} 32 | 33 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 34 | } 35 | \value{ 36 | \code{AgentMatrix} including the new 37 | sprouted \code{turtles}. 38 | } 39 | \description{ 40 | Create \code{n} new \code{turtles} on specific \code{patches}. 41 | } 42 | \details{ 43 | \code{nrow(patches)} must be equal to 1 or to \code{n}. 44 | 45 | \if{html}{\out{
}}\preformatted{ If `turtles` is provided, the new `turtles` are added to 46 | the `turtles` when returned. The `who` numbers of the sprouted `turtles` 47 | therefore follow the ones from the `turtles`. 48 | All new sprouted `turtles` are placed at the end of the `agentMatrix` object. 49 | If no `turtles` 50 | is provided, a new `agentMatrix` is created and the `who` numbers 51 | start at 0. 52 | 53 | If `turtles` is provided and had additional variables created 54 | with `turtlesOwn()`, `NA` is given for these variables 55 | for the new sprouted `turtles`. 56 | }\if{html}{\out{
}} 57 | } 58 | \examples{ 59 | t1 <- sprout(patches = cbind(pxcor = 2, pycor = 2), n = 3) 60 | t2 <- sprout(patches = cbind(pxcor = 3, pycor = 3), n = 3, turtles = t1) 61 | 62 | } 63 | \references{ 64 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 65 | Center for Connected Learning and Computer-Based Modeling, 66 | Northwestern University. Evanston, IL. 67 | } 68 | \seealso{ 69 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#sprout} 70 | } 71 | \author{ 72 | Sarah Bauduin 73 | } 74 | -------------------------------------------------------------------------------- /man/stackWorlds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \name{stackWorlds} 4 | \alias{stackWorlds} 5 | \alias{stackWorlds,worldMatrix-method} 6 | \title{Stack \code{worlds}} 7 | \usage{ 8 | stackWorlds(...) 9 | 10 | \S4method{stackWorlds}{worldMatrix}(...) 11 | } 12 | \arguments{ 13 | \item{...}{\code{worldMatrix} objects. If passed as unnamed objects, then the function 14 | will attempt to use their object names as layer names. Alternatively, to be more 15 | reliable, these can be passed as named arguments. See examples.} 16 | } 17 | \value{ 18 | \code{worldArray} object. 19 | } 20 | \description{ 21 | Stack multiple \code{worldMatrix} into a \code{worldArray}. 22 | } 23 | \details{ 24 | The \code{worldMatrix} objects must all have the same extents. 25 | } 26 | \examples{ 27 | w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = 1:25) 28 | w2 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4, data = 25:1) 29 | w3 <- stackWorlds(w1, w2) 30 | plot(w3) 31 | 32 | # pass named arguments to specify a different name than the object name 33 | w4 <- stackWorlds(layer1 = w1, layer2 = w2) 34 | 35 | } 36 | \author{ 37 | Sarah Bauduin 38 | } 39 | -------------------------------------------------------------------------------- /man/subHeadings.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{subHeadings} 4 | \alias{subHeadings} 5 | \alias{subHeadings,numeric,numeric-method} 6 | \alias{subHeadings,agentMatrix,numeric-method} 7 | \alias{subHeadings,numeric,agentMatrix-method} 8 | \alias{subHeadings,agentMatrix,agentMatrix-method} 9 | \title{Subtract \code{headings}} 10 | \usage{ 11 | subHeadings(angle1, angle2, range360 = FALSE) 12 | 13 | \S4method{subHeadings}{numeric,numeric}(angle1, angle2, range360 = FALSE) 14 | 15 | \S4method{subHeadings}{agentMatrix,numeric}(angle1, angle2, range360 = FALSE) 16 | 17 | \S4method{subHeadings}{numeric,agentMatrix}(angle1, angle2, range360 = FALSE) 18 | 19 | \S4method{subHeadings}{agentMatrix,agentMatrix}(angle1, angle2, range360 = FALSE) 20 | } 21 | \arguments{ 22 | \item{angle1}{\code{AgentMatrix} object representing the moving \code{agents}, or 23 | 24 | \if{html}{\out{
}}\preformatted{ Numeric. Vector of angles. 25 | }\if{html}{\out{
}}} 26 | 27 | \item{angle2}{\code{AgentMatrix} object representing the moving \code{agents}, or 28 | 29 | \if{html}{\out{
}}\preformatted{ Numeric. Vector of angles. 30 | }\if{html}{\out{
}}} 31 | 32 | \item{range360}{Logical. If \code{range360 = TRUE}, returned values are 33 | between 0 and 360 degrees; 34 | if \code{range360 = FALSE}, returned values are between 35 | -180 and 180 degrees. 36 | Default is \code{range360 = FALSE}.} 37 | } 38 | \value{ 39 | Numeric. Vector of the smallest angles in degrees 40 | by which \code{angle1} could be rotated to produce \code{angle2} 41 | (i.e., the target heading). 42 | } 43 | \description{ 44 | Compute the difference between \code{headings}. 45 | } 46 | \details{ 47 | This function does the opposite as the one in NetLogo where 48 | \code{angle1} is the target heading. 49 | 50 | \if{html}{\out{
}}\preformatted{ `angle1` and `angle2` must be of the same length or if different, 51 | one of them must be of length 1. 52 | 53 | Positive values mean clockwise rotations, negative value mean 54 | counterclockwise rotations. 55 | }\if{html}{\out{
}} 56 | } 57 | \examples{ 58 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 59 | t1 <- createOTurtles(n = 10, world = w1) 60 | subHeadings(angle1 = t1, angle2 = 0) 61 | 62 | } 63 | \references{ 64 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 65 | Center for Connected Learning and Computer-Based Modeling, 66 | Northwestern University. Evanston, IL. 67 | } 68 | \seealso{ 69 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#subtract-headings} 70 | } 71 | \author{ 72 | Sarah Bauduin 73 | } 74 | -------------------------------------------------------------------------------- /man/subsetting.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \docType{methods} 4 | \name{[[,worldArray,ANY,missing-method} 5 | \alias{[[,worldArray,ANY,missing-method} 6 | \alias{[[<-,worldArray,ANY,missing-method} 7 | \alias{$} 8 | \alias{$,worldArray-method} 9 | \title{Subsetting and replacing for \code{worldArray} class} 10 | \usage{ 11 | \S4method{[[}{worldArray,ANY,missing}(x, i) 12 | 13 | \S4method{[[}{worldArray,ANY,missing}(x, i) <- value 14 | 15 | \S4method{$}{worldArray}(x, name) 16 | } 17 | \arguments{ 18 | \item{x}{A \code{worldArray} object.} 19 | 20 | \item{i}{Index number or layer name specifying a subset of layer(s) 21 | from the \code{worldArray}.} 22 | 23 | \item{value}{A replacement \code{worldMatrix} layer for one of the current layers in the 24 | \code{worldArray}.} 25 | 26 | \item{name}{Layer name, normally without back ticks, unless has symbols.} 27 | } 28 | \value{ 29 | The replacement method returns the original object, but with updated elements. 30 | The accessor method extracts the entire layer. 31 | } 32 | \description{ 33 | Subsetting and replacing for \code{worldArray} class 34 | } 35 | \examples{ 36 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = runif(100)) 37 | w2 <- createWorld(0, 9, 0, 9, data = runif(100)) 38 | w3 <- createWorld(0, 9, 0, 9, data = runif(100) + 2) # add 2 so different range 39 | a1 <- stackWorlds(w1, w2) 40 | a1[[2]] 41 | a1[[2]] <- w3 42 | 43 | } 44 | -------------------------------------------------------------------------------- /man/tExist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{tExist} 4 | \alias{tExist} 5 | \alias{tExist,agentMatrix,numeric,missing-method} 6 | \alias{tExist,agentMatrix,numeric,character-method} 7 | \title{Do the \code{turtle} exist?} 8 | \usage{ 9 | tExist(turtles, who, breed) 10 | 11 | \S4method{tExist}{agentMatrix,numeric,missing}(turtles, who) 12 | 13 | \S4method{tExist}{agentMatrix,numeric,character}(turtles, who, breed) 14 | } 15 | \arguments{ 16 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 17 | 18 | \item{who}{Integer. Vector of the \code{who} numbers for the selected \code{turtles}.} 19 | 20 | \item{breed}{Characters. Vector of \code{breed} names for the selected \code{turtles}. 21 | If missing, there is no distinction based upon \code{breed}.} 22 | } 23 | \value{ 24 | Logical. Vector of \code{TRUE} or \code{FALSE} if the \code{who} numbers 25 | with any of the \code{breed}, if provided, exist or not 26 | inside the \code{turtles}. 27 | } 28 | \description{ 29 | Report \code{TRUE} if a \code{turtle} exists inside the \code{turtles}, report 30 | \code{FALSE} otherwise. 31 | } 32 | \examples{ 33 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 34 | t1 <- createTurtles( 35 | n = 10, coords = randomXYcor(w1, n = 10), 36 | breed = c(rep("sheep", 5), rep("wolf", 5)) 37 | ) 38 | tExist(turtles = t1, who = 3, breed = "sheep") 39 | tExist(turtles = t1, who = 9, breed = "sheep") 40 | tExist(turtles = t1, who = 9, breed = c("sheep", "wolf")) 41 | tExist(turtles = t1, who = c(3, 9)) 42 | 43 | } 44 | \references{ 45 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 46 | Center for Connected Learning and Computer-Based Modeling, 47 | Northwestern University. Evanston, IL. 48 | } 49 | \seealso{ 50 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#member} 51 | } 52 | \author{ 53 | Sarah Bauduin 54 | } 55 | -------------------------------------------------------------------------------- /man/turtle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{turtle} 4 | \alias{turtle} 5 | \alias{turtle,agentMatrix,numeric,missing-method} 6 | \alias{turtle,agentMatrix,numeric,character-method} 7 | \title{Select \code{turtles}} 8 | \usage{ 9 | turtle(turtles, who, breed) 10 | 11 | \S4method{turtle}{agentMatrix,numeric,missing}(turtles, who) 12 | 13 | \S4method{turtle}{agentMatrix,numeric,character}(turtles, who, breed) 14 | } 15 | \arguments{ 16 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 17 | 18 | \item{who}{Integer. Vector of the \code{who} numbers for the selected \code{turtles}.} 19 | 20 | \item{breed}{Characters. Vector of \code{breed} names for the selected \code{turtles}. 21 | If missing, there is no distinction based upon \code{breed}.} 22 | } 23 | \value{ 24 | \code{AgentMatrix} of the selected \code{turtles} sorted in the order of 25 | the \code{who} numbers requested. If \code{breed} was provided, the 26 | \code{turtles} selected are of one of the \code{breed}. 27 | } 28 | \description{ 29 | Report the individuals among \code{turtles} based on their \code{who} numbers 30 | and \code{breed}. 31 | } 32 | \details{ 33 | If no \code{turtle} matches the given \code{who} numbers, with potentially 34 | one of the given 35 | \code{breed}, inside \code{turtles}, then an empty \code{agentMatrix} is returned. 36 | 37 | \if{html}{\out{
}}\preformatted{ If there are duplicates `who` numbers among the `turtles`, the first 38 | matching `turtle` with the requested `who` number is returned. 39 | }\if{html}{\out{
}} 40 | } 41 | \examples{ 42 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 43 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 44 | t2 <- turtle(t1, who = 2) 45 | 46 | } 47 | \references{ 48 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 49 | Center for Connected Learning and Computer-Based Modeling, 50 | Northwestern University. Evanston, IL. 51 | } 52 | \seealso{ 53 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#turtle} 54 | } 55 | \author{ 56 | Sarah Bauduin 57 | } 58 | -------------------------------------------------------------------------------- /man/turtleSet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{turtleSet} 4 | \alias{turtleSet} 5 | \alias{turtleSet,agentMatrix-method} 6 | \title{Create a \code{turtle} \code{agentset}} 7 | \usage{ 8 | turtleSet(...) 9 | 10 | \S4method{turtleSet}{agentMatrix}(...) 11 | } 12 | \arguments{ 13 | \item{...}{\code{AgentMatrix} objects representing the moving \code{agents}.} 14 | } 15 | \value{ 16 | \code{AgentMatrix} object containing all the unique \code{turtles}. 17 | } 18 | \description{ 19 | Report a \code{turtle} \code{agentset} containing all unique \code{turtles} provided in the inputs. 20 | } 21 | \details{ 22 | Duplicated \code{turtles} are identified based only on their \code{who} numbers. 23 | The \code{turtle} chosen for a who number is the first one given in the inputs. 24 | To keep all \code{turtles} from the inputs, use \code{NLset()} to 25 | reassign \code{who} numbers in some of the inputs, prior using 26 | \code{turtleSet()}, to avoid \code{turtles} with duplicated \code{who} numbers. 27 | } 28 | \examples{ 29 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9) 30 | t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10), breed = "sheep") 31 | t2 <- createTurtles(n = 2, coords = randomXYcor(w1, n = 2), breed = "wolf") 32 | t2 <- NLset(turtles = t2, agents = t2, var = "who", val = c(10, 11)) 33 | t3 <- createTurtles(n = 1, coords = randomXYcor(w1, n = 1), breed = "sheperd") 34 | t3 <- NLset(turtles = t3, agents = t3, var = "who", val = 12) 35 | t4 <- turtleSet(t1, t2, t3) 36 | 37 | } 38 | \references{ 39 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 40 | Center for Connected Learning and Computer-Based Modeling, 41 | Northwestern University. Evanston, IL. 42 | } 43 | \seealso{ 44 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#turtle-set} 45 | } 46 | \author{ 47 | Sarah Bauduin 48 | } 49 | -------------------------------------------------------------------------------- /man/turtles2sf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{turtles2sf} 4 | \alias{turtles2sf} 5 | \alias{turtles2sf,ANY-method} 6 | \title{From \code{agentMatrix} to \code{sf}} 7 | \usage{ 8 | turtles2sf(turtles) 9 | 10 | \S4method{turtles2sf}{ANY}(turtles) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | } 15 | \value{ 16 | \code{sf} object of \verb{POINT geometry} representing the moving \code{agents} 17 | (coordinates and data) 18 | as contained in \code{turtles}. 19 | } 20 | \description{ 21 | Convert an \code{agentMatrix} object into an \code{sf} object. 22 | } 23 | \examples{ 24 | t1 <- createTurtles(n = 10, coords = cbind(xcor = 1:10, ycor = 1:10)) 25 | if (requireNamespace("sf", quietly = TRUE)) { 26 | sf_t1 <- turtles2sf(turtles = t1) 27 | } 28 | 29 | } 30 | \author{ 31 | Sarah Bauduin 32 | } 33 | -------------------------------------------------------------------------------- /man/turtles2spdf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{turtles2spdf} 4 | \alias{turtles2spdf} 5 | \alias{turtles2spdf,agentMatrix-method} 6 | \title{From \code{agentMatrix} to \code{SpatialPointsDataFrame}} 7 | \usage{ 8 | turtles2spdf(turtles) 9 | 10 | \S4method{turtles2spdf}{agentMatrix}(turtles) 11 | } 12 | \arguments{ 13 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 14 | } 15 | \value{ 16 | \code{SpatialPointsDataFrame} object representing the moving \code{agents} 17 | (coordinates and data) 18 | as contained in \code{turtles}. 19 | } 20 | \description{ 21 | Convert an \code{agentMatrix} object into a \code{SpatialPointsDataFrame} object. 22 | } 23 | \examples{ 24 | t1 <- createTurtles(n = 10, coords = cbind(xcor = 1:10, ycor = 1:10)) 25 | if (requireNamespace("sp", quietly = TRUE)) { 26 | sp1 <- turtles2spdf(turtles = t1) 27 | } 28 | 29 | } 30 | \author{ 31 | Sarah Bauduin 32 | } 33 | -------------------------------------------------------------------------------- /man/turtlesOn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{turtlesOn} 4 | \alias{turtlesOn} 5 | \alias{turtlesOn,worldNLR,agentMatrix,matrix,missing-method} 6 | \alias{turtlesOn,worldNLR,agentMatrix,matrix,character-method} 7 | \title{\code{Turtles} on} 8 | \usage{ 9 | turtlesOn(world, turtles, agents, breed, simplify = TRUE) 10 | 11 | \S4method{turtlesOn}{worldNLR,agentMatrix,matrix,missing}(world, turtles, agents, simplify) 12 | 13 | \S4method{turtlesOn}{worldNLR,agentMatrix,matrix,character}(world, turtles, agents, breed, simplify = TRUE) 14 | } 15 | \arguments{ 16 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 17 | 18 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 19 | 20 | \item{agents}{Matrix (\code{ncol} = 2) with the first column \code{pxcor} and the second 21 | column \code{pycor} representing the \code{patches} coordinates, or 22 | 23 | \if{html}{\out{
}}\preformatted{ `AgentMatrix` object representing the moving `agents`. 24 | }\if{html}{\out{
}}} 25 | 26 | \item{breed}{Characters. Vector of \code{breed} names for the selected \code{turtles}. 27 | If missing, there is no distinction based upon \code{breed}.} 28 | 29 | \item{simplify}{Logical. If \code{simplify = TRUE}, all \code{turtles} on the same 30 | \code{patches} as any \code{agents} are returned; if \code{simplify = FALSE}, 31 | the \code{turtles} are evaluated for each \code{agents}'s \code{patches} 32 | individually.} 33 | } 34 | \value{ 35 | \code{AgentMatrix} representing any individuals from \code{turtles} of 36 | any of the given \code{breed}, if specified, 37 | located on the same \code{patches} as any of the \code{agents}, if \code{simplify = TRUE}, or 38 | 39 | \if{html}{\out{
}}\preformatted{ Matrix (`ncol` = 2) with the first column `whoTurtles` and the second column 40 | `id` showing which `turtles` are on the same 41 | `patches` as which `agents` represented by `id`, if `simplify = FALSE`. 42 | `id` represents and follows the order of the `agents`. `id` does not represent 43 | the `who` numbers 44 | of the `agents` if `agents` are `turtles`. 45 | }\if{html}{\out{
}} 46 | } 47 | \description{ 48 | Report the individuals among \code{turtles} that are on the same \code{patches} as 49 | the \code{agents}. 50 | } 51 | \details{ 52 | The \code{agents} must be located inside the 53 | \code{world}'s extent. 54 | } 55 | \examples{ 56 | w1 <- createWorld( 57 | minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, 58 | data = runif(100) 59 | ) 60 | t1 <- createTurtles(n = 500, coords = randomXYcor(w1, n = 500)) 61 | plot(w1) 62 | points(t1, col = of(agents = t1, var = "color"), pch = 16) 63 | 64 | t2 <- turtlesOn(world = w1, turtles = t1, agents = patch(w1, 2, 2)) 65 | 66 | } 67 | \references{ 68 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 69 | Center for Connected Learning and Computer-Based Modeling, 70 | Northwestern University. Evanston, IL. 71 | } 72 | \seealso{ 73 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#turtles-on} 74 | } 75 | \author{ 76 | Sarah Bauduin 77 | } 78 | -------------------------------------------------------------------------------- /man/turtlesOwn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/turtle-functions.R 3 | \name{turtlesOwn} 4 | \alias{turtlesOwn} 5 | \alias{turtlesOwn,agentMatrix,character,missing-method} 6 | \alias{turtlesOwn,agentMatrix,character,ANY-method} 7 | \title{New \code{turtles} variable} 8 | \usage{ 9 | turtlesOwn(turtles, tVar, tVal) 10 | 11 | \S4method{turtlesOwn}{agentMatrix,character,missing}(turtles, tVar) 12 | 13 | \S4method{turtlesOwn}{agentMatrix,character,ANY}(turtles, tVar, tVal) 14 | } 15 | \arguments{ 16 | \item{turtles}{\code{AgentMatrix} object representing the moving \code{agents}.} 17 | 18 | \item{tVar}{Character. the name of the \code{turtles} variable to create.} 19 | 20 | \item{tVal}{Vector representing the values of \code{tVar}. 21 | Must be of length 1 or of length \code{turtles}. 22 | If missing, \code{NA} is given.} 23 | } 24 | \value{ 25 | \code{AgentMatrix} representing the \code{turtles} with the new 26 | variable \code{tVar} added. 27 | } 28 | \description{ 29 | Create a new variable for the \code{turtles}. 30 | } 31 | \examples{ 32 | t1 <- createTurtles(n = 5, coords = cbind(xcor = 0, ycor = 0)) 33 | t1 <- turtlesOwn(turtles = t1, tVar = "sex", tVal = c("F", "F", "F", "M", "M")) 34 | 35 | } 36 | \references{ 37 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 38 | Center for Connected Learning and Computer-Based Modeling, 39 | Northwestern University. Evanston, IL. 40 | } 41 | \seealso{ 42 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#turtles-own} 43 | } 44 | \author{ 45 | Sarah Bauduin 46 | } 47 | -------------------------------------------------------------------------------- /man/updateList.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/spades-functions.R 3 | \name{updateList} 4 | \alias{updateList} 5 | \alias{updateList,list,list-method} 6 | \alias{updateList,NULL,list-method} 7 | \alias{updateList,list,NULL-method} 8 | \alias{updateList,NULL,NULL-method} 9 | \title{Update elements of a named list with elements of a second named list} 10 | \usage{ 11 | updateList(x, y) 12 | 13 | \S4method{updateList}{list,list}(x, y) 14 | 15 | \S4method{updateList}{`NULL`,list}(x, y) 16 | 17 | \S4method{updateList}{list,`NULL`}(x, y) 18 | 19 | \S4method{updateList}{`NULL`,`NULL`}(x, y) 20 | } 21 | \arguments{ 22 | \item{x, y}{a named list} 23 | } 24 | \value{ 25 | A named list, with elements sorted by name. 26 | The values of matching elements in list \code{y} 27 | replace the values in list \code{x}. 28 | } 29 | \description{ 30 | Merge two named list based on their named entries. 31 | Where any element matches in both lists, the value from the second list is 32 | used in the updated list. 33 | Subelements are not examined and are simply replaced. If one list is empty, 34 | then it returns the other one, unchanged. 35 | } 36 | \examples{ 37 | L1 <- list(a = "hst", b = NA_character_, c = 43) 38 | L2 <- list(a = "gst", c = 42, d = list(letters)) 39 | updateList(L1, L2) 40 | 41 | updateList(L1, NULL) 42 | updateList(NULL, L2) 43 | updateList(NULL, NULL) # should return empty list 44 | 45 | } 46 | \author{ 47 | Alex Chubaty 48 | } 49 | -------------------------------------------------------------------------------- /man/world2raster.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{world2raster} 4 | \alias{world2raster} 5 | \alias{world2raster,worldMatrix-method} 6 | \alias{world2raster,worldArray-method} 7 | \title{Convert a \code{worldMatrix} or \code{worldArray} object into a \verb{Raster*} object} 8 | \usage{ 9 | world2raster(world) 10 | 11 | \S4method{world2raster}{worldMatrix}(world) 12 | 13 | \S4method{world2raster}{worldArray}(world) 14 | } 15 | \arguments{ 16 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 17 | } 18 | \value{ 19 | \code{RasterLayer} or \code{RasterStack} object depending on the input \code{world}. 20 | \code{Patches} value are retained from the \code{world}. 21 | } 22 | \description{ 23 | Convert a \code{worldMatrix} object into a \code{RasterLayer} object or a 24 | \code{worldArray} object into a \code{RasterStack} object 25 | } 26 | \details{ 27 | The \verb{Raster*} returned has the same extent and resolution as the \code{world} 28 | with round coordinates at the center of the cells and coordinates \code{x.5} 29 | at the edges of the cells. 30 | } 31 | \examples{ 32 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = runif(100)) 33 | if (requireNamespace("raster", quietly = TRUE)) { 34 | r1 <- world2raster(w1) 35 | terra::plot(r1) 36 | } 37 | 38 | } 39 | \author{ 40 | Sarah Bauduin 41 | } 42 | -------------------------------------------------------------------------------- /man/world2spatRast.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{world2spatRast} 4 | \alias{world2spatRast} 5 | \alias{world2spatRast,worldMatrix-method} 6 | \alias{world2spatRast,worldArray-method} 7 | \title{Convert a \code{worldMatrix} or \code{worldArray} object into a \code{SpatRaster} object} 8 | \usage{ 9 | world2spatRast(world) 10 | 11 | \S4method{world2spatRast}{worldMatrix}(world) 12 | 13 | \S4method{world2spatRast}{worldArray}(world) 14 | } 15 | \arguments{ 16 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 17 | } 18 | \value{ 19 | \code{SpatRaster} object. 20 | \code{Patches} value are retained from the \code{world}. 21 | } 22 | \description{ 23 | Convert a \code{worldMatrix} object or a 24 | \code{worldArray} object into a \code{SpatRaster} object 25 | } 26 | \details{ 27 | The \code{SpatRaster} returned has the same extent and resolution as the \code{world} 28 | with round coordinates at the center of the cells and coordinates \code{x.5} 29 | at the edges of the cells. 30 | } 31 | \examples{ 32 | w1 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = runif(100)) 33 | r1 <- world2spatRast(w1) 34 | terra::plot(r1) 35 | 36 | w2 <- createWorld(minPxcor = 0, maxPxcor = 9, minPycor = 0, maxPycor = 9, data = 0) 37 | w3 <- stackWorlds(w1, w2) 38 | r3 <- world2spatRast(w3) 39 | terra::plot(r3) 40 | 41 | } 42 | \author{ 43 | Sarah Bauduin 44 | } 45 | -------------------------------------------------------------------------------- /man/worldArray-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \docType{class} 4 | \name{worldArray-class} 5 | \alias{worldArray-class} 6 | \alias{worldArray} 7 | \title{The \code{worldArray} class} 8 | \description{ 9 | This is an s4 class extension of \code{array}. 10 | It is a collection of several \code{worldMatrix} objects with the same extent 11 | (i.e., same values for all their slots) stacked together. 12 | It is used to keep more than one value per \code{patch}. 13 | } 14 | \seealso{ 15 | \code{\link[=worldMatrix]{worldMatrix()}} 16 | } 17 | \author{ 18 | Sarah Bauduin, Eliot McIntire, and Alex Chubaty 19 | } 20 | -------------------------------------------------------------------------------- /man/worldHeight.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{worldHeight} 4 | \alias{worldHeight} 5 | \alias{worldHeight,worldNLR-method} 6 | \title{\code{World} height} 7 | \usage{ 8 | worldHeight(world) 9 | 10 | \S4method{worldHeight}{worldNLR}(world) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | } 15 | \value{ 16 | Integer. 17 | } 18 | \description{ 19 | Report the height of the \code{world} in \code{patch} number. 20 | } 21 | \examples{ 22 | w1 <- createWorld() 23 | worldHeight(w1) 24 | 25 | } 26 | \references{ 27 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 28 | Center for Connected Learning and Computer-Based Modeling, 29 | Northwestern University. Evanston, IL. 30 | } 31 | \seealso{ 32 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#world-dim} 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/worldMatrix-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \docType{class} 4 | \name{worldMatrix-class} 5 | \alias{worldMatrix-class} 6 | \alias{worldMatrix} 7 | \title{The \code{worldMatrix} class} 8 | \description{ 9 | This is an s4 class extension of \code{matrix} with 7 additional slots. 10 | A \code{worldMatrix} object can be viewed as a grid composed of squared \code{patches} 11 | (i.e., matrix cells). \code{Patches} have two spatial coordinates \code{pxcor} and 12 | \code{pycor}, representing the location of their center. \code{pxcor} and 13 | \code{pycor} are always integer and increment by 1. \code{pxcor} increases as 14 | you move right and \code{pycor} increases as you move up. \code{pxcor} and 15 | \code{pycor} can be negative if there are \code{patches} to the left or below the \code{patch} 16 | \verb{[pxcor = 0, pycor = 0]}. 17 | } 18 | \details{ 19 | The first four slots of the \code{worldMatrix} are: \code{minPxcor}, \code{maxPxcor}, 20 | \code{minPycor}, \code{maxPycor} which represent the minimum and maximum \code{patches} 21 | coordinates in the \code{worldMatrix}. 22 | The slot \code{extent} is similar to a \verb{Raster*} extent. Because \code{pxcor} 23 | and \code{pycor} represent the spatial location at the center of the \code{patches} and the 24 | resolution of them is 1, the extent of the \code{worldMatrix} is equal to 25 | \code{xmin = minPxcor - 0.5}, \code{xmax = maxPxcor + 0.5}, \code{ymin = minPycor - 0.5}, 26 | and \code{ymax = maxPycor + 0.5}. 27 | The number of \code{patches} in a \code{worldMatrix} is equal to 28 | \code{((maxPxcor - minPxcor) + 1) * ((maxPycor - minPycor) + 1)}. 29 | The slot \code{res} is equal to \code{1} as it is the spatial resolution of the \code{patches}. 30 | The last slot \code{pCoords} is a \code{matrix} representing the \code{patches} coordinates 31 | of all the matrix cells in the order of cells in a \verb{Raster*} (i.e., by rows). 32 | 33 | Careful: The methods \verb{[]} and \verb{[] <-} retrieve or assign values for 34 | the \code{patches} in the given order of the \code{patches} coordinates provided. 35 | When no \code{patches} coordinates are provided, the values retrieved or assigned 36 | is done in the order of the cell numbers as defined in in \verb{Raster*} objects 37 | (i.e., by rows). 38 | } 39 | \references{ 40 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 41 | Center for Connected Learning and Computer-Based Modeling, 42 | Northwestern University. Evanston, IL. 43 | } 44 | \seealso{ 45 | \code{\link[=worldArray]{worldArray()}} 46 | } 47 | \author{ 48 | Sarah Bauduin, Eliot McIntire, and Alex Chubaty 49 | } 50 | -------------------------------------------------------------------------------- /man/worldNLR-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/worldNLR-classes-methods.R 3 | \docType{class} 4 | \name{worldNLR-class} 5 | \alias{worldNLR-class} 6 | \alias{worldNLR} 7 | \title{The \code{worldNLR} class} 8 | \description{ 9 | The \code{worldNLR} class is the union of the \code{worldMatrix} and \code{worldArray} 10 | classes. Mostly used for building function purposes. 11 | } 12 | \author{ 13 | Sarah Bauduin, and Eliot McIntire 14 | } 15 | -------------------------------------------------------------------------------- /man/worldWidth.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/world-functions.R 3 | \name{worldWidth} 4 | \alias{worldWidth} 5 | \alias{worldWidth,worldNLR-method} 6 | \title{\code{World} width} 7 | \usage{ 8 | worldWidth(world) 9 | 10 | \S4method{worldWidth}{worldNLR}(world) 11 | } 12 | \arguments{ 13 | \item{world}{\code{WorldMatrix} or \code{worldArray} object.} 14 | } 15 | \value{ 16 | Integer. 17 | } 18 | \description{ 19 | Report the width of the \code{world} in \code{patch} number. 20 | } 21 | \examples{ 22 | w1 <- createWorld() 23 | worldWidth(w1) 24 | 25 | } 26 | \references{ 27 | Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. 28 | Center for Connected Learning and Computer-Based Modeling, 29 | Northwestern University. Evanston, IL. 30 | } 31 | \seealso{ 32 | \url{https://ccl.northwestern.edu/netlogo/docs/dictionary.html#world-dim} 33 | } 34 | \author{ 35 | Sarah Bauduin 36 | } 37 | -------------------------------------------------------------------------------- /man/wrap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/spades-functions.R 3 | \name{wrap} 4 | \alias{wrap} 5 | \alias{wrap,ANY-method} 6 | \title{Wrap coordinates or pixels in a torus-like fashion} 7 | \usage{ 8 | wrap(obj, bounds, withHeading) 9 | 10 | \S4method{wrap}{ANY}(obj, bounds, withHeading) 11 | } 12 | \arguments{ 13 | \item{obj}{A \verb{SpatialPoints*} object, or matrix of coordinates.} 14 | 15 | \item{bounds}{Either a \verb{Raster*}, \code{Extent}, or \code{bbox} object 16 | defining bounds to wrap around.} 17 | 18 | \item{withHeading}{Logical. If \code{TRUE}, then the previous points must be 19 | wrapped also so that the subsequent heading calculation will work. 20 | Default \code{FALSE}. See details.} 21 | } 22 | \value{ 23 | Same class as \code{obj}, but with coordinates updated to reflect the wrapping. 24 | } 25 | \description{ 26 | Generally for model development purposes. 27 | } 28 | \details{ 29 | If \code{withHeading} used, then obj must be a \code{SpatialPointsDataFrame} 30 | that contains two columns, \code{x1} and \code{y1}, with the immediately previous 31 | agent locations. 32 | } 33 | \examples{ 34 | if (requireNamespace("terra")) { 35 | xrange <- yrange <- c(-50, 50) 36 | hab <- terra::rast(terra::ext(c(xrange, yrange))) 37 | hab[] <- runif(terra::ncell(hab)) 38 | 39 | # initialize agents 40 | N <- 10 41 | 42 | # previous points 43 | x1 <- rep(0, N) 44 | y1 <- rep(0, N) 45 | # initial points 46 | starts <- cbind( 47 | x = stats::runif(N, xrange[1], xrange[2]), 48 | y = stats::runif(N, yrange[1], yrange[2]) 49 | ) 50 | 51 | # create the agent object 52 | agent <- agentMatrix(coords = starts, data = data.frame(x1 = x1, y1 = y1)) 53 | 54 | ln <- rlnorm(N, 1, 0.02) # log normal step length 55 | sd <- 30 # could be specified globally in params 56 | 57 | if (interactive()) { 58 | library(quickPlot) 59 | clearPlot() 60 | Plot(hab, zero.color = "white", axes = "L") 61 | Plot(agent, addTo = "hab") 62 | } 63 | if (requireNamespace("SpaDES.tools") && 64 | requireNamespace("CircStats")) { 65 | for (i in 1:10) { 66 | agent <- SpaDES.tools::crw( 67 | agent = agent, 68 | extent = terra::ext(hab), stepLength = ln, 69 | stddev = sd, lonlat = FALSE, torus = TRUE 70 | ) 71 | if (interactive()) Plot(agent, addTo = "hab", axes = TRUE) 72 | } 73 | } 74 | } 75 | } 76 | \author{ 77 | Eliot McIntire 78 | } 79 | -------------------------------------------------------------------------------- /revdep/.gitignore: -------------------------------------------------------------------------------- 1 | checks 2 | checks.noindex 3 | data.sqlite 4 | library 5 | library.noindex 6 | *.html 7 | -------------------------------------------------------------------------------- /revdep/README.md: -------------------------------------------------------------------------------- 1 | # Platform 2 | 3 | |field |value | 4 | |:--------|:-----------------------------------------| 5 | |version |R version 4.2.1 (2022-06-23) | 6 | |os |Ubuntu 20.04.4 LTS | 7 | |system |x86_64, linux-gnu | 8 | |ui |RStudio | 9 | |language |en_CA:en | 10 | |collate |en_CA.UTF-8 | 11 | |ctype |en_CA.UTF-8 | 12 | |tz |America/Edmonton | 13 | |date |2022-08-16 | 14 | |rstudio |2022.07.1+554 Spotted Wakerobin (desktop) | 15 | |pandoc |2.5 @ /usr/bin/pandoc | 16 | 17 | # Dependencies 18 | 19 | |package |old |new |Δ | 20 | |:------------|:------|:------|:--| 21 | |NetLogoR |0.3.10 |0.3.11 |* | 22 | |abind |1.4-5 |1.4-5 | | 23 | |backports |1.4.1 |1.4.1 | | 24 | |checkmate |2.1.0 |2.1.0 | | 25 | |CircStats |0.2-6 |0.2-6 | | 26 | |classInt |NA |0.4-7 |* | 27 | |cli |3.3.0 |3.3.0 | | 28 | |colorspace |2.0-3 |2.0-3 | | 29 | |data.table |1.14.2 |1.14.2 | | 30 | |DBI |NA |1.1.3 |* | 31 | |digest |0.6.29 |0.6.29 | | 32 | |e1071 |NA |1.7-11 |* | 33 | |fansi |1.0.3 |1.0.3 | | 34 | |farver |2.1.1 |2.1.1 | | 35 | |fastmatch |1.1-3 |1.1-3 | | 36 | |fpCompare |0.2.4 |0.2.4 | | 37 | |ggplot2 |3.3.6 |3.3.6 | | 38 | |glue |1.6.2 |1.6.2 | | 39 | |gridBase |0.4-7 |0.4-7 | | 40 | |gtable |0.3.0 |0.3.0 | | 41 | |igraph |1.3.4 |1.3.4 | | 42 | |isoband |0.2.5 |0.2.5 | | 43 | |labeling |0.4.2 |0.4.2 | | 44 | |lifecycle |1.0.1 |1.0.1 | | 45 | |magrittr |2.0.3 |2.0.3 | | 46 | |matrixStats |0.62.0 |0.62.0 | | 47 | |munsell |0.5.0 |0.5.0 | | 48 | |pillar |1.8.0 |1.8.0 | | 49 | |pkgconfig |2.0.3 |2.0.3 | | 50 | |proxy |NA |0.4-27 |* | 51 | |quickPlot |0.1.6 |0.1.6 | | 52 | |R6 |2.5.1 |2.5.1 | | 53 | |raster |3.5-29 |3.5-29 | | 54 | |RColorBrewer |1.1-3 |1.1-3 | | 55 | |Rcpp |1.0.9 |1.0.9 | | 56 | |remotes |2.4.2 |2.4.2 | | 57 | |Require |0.0.13 |0.0.13 | | 58 | |rgdal |1.5-32 |1.5-32 | | 59 | |rgeos |0.5-9 |0.5-9 | | 60 | |rlang |1.0.4 |1.0.4 | | 61 | |s2 |NA |1.1.0 |* | 62 | |scales |1.2.0 |1.2.0 | | 63 | |sf |NA |1.0-8 |* | 64 | |sp |1.5-0 |1.5-0 | | 65 | |SpaDES.tools |1.0.0 |1.0.0 | | 66 | |terra |1.6-7 |1.6-7 | | 67 | |tibble |3.1.8 |3.1.8 | | 68 | |units |NA |0.8-0 |* | 69 | |utf8 |1.2.2 |1.2.2 | | 70 | |vctrs |0.4.1 |0.4.1 | | 71 | |viridisLite |0.4.0 |0.4.0 | | 72 | |withr |2.5.0 |2.5.0 | | 73 | |wk |NA |0.6.0 |* | 74 | 75 | # Revdeps 76 | 77 | -------------------------------------------------------------------------------- /revdep/check.R: -------------------------------------------------------------------------------- 1 | #devtools::install_github("r-lib/revdepcheck") 2 | library("revdepcheck") 3 | 4 | options(repos = c(CRAN = 'https://cloud.r-project.org')) 5 | 6 | revdepcheck::revdep_reset() 7 | revdepcheck::revdep_check(num_workers = getOption("Ncpus", 4), timeout = 30*60) ## 30 mins 8 | revdepcheck::revdep_report_cran() ## update cran-comments with this output 9 | 10 | ### email maintainers of revdep packages (need to edit: `revdep/email.yml`) 11 | #revdep_email(type = "broken") ## will send via gmail 12 | #revdep_email(type = "failed") ## will send via gmail 13 | -------------------------------------------------------------------------------- /revdep/checks.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/NetLogoR/30be6134d79a10dc627cf21a3e83aad5658648b5/revdep/checks.rds -------------------------------------------------------------------------------- /revdep/cran.md: -------------------------------------------------------------------------------- 1 | ## revdepcheck results 2 | 3 | We checked 0 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. 4 | 5 | * We saw 0 new problems 6 | * We failed to check 0 packages 7 | 8 | -------------------------------------------------------------------------------- /revdep/email.yml: -------------------------------------------------------------------------------- 1 | release_date: ??? 2 | rel_release_date: ??? 3 | my_news_url: ??? 4 | release_version: ??? 5 | release_details: ??? 6 | -------------------------------------------------------------------------------- /revdep/failures.md: -------------------------------------------------------------------------------- 1 | *Wow, no problems at all. :)* -------------------------------------------------------------------------------- /revdep/problems.md: -------------------------------------------------------------------------------- 1 | *Wow, no problems at all. :)* -------------------------------------------------------------------------------- /revdep/timing.md: -------------------------------------------------------------------------------- 1 | # Check times 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tests/test-all.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | test_check("NetLogoR") 3 | # to test manually, use test_package("NetLogoR") 4 | -------------------------------------------------------------------------------- /tests/testthat/setup.R: -------------------------------------------------------------------------------- 1 | library(data.table) 2 | origDTthreads <- getDTthreads() 3 | if (!identical(Sys.getenv("NOT_CRAN"), "true")) { # this asks "is this test running on CRAN" 4 | Sys.setenv("OMP_THREAD_LIMIT" = 1) 5 | withr::defer( 6 | { 7 | data.table::setDTthreads(origDTthreads) 8 | }, 9 | teardown_env() 10 | ) 11 | } 12 | setDTthreads() # this triggers data.table to read the OMP_THREAD_LIMIT 13 | --------------------------------------------------------------------------------