Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
eeholmes committed Dec 5, 2023
2 parents 3c598c9 + ffb1783 commit 4f7e73b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
16 changes: 16 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,14 @@ <h4>Posit Webinars</h4>
<p>See the “Search past events” tab and our <a href="https://docs.google.com/document/d/1mrgtrSXVtPCTxrpBa_0ZbxEsnK9vcQzs6RIV3f-OTPw/edit?usp=sharing">Past meeting notes</a> for info on past events and links to things like notes and video for past events.</p>
<p><br/></p>
<ul>
<li><strong>Nov 7 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Trick and treat in R!: Discussion and code sharing and Posit Conf Digest (with Brian Fadely)</li>
<li><strong>Sep 26 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> {CiteSource} R package with Trevor Riley from Central Library.</li>
<li><strong>Aug 15 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Test R code with {testthat}.</li>
<li><strong>Jul 25 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Intro to Template Model Builder (TMB) with Andrea Havron.</li>
<li><strong>Jun 27 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Beginner Docker for R users with Eli Holmes (NWFSC)</li>
<li><strong>May 23 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Using the NOAA Fisheries Integrated Toolbox (NOAA FIT) with Kathryn Doering (OST)</li>
<li><strong>May 2 2023 12-1pm PT. NMFS R UG Monthly Meeting</strong> Citations in the R ecosystem.</li>
<li><strong>March 28 2023 12-1pm PT. NMFS R UG Monthly Meeting</strong> Natural Language Processing guest speaker, Brandon Kopp, Bureau of Labor Statistics</li>
<li><strong>March 14 2023 11-12pm PDT. NMFS Posit Webinar</strong> Shiny and html widgets. <a href="https://github.com/nmfs-opensci/posit-webinar-series">See the series repo for the recording</a></li>
<li><strong>Feb 28 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Connecting to REST APIs in R <a href="https://docs.google.com/document/d/1mrgtrSXVtPCTxrpBa_0ZbxEsnK9vcQzs6RIV3f-OTPw/edit?usp=sharing">Meeting Notes (NOAA restricted)</a> <a href="https://youtu.be/uXqWFZj-_2E">Video 1 httr::GET</a> <a href="https://youtu.be/x3LQ1pQ4nvY">Video 2 making an R client</a></li>
<li><strong>Feb 14 2023 11-12pm PDT. NMFS Posit Webinar</strong> Quarto for Reproducible Reports. <a href="https://colorado.posit.co/rsc/quarto-reporting/quarto-for-reporting.html">Slides</a> <a href="https://github.com/jeremy-allen/posit-webinar-series/tree/main/03-quarto">Materials on GitHub</a></li>
Expand Down Expand Up @@ -1109,6 +1117,14 @@ <h4>Posit Webinars</h4>
<p>See the “Search past events” tab and our <a href="https://docs.google.com/document/d/1mrgtrSXVtPCTxrpBa_0ZbxEsnK9vcQzs6RIV3f-OTPw/edit?usp=sharing">Past meeting notes</a> for info on past events and links to things like notes and video for past events.</p>
<p><br/></p>
<ul>
<li><strong>Nov 7 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Trick and treat in R!: Discussion and code sharing and Posit Conf Digest (with Brian Fadely)</li>
<li><strong>Sep 26 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> {CiteSource} R package with Trevor Riley from Central Library.</li>
<li><strong>Aug 15 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Test R code with {testthat}.</li>
<li><strong>Jul 25 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Intro to Template Model Builder (TMB) with Andrea Havron.</li>
<li><strong>Jun 27 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Beginner Docker for R users with Eli Holmes (NWFSC)</li>
<li><strong>May 23 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Using the NOAA Fisheries Integrated Toolbox (NOAA FIT) with Kathryn Doering (OST)</li>
<li><strong>May 2 2023 12-1pm PT. NMFS R UG Monthly Meeting</strong> Citations in the R ecosystem.</li>
<li><strong>March 28 2023 12-1pm PT. NMFS R UG Monthly Meeting</strong> Natural Language Processing guest speaker, Brandon Kopp, Bureau of Labor Statistics</li>
<li><strong>March 14 2023 11-12pm PDT. NMFS Posit Webinar</strong> Shiny and html widgets. <a href="https://github.com/nmfs-opensci/posit-webinar-series">See the series repo for the recording</a></li>
<li><strong>Feb 28 2023 12-1pm PDT. NMFS R UG Monthly Meeting</strong> Connecting to REST APIs in R <a href="https://docs.google.com/document/d/1mrgtrSXVtPCTxrpBa_0ZbxEsnK9vcQzs6RIV3f-OTPw/edit?usp=sharing">Meeting Notes (NOAA restricted)</a> <a href="https://youtu.be/uXqWFZj-_2E">Video 1 httr::GET</a> <a href="https://youtu.be/x3LQ1pQ4nvY">Video 2 making an R client</a></li>
<li><strong>Feb 14 2023 11-12pm PDT. NMFS Posit Webinar</strong> Quarto for Reproducible Reports. <a href="https://colorado.posit.co/rsc/quarto-reporting/quarto-for-reporting.html">Slides</a> <a href="https://github.com/jeremy-allen/posit-webinar-series/tree/main/03-quarto">Materials on GitHub</a></li>
Expand Down
4 changes: 2 additions & 2 deletions docs/posts/posts.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"contents": "\nThis is for vdiffr version 1.0.2.9000. The package is in development so syntax and behavior is likely to change. Read the testing chapter in the R packages book for background on writing tests for R packages.\nTests to compare two images\nhttps://vdiffr.r-lib.org/ is a package that integrates with the testthat package to allow tests that compare plot outputs.\nSetting up your package for unit testing\nusethis::use_testthat()\nMakes the tests folder and testthat subfolder.\nWithin the testthat folder,\nusethis::use_test(name=\"xyz\")\nThis will make a test file test-xyz.R in the testthis subfolder. When you make your own test files, replace “xyz” with your test name.\nTo run the tests, you can open test-xyz.R in RStudio and it will recognize that this is a test file. “Run tests” will show up on the upper right of the file.\nsnapshot workflow\nThe first time that you run expect_doppelganger(\"xyz\", plt1) within a test_that() call, a snapshot expectation will run and a svg of plt1 will be made in tests/testthat/_snaps/xyz called xyz.svg. The next time expect_doppelganger(\"xyz\", plt2) is run within a test_that() call, a svg of plt2 will be made and compared to xyz.svg. If it is different, the file xyz.new.svg will be made in tests/testthat/_snaps/xyz.\nBecause of this workflow, we want to make sure tests/testthat/_snaps/xyz is empty before we start because we have to run expect_doppelganger(\"xyz\", plt1) to create xyz.svg but if xyz.svg is already there from previous tests, we might end up creating xyz.new.svg if plt1 is a different plot than xyz.svg.\nThe full test-xyz.R test file is below. Here I break down the parts of that file.\nHeader\nGive some info about the tests (context), load packages, and then clean up the _snaps folder. Having old svgs there can mess up your tests.\ncontext(\"xyz\")\nlibrary(ggplot2)\nlibrary(vdiffr)\n\n# Clean up the _snaps folder for this test file\n# Note this won't be necessary in some situations\nfils <- dir(file.path(here::here(), \"tests\", \"testthat\", \"_snaps\", \"xyz\"), full.names = TRUE)\nfile.remove(fils)\nCompare two ggplots plot\nHere is the contents of test-xyz.R to compare two plots. This test should fail because the plots are different.\nStep 1 make first plot and run expect_doppelganger() to create a svg file in _snaps that is used to compare against. The name of the file is the first argument and must be the same in the expect_doppelganger() calls.\nplt <- ggplot(mtcars, aes(mpg)) + geom_histogram()\n# Save as ggplot-test1.svg in _snaps folder\n# This will appear as a successful test, i.e. plot successfully created\ntest_that(\"setup\", {\n expect_doppelganger(\"ggplot-test1\", plt)\n})\nStep 2. Create 2nd plot and compare to ggplot-test1.svg already in _snaps folder.\nplt <- ggplot(mtcars, aes(disp)) + geom_histogram()\ntest_that(\"plots are different\", {\n expect_doppelganger(\"ggplot-test1\", plt)\n})\nSince they are different, you will see ggplot-test1.new.svg in the _snaps folder.\nCompare two base plots\nThe syntax here is a little different. The object that you pass into expect_doppelganger() as the second argument is a function that creates the base plot. Otherwise the steps are the same.\nplt <- function(){ hist(mtcars$mpg) }\n# Step 1. Create base-test.svg\n# This will appear as a successful test, i.e. plot successfully created\ntest_that(\"setup\", {\n expect_doppelganger(\"base-test\", plt)\n})\n# Step 2. Test new plot against base-test.svg\n# Test will fail since they are different\nplt <- function(){ hist(mtcars$disp) }\ntest_that(\"plots are different\", {\n expect_doppelganger(\"base-test\", plt)\n})\nFinal test-xyz.R file\nThis should be in the testthat folder in tests folder. Running this will show 2 Fails and 4 Passes. To run, you can open the file in RStudio and look for the “Run Tests” button in top right of file. Or run this code.\nfil <- file.path(here::here(), \"tests\", \"testthat\", \"test-xyz.R\")\ntestthat::test_file(fil)\nOr open the file in RStudio and run this code:\ndevtools::test_active_file()\nThe full test file.\ncontext(\"xyz\")\nlibrary(ggplot2)\nlibrary(vdiffr)\n\n# Clean up the _snaps folder for this test file\n# Note this won't be necessary in some situations\nfils <- dir(file.path(here::here(), \"tests\", \"testthat\", \"_snaps\", \"xyz\"), full.names = TRUE)\nfile.remove(fils)\n\n# This test should fail. The plots are different\n# Step 1 make first plot\nplt <- ggplot(mtcars, aes(mpg)) + geom_histogram()\n# Save as ggplot-test1.svg in _snaps folder\n# This will appear as a successful test, i.e. plot successfully created\ntest_that(\"setup\", {\n expect_doppelganger(\"ggplot-test1\", plt)\n})\n# Step 2. Create 2nd plot and compare to ggplot-test1.svg in _snaps folder\nplt <- ggplot(mtcars, aes(disp)) + geom_histogram()\ntest_that(\"plots are different\", {\n expect_doppelganger(\"ggplot-test1\", plt)\n})\n# Since they are different, you will see ggplot-test1.new.svg in the _snaps folder\n\n# This test should not fail. The plots should be the same.\nfun <- function(dat){ return(ggplot(dat, aes(mpg)) + geom_histogram()) }\nplt <- fun(mtcars)\n# Step 1. Create ggplot-test2.svg\n# This will appear as a successful test, i.e. plot successfully created\ntest_that(\"setup\", {\n expect_doppelganger(\"ggplot-test2\", plt)\n})\n# Step 2. Test new plot against ggplot-test2.svg\nplt <- fun(na.omit(mtcars))\ntest_that(\"plots are the same\", {\n expect_doppelganger(\"ggplot-test2\", plt)\n})\n# Since they are the same, you will NOT see ggplot-test2.new.svg in the _snaps folder\n\n# Comparing plots made with base graphics; Create a function that makes the plot\nplt <- function(){ hist(mtcars$mpg) }\n# Step 1. Create base-test.svg\n# This will appear as a successful test, i.e. plot successfully created\ntest_that(\"setup\", {\n expect_doppelganger(\"base-test\", plt)\n})\n# Step 2. Test new plot against base-test.svg\n# Test will fail since they are different\nplt <- function(){ hist(mtcars$disp) }\ntest_that(\"plots are different\", {\n expect_doppelganger(\"base-test\", plt)\n})\n\n\n\n",
"preview": {},
"last_modified": "2023-12-05T20:39:28+00:00",
"last_modified": "2023-12-05T20:49:43+00:00",
"input_file": {}
},
{
Expand All @@ -33,7 +33,7 @@
"categories": [],
"contents": "\nThe R-Govys blog is a place for R-Govys users to post write-ups on topics of interest to the group. Suggestions:\nExample of using R in your work\nExample of a new R feature or package\nDiscussion of changes in how R is used in government\nWrite-up of a meeting review or summary\n\n\n\n",
"preview": {},
"last_modified": "2023-12-05T20:39:28+00:00",
"last_modified": "2023-12-05T20:49:43+00:00",
"input_file": {}
}
]
14 changes: 7 additions & 7 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" version="1.0">
<url>
<loc>https://nmfs-opensci.github.io/NMFS-R-UG/</loc>
<lastmod>2023-12-05T20:39:28+00:00</lastmod>
<lastmod>2023-12-05T20:49:43+00:00</lastmod>
</url>
<url>
<loc>https://nmfs-opensci.github.io/NMFS-R-UG/Meetings.html</loc>
<lastmod>2023-12-05T20:39:28+00:00</lastmod>
<lastmod>2023-12-05T20:49:43+00:00</lastmod>
</url>
<url>
<loc>https://nmfs-opensci.github.io/NMFS-R-UG/posts.html</loc>
<lastmod>2023-12-05T20:39:28+00:00</lastmod>
<lastmod>2023-12-05T20:49:43+00:00</lastmod>
</url>
<url>
<loc>https://nmfs-opensci.github.io/NMFS-R-UG/resources.html</loc>
<lastmod>2023-12-05T20:39:28+00:00</lastmod>
<lastmod>2023-12-05T20:49:43+00:00</lastmod>
</url>
<url>
<loc>https://nmfs-opensci.github.io/NMFS-R-UG/workshops.html</loc>
<lastmod>2023-12-05T20:39:28+00:00</lastmod>
<lastmod>2023-12-05T20:49:43+00:00</lastmod>
</url>
<url>
<loc>https://nmfs-opensci.github.io/NMFS-R-UG/posts/2021-09-28-vdiffr/</loc>
<lastmod>2023-12-05T20:39:28+00:00</lastmod>
<lastmod>2023-12-05T20:49:43+00:00</lastmod>
</url>
<url>
<loc>https://nmfs-opensci.github.io/NMFS-R-UG/posts/2021-09-15-welcome/</loc>
<lastmod>2023-12-05T20:39:28+00:00</lastmod>
<lastmod>2023-12-05T20:49:43+00:00</lastmod>
</url>
</urlset>

0 comments on commit 4f7e73b

Please sign in to comment.