diff --git a/.Rbuildignore b/.Rbuildignore index bc7ae5d..f785dd9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,7 +1,6 @@ ^.*\.Rproj$ ^\.Rproj\.user$ ^scripts$ -cache_test_data ^README\.Rmd$ ^cran-comments\.md$ ^CRAN-RELEASE$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index f2a4d8b..0f8f734 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -36,7 +36,7 @@ jobs: steps: # https://github.com/actions/checkout - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # https://github.com/r-lib/actions/tree/v2/setup-pandoc - uses: r-lib/actions/setup-pandoc@v2 @@ -51,7 +51,7 @@ jobs: # https://github.com/r-lib/actions/tree/v2/setup-r-dependencies - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::rcmdcheck + extra-packages: any::rcmdcheck, lme4?source, UCLATALL/JMRData needs: check # https://github.com/r-lib/actions/tree/v2/check-r-package diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 1675310..17c118b 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -14,7 +14,7 @@ jobs: steps: # https://github.com/actions/checkout - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # https://github.com/r-lib/actions/tree/v2/setup-r - uses: r-lib/actions/setup-r@v2 @@ -24,7 +24,7 @@ jobs: # https://github.com/r-lib/actions/tree/v2/setup-r-dependencies - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::covr + extra-packages: any::covr, lme4?source, UCLATALL/JMRData needs: coverage - name: Test coverage diff --git a/.gitignore b/.gitignore index 3f63f40..8ac522d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,8 @@ .Ruserdata .Rapp.history +# CRAN +CRAN-SUBMISSION + # Mac file .DS_Store diff --git a/.lintr b/.lintr index b988ac0..93a847a 100644 --- a/.lintr +++ b/.lintr @@ -1,7 +1,8 @@ linters: linters_with_defaults( - line_length_linter(100), + line_length_linter(100), commented_code_linter = NULL, - object_usage_linter = NULL + object_usage_linter = NULL, + T_and_F_symbol_linter = NULL ) exclusions: list( "DESCRIPTION", diff --git a/DESCRIPTION b/DESCRIPTION index 8b8008b..9547255 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,10 @@ Type: Package Package: supernova Title: Judd, McClelland, & Ryan Formatting for ANOVA Output -Version: 2.5.8 -Date: 2023-11-03 +Version: 3.0.0 +Date: 2024-02-06 Authors@R: c( - person("Adam", "Blake", , "adamblake@g.ucla.edu", role = c("cre", "aut"), + person("Adam", "Blake", , "adam@coursekata.org", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-7881-8652")), person("Jeff", "Chrabaszcz", role = "aut"), person("Ji", "Son", , "json2@calstatela.edu", role = "aut", @@ -16,17 +16,13 @@ Description: Produces ANOVA tables in the format used by Judd, McClelland, and Ryan (2017, ISBN: 978-1138819832) in their introductory textbook, Data Analysis. This includes proportional reduction in error and formatting to improve ease the transition between the book and R. -License: AGPL (>= 3) +License: GPL (>= 3) URL: https://github.com/UCLATALL/supernova BugReports: https://github.com/UCLATALL/supernova/issues Depends: R (>= 3.4.0) Imports: - backports, cli, - ggplot2, - lifecycle, - magrittr, methods, pillar (>= 1.5.0), purrr, @@ -37,8 +33,13 @@ Imports: Suggests: car, covr, + dplyr (>= 1.0.0), + ggplot2, lintr, lme4, + magrittr, + readr, + remotes, testthat (>= 2.1.0), tidyr, vdiffr @@ -46,4 +47,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: yes Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/LICENSE.md b/LICENSE.md index fab6548..175443c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,659 +1,595 @@ -GNU Affero General Public License -================================= +GNU General Public License +========================== -_Version 3, 19 November 2007_ -_Copyright (C) 2007 Free Software Foundation, Inc. <>_ +_Version 3, 29 June 2007_ +_Copyright © 2007 Free Software Foundation, Inc. <>_ -Everyone is permitted to copy and distribute verbatim copies of this -license document, but changing it is not allowed. +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. ## Preamble -The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - -The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains -free software for all its users. - -When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - -Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - -A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - -The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - -An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing -under this license. - -The precise terms and conditions for copying, distribution and -modification follow. +The GNU General Public License is a free, copyleft license for software and other +kinds of works. + +The licenses for most software and other practical works are designed to take away +your freedom to share and change the works. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change all versions of a +program--to make sure it remains free software for all its users. We, the Free +Software Foundation, use the GNU General Public License for most of our software; it +applies also to any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General +Public Licenses are designed to make sure that you have the freedom to distribute +copies of free software (and charge for them if you wish), that you receive source +code or can get it if you want it, that you can change the software or use pieces of +it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or +asking you to surrender the rights. Therefore, you have certain responsibilities if +you distribute copies of the software, or if you modify it: responsibilities to +respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, +you must pass on to the recipients the same freedoms that you received. You must make +sure that they, too, receive or can get the source code. And you must show them these +terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: **(1)** assert +copyright on the software, and **(2)** offer you this License giving you legal permission +to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is +no warranty for this free software. For both users' and authors' sake, the GPL +requires that modified versions be marked as changed, so that their problems will not +be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of +the software inside them, although the manufacturer can do so. This is fundamentally +incompatible with the aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we have designed +this version of the GPL to prohibit the practice for those products. If such problems +arise substantially in other domains, we stand ready to extend this provision to +those domains in future versions of the GPL, as needed to protect the freedom of +users. + +Finally, every program is threatened constantly by software patents. States should +not allow patents to restrict development and use of software on general-purpose +computers, but in those that do, we wish to avoid the special danger that patents +applied to a free program could make it effectively proprietary. To prevent this, the +GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. ## TERMS AND CONDITIONS -### 0. Definitions. +### 0. Definitions -"This License" refers to version 3 of the GNU Affero General Public -License. +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in +a fashion requiring copyright permission, other than the making of an exact copy. The +resulting work is called a “modified version” of the earlier work or a +work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on +the Program. + +To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for infringement under +applicable copyright law, except executing it on a computer or modifying a private +copy. Propagation includes copying, distribution (with or without modification), +making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through a computer +network, with no transfer of a copy, is not conveying. -"Copyright" also means copyright-like laws that apply to other kinds -of works, such as semiconductor masks. - -"The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - -To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of -an exact copy. The resulting work is called a "modified version" of -the earlier work or a work "based on" the earlier work. - -A "covered work" means either the unmodified Program or a work based -on the Program. - -To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - -To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user -through a computer network, with no transfer of a copy, is not -conveying. - -An interactive user interface displays "Appropriate Legal Notices" to -the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a +An interactive user interface displays “Appropriate Legal Notices” to the +extent that it includes a convenient and prominently visible feature that **(1)** +displays an appropriate copyright notice, and **(2)** tells the user that there is no +warranty for the work (except to the extent that warranties are provided), that +licensees may convey the work under this License, and how to view a copy of this +License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. -### 1. Source Code. - -The "source code" for a work means the preferred form of the work for -making modifications to it. "Object code" means any non-source form of -a work. - -A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - -The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - -The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - -The Corresponding Source need not include anything that users can -regenerate automatically from other parts of the Corresponding Source. - -The Corresponding Source for a work in source code form is that same +### 1. Source Code + +The “source code” for a work means the preferred form of the work for +making modifications to it. “Object code” means any non-source form of a work. -### 2. Basic Permissions. - -All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - -You may make, run and propagate covered works that you do not convey, -without conditions so long as your license otherwise remains in force. -You may convey covered works to others for the sole purpose of having -them make modifications exclusively for you, or provide you with -facilities for running those works, provided that you comply with the -terms of this License in conveying all material for which you do not -control copyright. Those thus making or running the covered works for -you must do so exclusively on your behalf, under your direction and -control, on terms that prohibit them from making any copies of your -copyrighted material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under the -conditions stated below. Sublicensing is not allowed; section 10 makes -it unnecessary. - -### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - -No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - -When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such -circumvention is effected by exercising rights under this License with -respect to the covered work, and you disclaim any intention to limit -operation or modification of the work as a means of enforcing, against -the work's users, your or third parties' legal rights to forbid -circumvention of technological measures. - -### 4. Conveying Verbatim Copies. - -You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - -### 5. Conveying Modified Source Versions. - -You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these -conditions: - -- a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. -- b) The work must carry prominent notices stating that it is - released under this License and any conditions added under - section 7. This requirement modifies the requirement in section 4 - to "keep intact all notices". -- c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. -- d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - -A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - -### 6. Conveying Non-Source Forms. - -You may convey a covered work in object code form under the terms of -sections 4 and 5, provided that you also convey the machine-readable -Corresponding Source under the terms of this License, in one of these -ways: - -- a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. -- b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the Corresponding - Source from a network server at no charge. -- c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. -- d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. -- e) Convey the object code using peer-to-peer transmission, - provided you inform other peers where the object code and - Corresponding Source of the work are being offered to the general - public at no charge under subsection 6d. - -A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - -A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, -family, or household purposes, or (2) anything designed or sold for -incorporation into a dwelling. In determining whether a product is a -consumer product, doubtful cases shall be resolved in favor of -coverage. For a particular product received by a particular user, -"normally used" refers to a typical or common use of that class of -product, regardless of the status of the particular user or of the way -in which the particular user actually uses, or expects or is expected -to use, the product. A product is a consumer product regardless of -whether the product has substantial commercial, industrial or -non-consumer uses, unless such uses represent the only significant -mode of use of the product. - -"Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to -install and execute modified versions of a covered work in that User -Product from a modified version of its Corresponding Source. The -information must suffice to ensure that the continued functioning of -the modified object code is in no case prevented or interfered with +A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of interfaces +specified for a particular programming language, one that is widely used among +developers working in that language. + +The “System Libraries” of an executable work include anything, other than +the work as a whole, that **(a)** is included in the normal form of packaging a Major +Component, but which is not part of that Major Component, and **(b)** serves only to +enable use of the work with that Major Component, or to implement a Standard +Interface for which an implementation is available to the public in source code form. +A “Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system (if any) on which +the executable work runs, or a compiler used to produce the work, or an object code +interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the +source code needed to generate, install, and (for an executable work) run the object +code and to modify the work, including scripts to control those activities. However, +it does not include the work's System Libraries, or general-purpose tools or +generally available free programs which are used unmodified in performing those +activities but which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for the work, and +the source code for shared libraries and dynamically linked subprograms that the work +is specifically designed to require, such as by intimate data communication or +control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate +automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +### 2. Basic Permissions + +All rights granted under this License are granted for the term of copyright on the +Program, and are irrevocable provided the stated conditions are met. This License +explicitly affirms your unlimited permission to run the unmodified Program. The +output from running a covered work is covered by this License only if the output, +given its content, constitutes a covered work. This License acknowledges your rights +of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without +conditions so long as your license otherwise remains in force. You may convey covered +works to others for the sole purpose of having them make modifications exclusively +for you, or provide you with facilities for running those works, provided that you +comply with the terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for you must do so +exclusively on your behalf, under your direction and control, on terms that prohibit +them from making any copies of your copyrighted material outside their relationship +with you. + +Conveying under any other circumstances is permitted solely under the conditions +stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +### 3. Protecting Users' Legal Rights From Anti-Circumvention Law + +No covered work shall be deemed part of an effective technological measure under any +applicable law fulfilling obligations under article 11 of the WIPO copyright treaty +adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention +of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of +technological measures to the extent such circumvention is effected by exercising +rights under this License with respect to the covered work, and you disclaim any +intention to limit operation or modification of the work as a means of enforcing, +against the work's users, your or third parties' legal rights to forbid circumvention +of technological measures. + +### 4. Conveying Verbatim Copies + +You may convey verbatim copies of the Program's source code as you receive it, in any +medium, provided that you conspicuously and appropriately publish on each copy an +appropriate copyright notice; keep intact all notices stating that this License and +any non-permissive terms added in accord with section 7 apply to the code; keep +intact all notices of the absence of any warranty; and give all recipients a copy of +this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer +support or warranty protection for a fee. + +### 5. Conveying Modified Source Versions + +You may convey a work based on the Program, or the modifications to produce it from +the Program, in the form of source code under the terms of section 4, provided that +you also meet all of these conditions: + +* **a)** The work must carry prominent notices stating that you modified it, and giving a +relevant date. +* **b)** The work must carry prominent notices stating that it is released under this +License and any conditions added under section 7. This requirement modifies the +requirement in section 4 to “keep intact all notices”. +* **c)** You must license the entire work, as a whole, under this License to anyone who +comes into possession of a copy. This License will therefore apply, along with any +applicable section 7 additional terms, to the whole of the work, and all its parts, +regardless of how they are packaged. This License gives no permission to license the +work in any other way, but it does not invalidate such permission if you have +separately received it. +* **d)** If the work has interactive user interfaces, each must display Appropriate Legal +Notices; however, if the Program has interactive interfaces that do not display +Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are +not by their nature extensions of the covered work, and which are not combined with +it such as to form a larger program, in or on a volume of a storage or distribution +medium, is called an “aggregate” if the compilation and its resulting +copyright are not used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work in an aggregate +does not cause this License to apply to the other parts of the aggregate. + +### 6. Conveying Non-Source Forms + +You may convey a covered work in object code form under the terms of sections 4 and +5, provided that you also convey the machine-readable Corresponding Source under the +terms of this License, in one of these ways: + +* **a)** Convey the object code in, or embodied in, a physical product (including a +physical distribution medium), accompanied by the Corresponding Source fixed on a +durable physical medium customarily used for software interchange. +* **b)** Convey the object code in, or embodied in, a physical product (including a +physical distribution medium), accompanied by a written offer, valid for at least +three years and valid for as long as you offer spare parts or customer support for +that product model, to give anyone who possesses the object code either **(1)** a copy of +the Corresponding Source for all the software in the product that is covered by this +License, on a durable physical medium customarily used for software interchange, for +a price no more than your reasonable cost of physically performing this conveying of +source, or **(2)** access to copy the Corresponding Source from a network server at no +charge. +* **c)** Convey individual copies of the object code with a copy of the written offer to +provide the Corresponding Source. This alternative is allowed only occasionally and +noncommercially, and only if you received the object code with such an offer, in +accord with subsection 6b. +* **d)** Convey the object code by offering access from a designated place (gratis or for +a charge), and offer equivalent access to the Corresponding Source in the same way +through the same place at no further charge. You need not require recipients to copy +the Corresponding Source along with the object code. If the place to copy the object +code is a network server, the Corresponding Source may be on a different server +(operated by you or a third party) that supports equivalent copying facilities, +provided you maintain clear directions next to the object code saying where to find +the Corresponding Source. Regardless of what server hosts the Corresponding Source, +you remain obligated to ensure that it is available for as long as needed to satisfy +these requirements. +* **e)** Convey the object code using peer-to-peer transmission, provided you inform +other peers where the object code and Corresponding Source of the work are being +offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the +Corresponding Source as a System Library, need not be included in conveying the +object code work. + +A “User Product” is either **(1)** a “consumer product”, which +means any tangible personal property which is normally used for personal, family, or +household purposes, or **(2)** anything designed or sold for incorporation into a +dwelling. In determining whether a product is a consumer product, doubtful cases +shall be resolved in favor of coverage. For a particular product received by a +particular user, “normally used” refers to a typical or common use of +that class of product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected to use, the +product. A product is a consumer product regardless of whether the product has +substantial commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install and execute +modified versions of a covered work in that User Product from a modified version of +its Corresponding Source. The information must suffice to ensure that the continued +functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. -If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - -The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or -updates for a work that has been modified or installed by the -recipient, or for the User Product in which it has been modified or -installed. Access to a network may be denied when the modification -itself materially and adversely affects the operation of the network -or violates the rules and protocols for communication across the -network. - -Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - -### 7. Additional Terms. - -"Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by +If you convey an object code work under this section in, or with, or specifically for +use in, a User Product, and the conveying occurs as part of a transaction in which +the right of possession and use of the User Product is transferred to the recipient +in perpetuity or for a fixed term (regardless of how the transaction is +characterized), the Corresponding Source conveyed under this section must be +accompanied by the Installation Information. But this requirement does not apply if +neither you nor any third party retains the ability to install modified object code +on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to +continue to provide support service, warranty, or updates for a work that has been +modified or installed by the recipient, or for the User Product in which it has been +modified or installed. Access to a network may be denied when the modification itself +materially and adversely affects the operation of the network or violates the rules +and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with +this section must be in a format that is publicly documented (and with an +implementation available to the public in source code form), and must require no +special password or key for unpacking, reading or copying. + +### 7. Additional Terms + +“Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. Additional +permissions that are applicable to the entire Program shall be treated as though they +were included in this License, to the extent that they are valid under applicable +law. If additional permissions apply only to part of the Program, that part may be +used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. -When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - -Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders -of that material) supplement the terms of this License with terms: - -- a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or -- b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or -- c) Prohibiting misrepresentation of the origin of that material, - or requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or -- d) Limiting the use for publicity purposes of names of licensors - or authors of the material; or -- e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or -- f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions - of it) with contractual assumptions of liability to the recipient, - for any liability that these contractual assumptions directly - impose on those licensors and authors. - -All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - -If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - -Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; the -above requirements apply either way. - -### 8. Termination. - -You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - -However, if you cease all violation of this License, then your license -from a particular copyright holder is reinstated (a) provisionally, -unless and until the copyright holder explicitly and finally -terminates your license, and (b) permanently, if the copyright holder -fails to notify you of the violation by some reasonable means prior to -60 days after the cessation. - -Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after +When you convey a copy of a covered work, you may at your option remove any +additional permissions from that copy, or from any part of it. (Additional +permissions may be written to require their own removal in certain cases when you +modify the work.) You may place additional permissions on material, added by you to a +covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a +covered work, you may (if authorized by the copyright holders of that material) +supplement the terms of this License with terms: + +* **a)** Disclaiming warranty or limiting liability differently from the terms of +sections 15 and 16 of this License; or +* **b)** Requiring preservation of specified reasonable legal notices or author +attributions in that material or in the Appropriate Legal Notices displayed by works +containing it; or +* **c)** Prohibiting misrepresentation of the origin of that material, or requiring that +modified versions of such material be marked in reasonable ways as different from the +original version; or +* **d)** Limiting the use for publicity purposes of names of licensors or authors of the +material; or +* **e)** Declining to grant rights under trademark law for use of some trade names, +trademarks, or service marks; or +* **f)** Requiring indemnification of licensors and authors of that material by anyone +who conveys the material (or modified versions of it) with contractual assumptions of +liability to the recipient, for any liability that these contractual assumptions +directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you received +it, or any part of it, contains a notice stating that it is governed by this License +along with a term that is a further restriction, you may remove that term. If a +license document contains a further restriction but permits relicensing or conveying +under this License, you may add to a covered work material governed by the terms of +that license document, provided that the further restriction does not survive such +relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in +the relevant source files, a statement of the additional terms that apply to those +files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a +separately written license, or stated as exceptions; the above requirements apply +either way. + +### 8. Termination + +You may not propagate or modify a covered work except as expressly provided under +this License. Any attempt otherwise to propagate or modify it is void, and will +automatically terminate your rights under this License (including any patent licenses +granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a +particular copyright holder is reinstated **(a)** provisionally, unless and until the +copyright holder explicitly and finally terminates your license, and **(b)** permanently, +if the copyright holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently +if the copyright holder notifies you of the violation by some reasonable means, this +is the first time you have received notice of violation of this License (for any +work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. -Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - -### 9. Acceptance Not Required for Having Copies. - -You are not required to accept this License in order to receive or run -a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - -### 10. Automatic Licensing of Downstream Recipients. - -Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - -An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - -You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - -### 11. Patents. - -A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - -A contributor's "essential patent claims" are all patent claims owned -or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - -Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - -In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - -If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - -If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - -A patent license is "discriminatory" if it does not include within the -scope of its coverage, prohibits the exercise of, or is conditioned on -the non-exercise of one or more of the rights that are specifically -granted under this License. You may not convey a covered work if you -are a party to an arrangement with a third party that is in the -business of distributing software, under which you make payment to the -third party based on the extent of your activity of conveying the -work, and under which the third party grants, to any of the parties -who would receive the covered work from you, a discriminatory patent -license (a) in connection with copies of the covered work conveyed by -you (or copies made from those copies), or (b) primarily for and in -connection with specific products or compilations that contain the -covered work, unless you entered into that arrangement, or that patent -license was granted, prior to 28 March 2007. - -Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - -### 12. No Surrender of Others' Freedom. - -If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under -this License and any other pertinent obligations, then as a -consequence you may not convey it at all. For example, if you agree to -terms that obligate you to collect a royalty for further conveying -from those to whom you convey the Program, the only way you could -satisfy both those terms and this License would be to refrain entirely -from conveying the Program. - -### 13. Remote Network Interaction; Use with the GNU General Public License. - -Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your -version supports such interaction) an opportunity to receive the -Corresponding Source of your version by providing access to the -Corresponding Source from a network server at no charge, through some -standard or customary means of facilitating copying of software. This -Corresponding Source shall include the Corresponding Source for any -work covered by version 3 of the GNU General Public License that is -incorporated pursuant to the following paragraph. - -Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - -### 14. Revised Versions of this License. - -The Free Software Foundation may publish revised and/or new versions -of the GNU Affero General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever -published by the Free Software Foundation. - -If the Program specifies that a proxy can decide which future versions -of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - -Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - -### 15. Disclaimer of Warranty. - -THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT -WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE -DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR -CORRECTION. - -### 16. Limitation of Liability. - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR -CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES -ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT -NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR -LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM -TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER -PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -### 17. Interpretation of Sections 15 and 16. - -If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - -END OF TERMS AND CONDITIONS +Termination of your rights under this section does not terminate the licenses of +parties who have received copies or rights from you under this License. If your +rights have been terminated and not permanently reinstated, you do not qualify to +receive new licenses for the same material under section 10. + +### 9. Acceptance Not Required for Having Copies + +You are not required to accept this License in order to receive or run a copy of the +Program. Ancillary propagation of a covered work occurring solely as a consequence of +using peer-to-peer transmission to receive a copy likewise does not require +acceptance. However, nothing other than this License grants you permission to +propagate or modify any covered work. These actions infringe copyright if you do not +accept this License. Therefore, by modifying or propagating a covered work, you +indicate your acceptance of this License to do so. + +### 10. Automatic Licensing of Downstream Recipients + +Each time you convey a covered work, the recipient automatically receives a license +from the original licensors, to run, modify and propagate that work, subject to this +License. You are not responsible for enforcing compliance by third parties with this +License. + +An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an organization, or +merging organizations. If propagation of a covered work results from an entity +transaction, each party to that transaction who receives a copy of the work also +receives whatever licenses to the work the party's predecessor in interest had or +could give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if the predecessor +has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or +affirmed under this License. For example, you may not impose a license fee, royalty, +or other charge for exercise of rights granted under this License, and you may not +initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging +that any patent claim is infringed by making, using, selling, offering for sale, or +importing the Program or any portion of it. + +### 11. Patents + +A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The work thus +licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or +controlled by the contributor, whether already acquired or hereafter acquired, that +would be infringed by some manner, permitted by this License, of making, using, or +selling its contributor version, but do not include claims that would be infringed +only as a consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant patent +sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license +under the contributor's essential patent claims, to make, use, sell, offer for sale, +import and otherwise run, modify and propagate the contents of its contributor +version. + +In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent (such as an +express permission to practice a patent or covenant not to sue for patent +infringement). To “grant” such a patent license to a party means to make +such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the +Corresponding Source of the work is not available for anyone to copy, free of charge +and under the terms of this License, through a publicly available network server or +other readily accessible means, then you must either **(1)** cause the Corresponding +Source to be so available, or **(2)** arrange to deprive yourself of the benefit of the +patent license for this particular work, or **(3)** arrange, in a manner consistent with +the requirements of this License, to extend the patent license to downstream +recipients. “Knowingly relying” means you have actual knowledge that, but +for the patent license, your conveying the covered work in a country, or your +recipient's use of the covered work in a country, would infringe one or more +identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you +convey, or propagate by procuring conveyance of, a covered work, and grant a patent +license to some of the parties receiving the covered work authorizing them to use, +propagate, modify or convey a specific copy of the covered work, then the patent +license you grant is automatically extended to all recipients of the covered work and +works based on it. + +A patent license is “discriminatory” if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on the +non-exercise of one or more of the rights that are specifically granted under this +License. You may not convey a covered work if you are a party to an arrangement with +a third party that is in the business of distributing software, under which you make +payment to the third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties who would receive +the covered work from you, a discriminatory patent license **(a)** in connection with +copies of the covered work conveyed by you (or copies made from those copies), or **(b)** +primarily for and in connection with specific products or compilations that contain +the covered work, unless you entered into that arrangement, or that patent license +was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied +license or other defenses to infringement that may otherwise be available to you +under applicable patent law. + +### 12. No Surrender of Others' Freedom + +If conditions are imposed on you (whether by court order, agreement or otherwise) +that contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot convey a covered work so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not convey it at all. For example, if you +agree to terms that obligate you to collect a royalty for further conveying from +those to whom you convey the Program, the only way you could satisfy both those terms +and this License would be to refrain entirely from conveying the Program. + +### 13. Use with the GNU Affero General Public License + +Notwithstanding any other provision of this License, you have permission to link or +combine any covered work with a work licensed under version 3 of the GNU Affero +General Public License into a single combined work, and to convey the resulting work. +The terms of this License will continue to apply to the part which is the covered +work, but the special requirements of the GNU Affero General Public License, section +13, concerning interaction through a network will apply to the combination as such. + +### 14. Revised Versions of this License + +The Free Software Foundation may publish revised and/or new versions of the GNU +General Public License from time to time. Such new versions will be similar in spirit +to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that +a certain numbered version of the GNU General Public License “or any later +version” applies to it, you have the option of following the terms and +conditions either of that numbered version or of any later version published by the +Free Software Foundation. If the Program does not specify a version number of the GNU +General Public License, you may choose any version ever published by the Free +Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU +General Public License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no +additional obligations are imposed on any author or copyright holder as a result of +your choosing to follow a later version. + +### 15. Disclaimer of Warranty + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +### 16. Limitation of Liability + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY +COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS +PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE +OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE +WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +### 17. Interpretation of Sections 15 and 16 + +If the disclaimer of warranty and limitation of liability provided above cannot be +given local legal effect according to their terms, reviewing courts shall apply local +law that most closely approximates an absolute waiver of all civil liability in +connection with the Program, unless a warranty or assumption of liability accompanies +a copy of the Program in return for a fee. + +_END OF TERMS AND CONDITIONS_ ## How to Apply These Terms to Your New Programs -If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these -terms. - -To do so, attach the following notices to the program. It is safest to -attach them to the start of each source file to most effectively state -the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper -mail. - -If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for -the specific requirements. - -You should also get your employer (if you work as a programmer) or -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. For more information on this, and how to apply and follow -the GNU AGPL, see . +If you develop a new program, and you want it to be of the greatest possible use to +the public, the best way to achieve this is to make it free software which everyone +can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them +to the start of each source file to most effectively state the exclusion of warranty; +and each file should have at least the “copyright” line and a pointer to +where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this +when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type 'show c' for details. + +The hypothetical commands `show w` and `show c` should show the appropriate parts of +the General Public License. Of course, your program's commands might be different; +for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to +sign a “copyright disclaimer” for the program, if necessary. For more +information on this, and how to apply and follow the GNU GPL, see +<>. + +The GNU General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may consider it +more useful to permit linking proprietary applications with the library. If this is +what you want to do, use the GNU Lesser General Public License instead of this +License. But first, please read +<>. diff --git a/NAMESPACE b/NAMESPACE index 157b5bd..87e6ac6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method(autoplot,pairwise) S3method(format,supernova_number) S3method(generate_models,formula) S3method(generate_models,lm) @@ -11,7 +10,6 @@ S3method(plot,pairwise) S3method(print,comparison_models) S3method(print,pairwise) S3method(print,supernova) -S3method(scale_type,supernova_number) S3method(supernova,lm) S3method(supernova,lmerMod) S3method(tbl_sum,pairwise_tbl) @@ -36,8 +34,8 @@ S3method(vec_ptype2,supernova_number.character) S3method(vec_ptype2,supernova_number.double) S3method(vec_ptype2,supernova_number.supernova_number) S3method(vec_ptype_abbr,supernova_number) -export("%>%") export(as_number) +export(autoplot.pairwise) export(drop_term) export(equation) export(generate_models) @@ -48,15 +46,9 @@ export(pairwise) export(pairwise_bonferroni) export(pairwise_t) export(pairwise_tukey) -export(superanova) export(supernova) export(variables) import(vctrs) -importFrom(ggplot2,"%+%") -importFrom(ggplot2,autoplot) -importFrom(ggplot2,scale_type) -importFrom(lifecycle,deprecated) -importFrom(magrittr,"%>%") importFrom(methods,setOldClass) importFrom(pillar,tbl_sum) importFrom(rlang,.data) diff --git a/NEWS.md b/NEWS.md index b32aa59..3fada2c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ # Changelog +## supernova 3.0.0 + +### Breaking changes + +- Remove deprecated `superanova()` +- Remove `magrittr`, `ggplot2`, and `backports` dependencies + ## supernova 2.5.8 - Don't trim the leading digit from p-value or PRE when they are exactly 1 diff --git a/R/generate_models.R b/R/generate_models.R index b1fe229..ae2e98a 100644 --- a/R/generate_models.R +++ b/R/generate_models.R @@ -128,7 +128,7 @@ generate_models.lm <- function(model, type = 3) { list(complex = model, simple = drop_term(model, term)) }) - fits <- magrittr::set_names(fits, terms) + fits <- rlang::set_names(fits, terms) full_model_pair <- list(complex = model, simple = update_in_env(model, . ~ NULL)) fits <- append(fits, list("Full Model" = full_model_pair), after = 0L) } @@ -149,7 +149,7 @@ add_class_information <- function(models, model, type) { build_formulae_full_model <- function(frm) { null_model <- frm_build(frm_outcome(frm), "NULL", environment(frm)) models <- list(complex = frm, simple = null_model) - magrittr::set_names(list(models), "Full Model") + rlang::set_names(list(models), "Full Model") } build_formulae_type_1 <- function(frm) { @@ -163,7 +163,7 @@ build_formulae_type_1 <- function(frm) { list(complex = complex, simple = frm_remove_term(complex, term)) }) - magrittr::set_names(models, terms) + rlang::set_names(models, terms) } build_formulae_type_2 <- function(frm) { @@ -189,7 +189,7 @@ build_formulae_type_2 <- function(frm) { list(complex = complex, simple = frm_remove_term(complex, term)) }) - magrittr::set_names(models, terms) + rlang::set_names(models, terms) } build_formulae_type_3 <- function(frm) { @@ -202,7 +202,7 @@ build_formulae_type_3 <- function(frm) { list(complex = frm, simple = frm_remove_term(frm, term)) }) - magrittr::set_names(models, terms) + rlang::set_names(models, terms) } @@ -240,13 +240,7 @@ drop_term <- function(fit, term) { x_reduced <- x[, which(column_term_indices != term_index_to_drop), drop = FALSE] reduced_fit <- stats::lm.fit(x_reduced, y, offset = offset) - - call_string <- deparse(fit$call) %>% - paste0(collapse = "") %>% - stringr::str_squish() - new_call_string <- sprintf("drop_term(%s, \"%s\")", call_string, term) - str2lang <- utils::getFromNamespace("str2lang", "backports") - reduced_fit$call <- str2lang(new_call_string) + reduced_fit$call <- base::call("drop_term", fit$call, term) oldClass(reduced_fit) <- "lm" reduced_fit @@ -280,8 +274,8 @@ print.comparison_models <- function(x, ...) { #' @keywords internal formula_string <- function(obj, part, term) { type <- resolve_type(attr(obj, "type")) - model_full <- as.formula(attr(obj, "model")) %>% frm_expand() - model_part <- as.formula(part) %>% frm_expand() + model_full <- frm_expand(as.formula(attr(obj, "model"))) + model_part <- frm_expand(as.formula(part)) # For Types II and III the spaces need to be inserted within the formula string. # So, determine which variables were removed @@ -300,14 +294,11 @@ formula_string <- function(obj, part, term) { # add regex to remove immediately following space and plus rem_pat <- paste0(paste0(" ", rem_pat, collapse = " \\+?|"), "$") - # perform replacements - output <- deparse(model_full) %>% - # replace variables with spaces in full string - stringr::str_replace_all(rem_pat, function(str) strrep(" ", nchar(str))) %>% - # trim dangling spaces and plus signs from end - stringr::str_remove("[ \\+]*$") - - return(output) + # replace variables with spaces in full string + replacer <- function(str) strrep(" ", nchar(str)) + vars_removed <- stringr::str_replace_all(deparse(model_full), rem_pat, replacer) + # trim dangling spaces and plus signs from end + return(stringr::str_remove(vars_removed, "[ \\+]*$")) } if (type == 3) { @@ -316,13 +307,23 @@ formula_string <- function(obj, part, term) { # add regex to remove immediately following space and plus rem_pat <- paste0(" ", rem_pat, "( \\+|$)") - # perform replacements - output <- deparse(model_full) %>% - # replace variables with spaces in full string - stringr::str_replace_all(rem_pat, function(str) strrep(" ", nchar(str))) %>% - # trim dangling spaces and plus signs from end - stringr::str_remove("[ \\+]*$") - - return(output) + # replace variables with spaces in full string + replacer <- function(str) strrep(" ", nchar(str)) + vars_removed <- stringr::str_replace_all(deparse(model_full), rem_pat, replacer) + # trim dangling spaces and plus signs from end + return(stringr::str_remove(vars_removed, "[ \\+]*$")) } } + +replace_vars_with_spaces <- function(str, vars) { + # escape special regex characters in variables + rem_pat <- stringr::str_replace_all(vars, "(\\W)", "\\\\\\1") + # add regex to remove immediately following space and plus + rem_pat <- paste0(paste0(" ", rem_pat, collapse = " \\+?|"), "$") + + # replace variables with spaces in full string + replacer <- function(str) strrep(" ", nchar(str)) + vars_removed <- stringr::str_replace_all(str, rem_pat, replacer) + # trim dangling spaces and plus signs from end + stringr::str_remove(vars_removed, "[ \\+]*$") +} diff --git a/R/listwise_delete.R b/R/listwise_delete.R index 7d6dab3..94a0e83 100644 --- a/R/listwise_delete.R +++ b/R/listwise_delete.R @@ -40,19 +40,18 @@ listwise_delete.lm <- function(obj, vars = all.vars(formula(obj))) { return(obj) } - call_string <- build_equivalent_call_string(obj, vars) + new_call <- build_equivalent_call(obj, vars) rlang::inform( message = c( cli::pluralize("Refitting to remove {n_missing} case{?s} with missing value(s)"), - i = paste0(call_string, "\n") + i = rlang::expr_text(new_call) ), class = "supernova_missing_values_message" ) - str2lang <- utils::getFromNamespace("str2lang", "backports") rlang::try_fetch( - eval(str2lang(call_string), envir = environment(as.formula(obj))), + eval(new_call, envir = environment(as.formula(obj))), supernova_missing_values_message = function(cnd) { rlang::cnd_muffle(cnd) } @@ -60,29 +59,11 @@ listwise_delete.lm <- function(obj, vars = all.vars(formula(obj))) { } -build_equivalent_call_string <- function(linear_model, vars) { - call_string <- deparse(linear_model$call) %>% - stringr::str_flatten() %>% - stringr::str_squish() - var_string <- paste0( - "c(", - paste0('"', vars, '"', collapse = ", "), - ")" - ) - - if (stringr::str_detect(call_string, " data = .+?[ ,)]")) { - new_call_string <- stringr::str_replace( - call_string, - " data = (.+?)([ ,)])", - sprintf(" data = listwise_delete(\\1, %s)\\2", var_string) - ) +build_equivalent_call <- function(linear_model, vars) { + call_args <- rlang::call_args(linear_model$call) + if (!is.null(call_args$data)) { + rlang::call_modify(linear_model$call, data = call("listwise_delete", call_args$data, vars)) } else { - model <- formula(linear_model) - variables <- c(frm_outcome(model), frm_vars(model)) - variables_string <- paste(variables, collapse = ", ") - data_string <- paste0(" data = listwise_delete(data.frame(", variables_string, "))") - new_call_string <- stringr::str_replace(call_string, "\\)$", paste0(data_string, ")")) + rlang::call_modify(linear_model$call, data = listwise_delete(data.frame(vars))) } - - new_call_string } diff --git a/R/number.R b/R/number.R index 39d0846..b43f000 100644 --- a/R/number.R +++ b/R/number.R @@ -69,9 +69,8 @@ as_number <- function(x) vctrs::vec_cast(x, new_number()) #' @export format.supernova_number <- function(x, ...) { formatter <- function(values) { - formatted <- values %>% - round(attr(x, "digits")) %>% - format(nsmall = attr(x, "digits"), scientific = attr(x, "scientific")) + rounded <- round(values, attr(x, "digits")) + formatted <- format(rounded, nsmall = attr(x, "digits"), scientific = attr(x, "scientific")) if (!attr(x, "leading_zero")) { formatted <- stringr::str_replace(formatted, "^0[.]", ".") diff --git a/R/pairwise.R b/R/pairwise.R index fcde0fe..6953edd 100644 --- a/R/pairwise.R +++ b/R/pairwise.R @@ -101,9 +101,9 @@ pairwise_t <- function(fit, term = NULL, alpha = .05, correction = "none") { params <- means_and_counts(fit, term) tests <- purrr::pmap(params, function(means, counts, term) { if (term %in% frm_interaction_terms(fit)) { - simple_terms <- expand.grid(dimnames(means)) %>% purrr::pmap_chr(paste, sep = ":") - means <- as.vector(means) %>% magrittr::set_names(simple_terms) - counts <- as.vector(counts) %>% magrittr::set_names(simple_terms) + simple_terms <- purrr::pmap_chr(expand.grid(dimnames(means)), paste, sep = ":") + means <- rlang::set_names(as.vector(means), simple_terms) + counts <- rlang::set_names(as.vector(counts), simple_terms) pairs <- level_pairs(simple_terms) } else { pairs <- level_pairs(names(means)) @@ -139,8 +139,7 @@ pairwise_t <- function(fit, term = NULL, alpha = .05, correction = "none") { }) fwer <- 1 - (1 - alpha / corr_val)^length(rows) - purrr::reduce(rows, vctrs::vec_c) %>% - new_pairwise_tbl(term, fit, fwer, alpha, correction) + new_pairwise_tbl(purrr::reduce(rows, vctrs::vec_c), term, fit, fwer, alpha, correction) }) structure(tests, class = "pairwise", fit = fit, correction = correction) @@ -163,9 +162,9 @@ pairwise_tukey <- function(fit, term = NULL, alpha = .05) { mse <- sum(fit$residuals^2) / fit$df.residual tests <- purrr::pmap(means_and_counts(fit, term), function(means, counts, term) { if (term %in% frm_interaction_terms(fit)) { - simple_terms <- expand.grid(dimnames(means)) %>% purrr::pmap_chr(paste, sep = ":") - means <- as.vector(means) %>% magrittr::set_names(simple_terms) - counts <- as.vector(counts) %>% magrittr::set_names(simple_terms) + simple_terms <- purrr::pmap_chr(expand.grid(dimnames(means)), paste, sep = ":") + means <- rlang::set_names(as.vector(means), simple_terms) + counts <- rlang::set_names(as.vector(counts), simple_terms) pairs <- level_pairs(simple_terms) } else { pairs <- level_pairs(names(means)) @@ -194,8 +193,7 @@ pairwise_tukey <- function(fit, term = NULL, alpha = .05) { ) }) - purrr::reduce(rows, vctrs::vec_c) %>% - new_pairwise_tbl(term, fit, alpha, alpha, correction) + new_pairwise_tbl(purrr::reduce(rows, vctrs::vec_c), term, fit, alpha, alpha, correction) }) structure(tests, class = "pairwise", fit = fit, correction = correction) @@ -303,14 +301,13 @@ means_and_counts <- function(fit, term) { model_tables <- stats::model.tables(stats::aov(categorical_fit), "means") means <- model_tables$tables[terms] - counts <- model_tables$n[terms] %>% - purrr::imap(function(term_counts, index) { - if (length(term_counts) == 1) { - term_counts <- rep_len(term_counts, length(means[[index]])) - names(term_counts) <- names(means[[index]]) - } - term_counts - }) + counts <- purrr::imap(model_tables$n[terms], function(term_counts, index) { + if (length(term_counts) == 1) { + term_counts <- rep_len(term_counts, length(means[[index]])) + names(term_counts) <- names(means[[index]]) + } + term_counts + }) list(means = means, counts = counts, term = terms) } @@ -349,15 +346,14 @@ select_terms <- function(fit, term = NULL) { #' @keywords internal level_pairs <- function(levels) { create_row <- function(level) { - purrr::map(levels, ~ list(level, .x)) %>% - vctrs::vec_rbind() %>% - suppressMessages() + suppressMessages( + vctrs::vec_rbind(purrr::map(levels, ~ list(level, .x))) + ) } - purrr::map(levels, create_row) %>% - purrr::reduce(vctrs::vec_c) %>% - as.matrix() %>% - lower_tri() + rows <- purrr::map(levels, create_row) + mat <- as.matrix(purrr::reduce(rows, vctrs::vec_c)) + lower_tri(mat) } @@ -393,11 +389,34 @@ tbl_sum.pairwise_tbl <- function(x) { # Plotting ------------------------------------------------------------------------------------ +scale_type.supernova_number <- function(x) "continuous" + +#' Plotting method for pairwise objects. +#' +#' @param object A [`pairwise`] object. +#' @param ... Additional arguments passed to the plotting geom. +#' @details This function requires an optional dependency: [`ggplot2`][ggplot2::ggplot2-package]. +#' When this package is installed, calling `autoplot()` or `plot` on a `pairwise` object will +#' generate a plot of the pairwise comparisons. The plot will show the differences between the +#' groups, with error bars representing the confidence intervals. The x-axis will be labeled with +#' the type of confidence interval used and the values of the differences, and the y-axis will be +#' labeled with the groups being compared. A dashed line at 0 is included to help visualize the +#' differences. +#' #' @export -#' @importFrom ggplot2 autoplot -#' @importFrom ggplot2 %+% #' @importFrom rlang .data +#' +#' @examples +#' if (require(ggplot2)) { +#' # generate the plot immediately +#' pairwise(lm(mpg ~ factor(am) + disp, data = mtcars), plot = TRUE) +#' +#' # or save the object and plot it later +#' p <- pairwise(lm(mpg ~ factor(am) + disp, data = mtcars)) +#' plot(p) +#' } autoplot.pairwise <- function(object, ...) { + `%+%` <- ggplot2::`%+%` x <- object[!(names(object) %in% c("p_adj", "p_val"))] p <- purrr::imap(x, function(tbl, term) { tbl$term <- term @@ -405,10 +424,10 @@ autoplot.pairwise <- function(object, ...) { correction <- attr(tbl, "correction") x_axis_label <- if (correction == "none") { - conf <- format((1 - attr(tbl, "alpha")) * 100, digits = 3) %>% paste0("%") + conf <- paste0(format((1 - attr(tbl, "alpha")) * 100, digits = 3), "%") paste(conf, "CI (per test; uncorrected)") } else { - conf <- format((1 - attr(tbl, "fwer")) * 100, digits = 3) %>% paste0("%") + conf <- paste0(format((1 - attr(tbl, "fwer")) * 100, digits = 3), "%") paste(conf, "CI with", stringr::str_to_title(correction), "correction") } @@ -429,13 +448,14 @@ autoplot.pairwise <- function(object, ...) { } +#' @rdname autoplot.pairwise +#' @param x A `pairwise` object. +#' @param y Ignored, required for compatibility with the `plot()` generic. #' @export -#' @importFrom ggplot2 scale_type -scale_type.supernova_number <- function(x) "continuous" - +plot.pairwise <- function(x, y, ...) { + if (!requireNamespace("ggplot2", quietly = TRUE)) { + rlang::abort("The ggplot2 package is required to plot pairwise comparisons.") + } -#' @export -#' @importFrom ggplot2 autoplot -plot.pairwise <- function(x, ...) { - purrr::walk(autoplot(x, ...), print) + purrr::walk(ggplot2::autoplot(x, ...), print) } diff --git a/R/supernova-package.R b/R/supernova-package.R index 5980d81..868b40d 100644 --- a/R/supernova-package.R +++ b/R/supernova-package.R @@ -1,12 +1,3 @@ -## usethis namespace: start -#' @importFrom lifecycle deprecated -## usethis namespace: end -NULL - -.onLoad <- function(libname, pkgname) { - backports::import(pkgname, "str2lang") -} - # Suppress R CMD check note (these are actually used) #' @importFrom methods setOldClass NULL diff --git a/R/supernova.R b/R/supernova.R index dd304cd..6c01889 100644 --- a/R/supernova.R +++ b/R/supernova.R @@ -8,8 +8,6 @@ #' values, and is intended to match the output used in Judd, McClelland, and #' Ryan (2017). #' -#' `superanova()` is an alias of `supernova()` -#' #' @param fit A model fit by [`lm()`] or [`lme4::lmer()`] #' @param type The type of sums of squares to calculate (see [`generate_models()`]). Defaults to the #' widely used Type `III` SS. @@ -24,7 +22,9 @@ #' #' @examples #' supernova(lm(mpg ~ disp, data = mtcars)) -#' supernova(lm(mpg ~ disp, data = mtcars)) %>% print(pcut = 8) +#' +#' change_p_decimals <- supernova(lm(mpg ~ disp, data = mtcars)) +#' print(change_p_decimals, pcut = 8) #' @importFrom stats anova as.formula drop1 pf #' #' @references Judd, C. M., McClelland, G. H., & Ryan, C. S. (2017). \emph{Data @@ -37,13 +37,6 @@ supernova <- function(fit, type = 3, verbose = TRUE) { } -#' @export -#' @rdname supernova -superanova <- function(fit, type = 3, verbose = TRUE) { - lifecycle::deprecate_stop("2.5.2", "superanova()", "supernova()") -} - - #' @export #' @rdname supernova supernova.lm <- function(fit, type = 3, verbose = TRUE) { @@ -76,7 +69,7 @@ supernova.lm <- function(fit, type = 3, verbose = TRUE) { vctrs::vec_c( row_term("Model", "(error reduced)", models, "Full Model"), - partial_rows %>% purrr::reduce(vctrs::vec_c), + purrr::reduce(partial_rows, vctrs::vec_c), row_error("Error", "(from model)", fit), row_error("Total", "(empty model)", fit_null) ) @@ -228,8 +221,8 @@ supernova.lmerMod <- function(fit, type = 3, verbose = FALSE) { df_total_within <- total_row[["df"]] - df_total_between # TREATMENT ROWS - anova_lm <- anova_tbl(fit_lm) %>% select("F", FALSE) - anova_lmer <- anova_tbl(model_full) %>% select(c("term", "F")) + anova_lm <- select(anova_tbl(fit_lm), "F", FALSE) + anova_lmer <- select(anova_tbl(model_full), c("term", "F")) partial_rows <- merge_keep_order(anova_lmer, anova_lm, by = "term", order_by = "term") # TREATMENT WITHIN @@ -270,8 +263,9 @@ supernova.lmerMod <- function(fit, type = 3, verbose = FALSE) { part <- vctrs::vec_c( partial_within[which(partial_within$term == x), ], partial_within_error[which(partial_within_error$match == x), ] - ) %>% select("match", keep = FALSE) + ) + part <- select(part, "match", keep = FALSE) part[, c("PRE", "p")] <- NA_real_ part[["PRE"]][[1]] <- part[["SS"]][[1]] / sum(part[["SS"]]) part[["p"]][[1]] <- pf(part[["F"]][[1]], part[["df"]][[1]], part[["df"]][[2]], @@ -343,9 +337,9 @@ supernova.lmerMod <- function(fit, type = 3, verbose = FALSE) { )[c("term", "SS", "df", "MS", "F", "PRE", "p")] tbl[["df"]] <- as.integer(tbl[["df"]]) tbl[["MS"]] <- tbl[["SS"]] / tbl[["df"]] - tbl <- tbl[tbl[["df"]] > 0, ] %>% as.data.frame() + tbl <- tbl[tbl[["df"]] > 0, ] - rl <- list(tbl = tbl, fit = fit, models = NULL) + rl <- list(tbl = as.data.frame(tbl), fit = fit, models = NULL) class(rl) <- "supernova" attr(rl, "type") <- strrep("I", type) attr(rl, "verbose") <- verbose @@ -376,8 +370,8 @@ print.supernova <- function(x, pcut = 4, ...) { # NAs to blank spots if (!is.null(tbl$description)) tbl$description[is.na(tbl$description)] <- "" - tbl <- lapply(tbl, function(x) gsub("\\s*NA\\s*", " ", x)) %>% - as.data.frame(stringsAsFactors = FALSE) + tbl <- lapply(tbl, function(x) gsub("\\s*NA\\s*", " ", x)) + tbl <- as.data.frame(tbl, stringsAsFactors = FALSE) # trim leading 0 from p and PRE tbl[, c("p", "PRE")] <- vapply( @@ -412,8 +406,9 @@ print.supernova <- function(x, pcut = 4, ...) { tbl <- insert_rule(tbl, 1) tbl <- insert_rule(tbl, grep("Total between subjects", tbl$term) + 1) tbl <- insert_rule(tbl, grep("Total within subjects", tbl$term) + 1) - tbl[["term"]] <- tbl[["term"]] %>% - stringr::str_replace("(Total|Error) (?:between|within) subjects", "\\1") + tbl[["term"]] <- stringr::str_replace( + tbl[["term"]], "(Total|Error) (?:between|within) subjects", "\\1" + ) } # add spaces and a vertical bar to separate the terms & desc from values diff --git a/R/utils-formula.R b/R/utils-formula.R index cb17037..04be2d4 100644 --- a/R/utils-formula.R +++ b/R/utils-formula.R @@ -164,9 +164,9 @@ frm_random_vars <- function(frm) { possible_bars <- stringr::str_detect(frm_terms(frm), stringr::fixed("|")) random_terms <- if (any(possible_bars)) lme4::findbars(frm) else list() - purrr::map(random_terms, all.vars) %>% - purrr::flatten_chr() %>% - unique() + terms <- purrr::map(random_terms, all.vars) + terms <- purrr::flatten_chr(terms) + unique(terms) } diff --git a/R/utils-pipe.R b/R/utils-pipe.R deleted file mode 100644 index e79f3d8..0000000 --- a/R/utils-pipe.R +++ /dev/null @@ -1,11 +0,0 @@ -#' Pipe operator -#' -#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. -#' -#' @name %>% -#' @rdname pipe -#' @keywords internal -#' @export -#' @importFrom magrittr %>% -#' @usage lhs \%>\% rhs -NULL diff --git a/R/variables.R b/R/variables.R index 6130f7d..09354d3 100644 --- a/R/variables.R +++ b/R/variables.R @@ -58,8 +58,8 @@ variables.lmerMod <- function(object) { # currently we only support a single grouping variable, logically it must be the random variable # with the shortest name --- all other valid random variables will be nested in some way and have # (1 | a:b) syntax, where b is the group variable - group_var <- random_terms[which.min(nchar(random_terms))] %>% - stringr::str_remove("^1 [|] ") + group_var <- random_terms[which.min(nchar(random_terms))] + group_var <- stringr::str_remove(group_var, "^1 [|] ") # need to check the data and number of groups to determine within and between below data <- object@frame diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..b40db08 --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,6 @@ +.onLoad <- function(...) { + if (requireNamespace("ggplot2", quietly = TRUE)) { + vctrs::s3_register("ggplot2::autoplot", "pairwise") + vctrs::s3_register("ggplot2::scale_type", "supernova_number") + } +} diff --git a/README.Rmd b/README.Rmd index 1b7721d..a853873 100644 --- a/README.Rmd +++ b/README.Rmd @@ -13,7 +13,6 @@ knitr::opts_chunk$set( ) library(supernova) -library(mosaic) set.seed(123) ``` @@ -126,13 +125,13 @@ library(lme4) library(tidyr) library(dplyr) -simple_crossed <- JMRData::ex11.9 %>% - gather(condition, puzzles_completed, -subject) %>% +simple_crossed <- JMRData::ex11.9 |> + gather(condition, puzzles_completed, -subject) |> mutate_at(vars(subject, condition), as.factor) -multiple_crossed <- JMRData::ex11.17 %>% - gather(condition, recall, -Subject) %>% - separate(condition, c("type", "time"), -1) %>% +multiple_crossed <- JMRData::ex11.17 |> + gather(condition, recall, -Subject) |> + separate(condition, c("type", "time"), -1) |> mutate(across(c(Subject, type, time), as.factor)) ``` @@ -141,13 +140,13 @@ multiple_crossed <- JMRData::ex11.17 %>% Fitting the `simple_crossed` data with `lm()` would ignore the non-independence due to observations coming from the same `subject`. Compare this output with the following output where the model was fit with `lmer()` and the specification of `subject` as a random factor: ```{r} -simple_crossed %>% - lm(puzzles_completed ~ condition, data = .) %>% +simple_crossed |> + lm(puzzles_completed ~ condition, data = _) |> supernova(verbose = FALSE) # use lmer() to specify the non-independence -simple_crossed %>% - lmer(puzzles_completed ~ condition + (1 | subject), data = .) %>% +simple_crossed |> + lmer(puzzles_completed ~ condition + (1 | subject), data = _) |> supernova() ``` @@ -157,13 +156,13 @@ Here is another example like the previous, but here multiple variables (`time`, ```{r} # fitting this with lm would ignore the non-independence due to Subject -multiple_crossed %>% - lm(recall ~ type * time, data = .) %>% +multiple_crossed |> + lm(recall ~ type * time, data = _) |> supernova(verbose = FALSE) # using lmer() we can specify the non-independence -multiple_crossed %>% - lmer(recall ~ type * time + (1 | Subject) + (1 | type:Subject) + (1 | time:Subject), data = .) %>% +multiple_crossed |> + lmer(recall ~ type * time + (1 | Subject) + (1 | type:Subject) + (1 | time:Subject), data = _) |> supernova() ``` @@ -172,18 +171,18 @@ multiple_crossed %>% In this example, each person in a group of three generates a rating. If we fit the data with `lm()` that would ignore the non-independence due to the people being in the same `group`. Compare this output with the following output where the `group` is specified as a random factor. ```{r} -simple_nested <- JMRData::ex11.1 %>% - gather(id, value, starts_with("score")) %>% +simple_nested <- JMRData::ex11.1 |> + gather(id, value, starts_with("score")) |> mutate(across(c(group, instructions, id), as.factor)) # fitting this with lm would ignore the non-independence due to group -simple_nested %>% - lm(value ~ instructions, data = .) %>% +simple_nested |> + lm(value ~ instructions, data = _) |> supernova(verbose = FALSE) # using lmer() we can specify the non-independence -simple_nested %>% - lmer(value ~ instructions + (1 | group), data = .) %>% +simple_nested |> + lmer(value ~ instructions + (1 | group), data = _) |> supernova() ``` @@ -192,18 +191,18 @@ simple_nested %>% In this example, each person in heterosexual marriage generates a rating of satisfaction. Additionally, these couples were chosen such that they either have children or not, and have been married 15 vs. 30 years. If we fit the data with `lm()` that would ignore the non-independence due to the people being in the same `couple`. Compare this output with the following output where the `group` is specified as a random factor. ```{r} -complex_nested <- JMRData::ex11.22 %>% - gather(sex, rating, Male, Female) %>% +complex_nested <- JMRData::ex11.22 |> + gather(sex, rating, Male, Female) |> mutate(across(c(couple, children, sex, yearsmarried), as.factor)) # fitting this with lm would ignore the non-independence due to group -complex_nested %>% - lm(rating ~ sex * yearsmarried * children, data = .) %>% +complex_nested |> + lm(rating ~ sex * yearsmarried * children, data = _) |> supernova(verbose = FALSE) # using lmer() we can specify the non-independence -complex_nested %>% - lmer(rating ~ sex * yearsmarried * children + (1 | couple), data = .) %>% +complex_nested |> + lmer(rating ~ sex * yearsmarried * children + (1 | couple), data = _) |> supernova() ``` diff --git a/README.md b/README.md index a0c0a58..b2b8593 100644 --- a/README.md +++ b/README.md @@ -220,13 +220,13 @@ library(lme4) library(tidyr) library(dplyr) -simple_crossed <- JMRData::ex11.9 %>% - gather(condition, puzzles_completed, -subject) %>% +simple_crossed <- JMRData::ex11.9 |> + gather(condition, puzzles_completed, -subject) |> mutate_at(vars(subject, condition), as.factor) -multiple_crossed <- JMRData::ex11.17 %>% - gather(condition, recall, -Subject) %>% - separate(condition, c("type", "time"), -1) %>% +multiple_crossed <- JMRData::ex11.17 |> + gather(condition, recall, -Subject) |> + separate(condition, c("type", "time"), -1) |> mutate(across(c(Subject, type, time), as.factor)) ``` @@ -238,8 +238,8 @@ Compare this output with the following output where the model was fit with `lmer()` and the specification of `subject` as a random factor: ``` r -simple_crossed %>% - lm(puzzles_completed ~ condition, data = .) %>% +simple_crossed |> + lm(puzzles_completed ~ condition, data = _) |> supernova(verbose = FALSE) #> Analysis of Variance Table (Type III SS) #> Model: puzzles_completed ~ condition @@ -252,8 +252,8 @@ simple_crossed %>% #> Total | 23.000 15 1.533 # use lmer() to specify the non-independence -simple_crossed %>% - lmer(puzzles_completed ~ condition + (1 | subject), data = .) %>% +simple_crossed |> + lmer(puzzles_completed ~ condition + (1 | subject), data = _) |> supernova() #> Analysis of Variance Table (Type III SS) #> Model: puzzles_completed ~ condition + (1 | subject) @@ -278,8 +278,8 @@ Here is another example like the previous, but here multiple variables ``` r # fitting this with lm would ignore the non-independence due to Subject -multiple_crossed %>% - lm(recall ~ type * time, data = .) %>% +multiple_crossed |> + lm(recall ~ type * time, data = _) |> supernova(verbose = FALSE) #> Analysis of Variance Table (Type III SS) #> Model: recall ~ type * time @@ -295,8 +295,8 @@ multiple_crossed %>% #> Total | 232.167 29 8.006 # using lmer() we can specify the non-independence -multiple_crossed %>% - lmer(recall ~ type * time + (1 | Subject) + (1 | type:Subject) + (1 | time:Subject), data = .) %>% +multiple_crossed |> + lmer(recall ~ type * time + (1 | Subject) + (1 | type:Subject) + (1 | time:Subject), data = _) |> supernova() #> Analysis of Variance Table (Type III SS) #> Model: recall ~ type * time + (1 | Subject) + (1 | type:Subject) + (1 | time:Subject) @@ -326,13 +326,13 @@ to the people being in the same `group`. Compare this output with the following output where the `group` is specified as a random factor. ``` r -simple_nested <- JMRData::ex11.1 %>% - gather(id, value, starts_with("score")) %>% +simple_nested <- JMRData::ex11.1 |> + gather(id, value, starts_with("score")) |> mutate(across(c(group, instructions, id), as.factor)) # fitting this with lm would ignore the non-independence due to group -simple_nested %>% - lm(value ~ instructions, data = .) %>% +simple_nested |> + lm(value ~ instructions, data = _) |> supernova(verbose = FALSE) #> Analysis of Variance Table (Type III SS) #> Model: value ~ instructions @@ -345,8 +345,8 @@ simple_nested %>% #> Total | 28.500 17 1.676 # using lmer() we can specify the non-independence -simple_nested %>% - lmer(value ~ instructions + (1 | group), data = .) %>% +simple_nested |> + lmer(value ~ instructions + (1 | group), data = _) |> supernova() #> Analysis of Variance Table (Type III SS) #> Model: value ~ instructions + (1 | group) @@ -374,34 +374,34 @@ to the people being in the same `couple`. Compare this output with the following output where the `group` is specified as a random factor. ``` r -complex_nested <- JMRData::ex11.22 %>% - gather(sex, rating, Male, Female) %>% +complex_nested <- JMRData::ex11.22 |> + gather(sex, rating, Male, Female) |> mutate(across(c(couple, children, sex, yearsmarried), as.factor)) # fitting this with lm would ignore the non-independence due to group -complex_nested %>% - lm(rating ~ sex * yearsmarried * children, data = .) %>% +complex_nested |> + lm(rating ~ sex * yearsmarried * children, data = _) |> supernova(verbose = FALSE) #> Analysis of Variance Table (Type III SS) #> Model: rating ~ sex * yearsmarried * children #> -#> SS df MS F PRE p -#> ------------------------- | ------ -- ----- ------ ----- ----- -#> Model | 26.500 7 3.786 5.345 .6092 .0009 -#> sex | 0.000 1 0.000 0.000 .0000 .0000 -#> yearsmarried | 1.125 1 1.125 1.588 .0621 .2197 -#> children | 2.000 1 2.000 2.824 .1053 .1059 -#> sex:yearsmarried | 2.250 1 2.250 3.176 .1169 .0874 -#> sex:children | 0.062 1 0.062 0.088 .0037 .7690 -#> yearsmarried:children | 7.563 1 7.563 10.676 .3079 .0033 -#> sex:yearsmarried:children | 0.500 1 0.500 0.706 .0286 .4091 -#> Error | 17.000 24 0.708 -#> ------------------------- | ------ -- ----- ------ ----- ----- +#> SS df MS F PRE p +#> ------------------------- | ------ -- ----- ------ ----- ------ +#> Model | 26.500 7 3.786 5.345 .6092 .0009 +#> sex | 0.000 1 0.000 0.000 .0000 1.0000 +#> yearsmarried | 1.125 1 1.125 1.588 .0621 .2197 +#> children | 2.000 1 2.000 2.824 .1053 .1059 +#> sex:yearsmarried | 2.250 1 2.250 3.176 .1169 .0874 +#> sex:children | 0.063 1 0.063 0.088 .0037 .7690 +#> yearsmarried:children | 7.562 1 7.562 10.676 .3079 .0033 +#> sex:yearsmarried:children | 0.500 1 0.500 0.706 .0286 .4091 +#> Error | 17.000 24 0.708 +#> ------------------------- | ------ -- ----- ------ ----- ------ #> Total | 43.500 31 1.403 # using lmer() we can specify the non-independence -complex_nested %>% - lmer(rating ~ sex * yearsmarried * children + (1 | couple), data = .) %>% +complex_nested |> + lmer(rating ~ sex * yearsmarried * children + (1 | couple), data = _) |> supernova() #> Analysis of Variance Table (Type III SS) #> Model: rating ~ sex * yearsmarried * children + (1 | couple) @@ -516,7 +516,7 @@ appropriately evaluate each term in the full model. ``` r generate_models(lm(mpg ~ hp * disp, data = mtcars), type = 2) #> -#> ── Comparison Models for Type II SS ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +#> ── Comparison Models for Type II SS ──────────────────────────────────────────── #> #> ── Full Model #> complex: mpg ~ hp + disp + hp:disp @@ -564,7 +564,7 @@ pairwise comparisons like this: ``` r pairwise(lm(mpg ~ factor(am), data = mtcars)) #> -#> ── Tukey's Honestly Significant Differences ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +#> ── Tukey's Honestly Significant Differences ──────────────────────────────────── #> Model: mpg ~ factor(am) #> factor(am) #> Levels: 2 @@ -593,7 +593,7 @@ quantitative predictor: ``` r pairwise(lm(mpg ~ factor(am) + disp, data = mtcars)) #> -#> ── Tukey's Honestly Significant Differences ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +#> ── Tukey's Honestly Significant Differences ──────────────────────────────────── #> Model: mpg ~ factor(am) + disp #> factor(am) #> Levels: 2 diff --git a/cran-comments.md b/cran-comments.md index 6665fd0..bd33b66 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,23 +1,62 @@ ## Release summary -- Don't trim the leading digit from p-value or PRE when they are exactly 1 -- Fix issue on CRAN check when lme4 (optional) is not installed but is used in tests +- Remove deprecated `superanova()` +- Remove `magrittr`, `ggplot2`, and `backports` dependencies ## Test environments -- Local install on macOS Monterey 13.1 (ARM); R 4.2.1 +- Local install on macOS Monterey 13.1 (ARM); R 4.3.2 - GitHub Actions - - macOS: 12.6.3; R: 4.2.3 - - Microsoft Windows Server 2022: 10.0.20348; R: 4.2.3, 3.6.3 - - Ubuntu: 18.04.6; R: devel, 4.2.3, 4.1.3 + - macOS: 12.7.2; R: 4.3.2 + - Microsoft Windows Server 2022: 10.0.20348; R: 4.3.2, 3.6.3 + - Ubuntu: 22.04.3; R: devel, 4.3.2, 4.2.3 - `check_rhub()` - `check_win_devel()` ## R CMD check results -0 errors v | 0 warnings v | 0 notes v +There were 4 notes during the checks. -R CMD check succeeded +1. I am the maintainer of the package and have updated the email address. + + ``` + * checking CRAN incoming feasibility ... [15s] NOTE + Maintainer: 'Adam Blake ' + + New maintainer: + Adam Blake + Old maintainer(s): + Adam Blake + ``` + +2. On Windows Server 2022, R-devel, 64 bit: + + ``` + * checking for non-standard things in the check directory ... NOTE + Found the following files/directories: + ''NULL'' + ``` + + As noted in [R-hub issue #560](https://github.com/r-hub/rhub/issues/560), this seems to be an Rhub issue and so can likely be ignored. + +3. On Windows Server 2022, R-devel, 64 bit: + + ``` + * checking for detritus in the temp directory ... NOTE + Found the following files/directories: + 'lastMiKTeXException' + ``` + + As noted in [R-hub issue #503](https://github.com/r-hub/rhub/issues/503), this could be due to a bug/crash in MiKTeX and can likely be ignored. + +4. On Fedora Linux, R-devel, clang, gfortran, and on Ubuntu Linux 20.04.1 LTS, R-release, GCC: + + ``` + * checking HTML version of manual ... NOTE + Skipping checking HTML validation: no command 'tidy' found + ``` + + As noted in [R-hub issue #548](https://github.com/r-hub/rhub/issues/548), this is a missing formatter/linter on R-Hub and can likely be ignored. ## Reverse dependencies @@ -25,5 +64,4 @@ Dependencies were identified with `devtools::revdep()` and tested with `revdepch Packages: -- coursekata -- eda4treeR +- eda4treeR (meta-package with no code) diff --git a/man/autoplot.pairwise.Rd b/man/autoplot.pairwise.Rd new file mode 100644 index 0000000..214e7e4 --- /dev/null +++ b/man/autoplot.pairwise.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pairwise.R +\name{autoplot.pairwise} +\alias{autoplot.pairwise} +\alias{plot.pairwise} +\title{Plotting method for pairwise objects.} +\usage{ +autoplot.pairwise(object, ...) + +\method{plot}{pairwise}(x, y, ...) +} +\arguments{ +\item{object}{A \code{\link{pairwise}} object.} + +\item{...}{Additional arguments passed to the plotting geom.} + +\item{x}{A \code{pairwise} object.} + +\item{y}{Ignored, required for compatibility with the \code{plot()} generic.} +} +\description{ +Plotting method for pairwise objects. +} +\details{ +This function requires an optional dependency: \code{\link[ggplot2:ggplot2-package]{ggplot2}}. +When this package is installed, calling \code{autoplot()} or \code{plot} on a \code{pairwise} object will +generate a plot of the pairwise comparisons. The plot will show the differences between the +groups, with error bars representing the confidence intervals. The x-axis will be labeled with +the type of confidence interval used and the values of the differences, and the y-axis will be +labeled with the groups being compared. A dashed line at 0 is included to help visualize the +differences. +} +\examples{ +if (require(ggplot2)) { + # generate the plot immediately + pairwise(lm(mpg ~ factor(am) + disp, data = mtcars), plot = TRUE) + + # or save the object and plot it later + p <- pairwise(lm(mpg ~ factor(am) + disp, data = mtcars)) + plot(p) +} +} diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg deleted file mode 100644 index 48f72a6..0000000 --- a/man/figures/lifecycle-archived.svg +++ /dev/null @@ -1 +0,0 @@ - lifecyclelifecyclearchivedarchived \ No newline at end of file diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg deleted file mode 100644 index 01452e5..0000000 --- a/man/figures/lifecycle-defunct.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecycledefunctdefunct \ No newline at end of file diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg deleted file mode 100644 index 4baaee0..0000000 --- a/man/figures/lifecycle-deprecated.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecycledeprecateddeprecated \ No newline at end of file diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg deleted file mode 100644 index d1d060e..0000000 --- a/man/figures/lifecycle-experimental.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecycleexperimentalexperimental \ No newline at end of file diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg deleted file mode 100644 index df71310..0000000 --- a/man/figures/lifecycle-maturing.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecyclematuringmaturing \ No newline at end of file diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg deleted file mode 100644 index 08ee0c9..0000000 --- a/man/figures/lifecycle-questioning.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecyclequestioningquestioning \ No newline at end of file diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg deleted file mode 100644 index e015dc8..0000000 --- a/man/figures/lifecycle-stable.svg +++ /dev/null @@ -1 +0,0 @@ -lifecyclelifecyclestablestable \ No newline at end of file diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg deleted file mode 100644 index 75f24f5..0000000 --- a/man/figures/lifecycle-superseded.svg +++ /dev/null @@ -1 +0,0 @@ - lifecyclelifecyclesupersededsuperseded \ No newline at end of file diff --git a/man/pipe.Rd b/man/pipe.Rd deleted file mode 100644 index 0eec752..0000000 --- a/man/pipe.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils-pipe.R -\name{\%>\%} -\alias{\%>\%} -\title{Pipe operator} -\usage{ -lhs \%>\% rhs -} -\description{ -See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. -} -\keyword{internal} diff --git a/man/supernova.Rd b/man/supernova.Rd index 230f30a..e5e703f 100644 --- a/man/supernova.Rd +++ b/man/supernova.Rd @@ -2,15 +2,12 @@ % Please edit documentation in R/supernova.R \name{supernova} \alias{supernova} -\alias{superanova} \alias{supernova.lm} \alias{supernova.lmerMod} \title{supernova} \usage{ supernova(fit, type = 3, verbose = TRUE) -superanova(fit, type = 3, verbose = TRUE) - \method{supernova}{lm}(fit, type = 3, verbose = TRUE) \method{supernova}{lmerMod}(fit, type = 3, verbose = FALSE) @@ -40,12 +37,11 @@ error, an explicit summary of the whole model, separate formatting of p values, and is intended to match the output used in Judd, McClelland, and Ryan (2017). } -\details{ -\code{superanova()} is an alias of \code{supernova()} -} \examples{ supernova(lm(mpg ~ disp, data = mtcars)) -supernova(lm(mpg ~ disp, data = mtcars)) \%>\% print(pcut = 8) + +change_p_decimals <- supernova(lm(mpg ~ disp, data = mtcars)) +print(change_p_decimals, pcut = 8) } \references{ Judd, C. M., McClelland, G. H., & Ryan, C. S. (2017). \emph{Data diff --git a/revdep/README.md b/revdep/README.md index 4d3628b..88efb6b 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,32 +1,31 @@ # Platform -|field |value | -|:--------|:--------------------------------| -|version |R version 4.3.1 (2023-06-16) | -|os |macOS Sonoma 14.0 | -|system |aarch64, darwin23.0.0 | -|ui |unknown | -|language |(EN) | -|collate |en_US.UTF-8 | -|ctype |en_US.UTF-8 | -|tz |America/Los_Angeles | -|date |2023-11-04 | -|pandoc |3.1.9 @ /opt/homebrew/bin/pandoc | +| field | value | +| :------- | :---------------------------------- | +| version | R version 4.3.2 (2023-10-31) | +| os | macOS Sonoma 14.2.1 | +| system | aarch64, darwin23.2.0 | +| ui | unknown | +| language | (EN) | +| collate | en_US.UTF-8 | +| ctype | en_US.UTF-8 | +| tz | America/Los_Angeles | +| date | 2024-02-06 | +| pandoc | 3.1.11.1 @ /opt/homebrew/bin/pandoc | # Dependencies -|package |old |new |Δ | -|:---------|:-----|:-----|:--| -|supernova |2.5.7 |2.5.8 |* | -|rlang |NA |1.1.2 |* | -|withr |NA |2.5.2 |* | +| package | old | new | Δ | +| :-------- | :---- | :---- | :-- | +| supernova | 2.5.8 | 3.0.0 | \* | # Revdeps ## Failed to check (2) -|package |version |error |warning |note | -|:----------|:-------|:-----|:-------|:----| -|coursekata |? | | | | -|eda4treeR |? | | | | +Though these fail to check, the failures are not related to `supernova`. The `coursekata` package has been removed from CRAN, and the `eda4treeR` package is a meta-package that does not have any code to check. +| package | version | error | warning | note | +| :--------- | :------ | :---- | :------ | :--- | +| coursekata | ? | | | | +| eda4treeR | ? | | | | diff --git a/scripts/logo.R b/scripts/logo.R index e3fd8c2..9f6adc2 100644 --- a/scripts/logo.R +++ b/scripts/logo.R @@ -39,8 +39,8 @@ novas <- list(nova, rotate_180(nova)) # Plot ggplot(mapping = aes(x, y)) + - geom_polygon(data = hex_coords(4) %>% translate(dy = -1.3), fill = color$primary) + - geom_polygon(data = hex_coords(3.6) %>% translate(dy = -1.3), fill = color$dark) + + geom_polygon(data = hex_coords(4) |> translate(dy = -1.3), fill = color$primary) + + geom_polygon(data = hex_coords(3.6) |> translate(dy = -1.3), fill = color$dark) + geom_text( data = data.frame(x = 0, y = -2.8), label = "supernova", size = 20, color = color$light, family = "Consolas" @@ -60,6 +60,6 @@ ggsave( bg = "transparent" ) -load.image("man/figures/logo.png") %>% - autocrop() %>% +load.image("man/figures/logo.png") |> + autocrop() |> save.image("man/figures/logo.png") diff --git a/tests/testthat/_snaps/listwise_delete.md b/tests/testthat/_snaps/listwise_delete.md index cc1f732..c7c7643 100644 --- a/tests/testthat/_snaps/listwise_delete.md +++ b/tests/testthat/_snaps/listwise_delete.md @@ -2,7 +2,7 @@ Code listwise_delete(df_missing) - Message + Message 3 cases removed due to missing value(s). Output mpg cyl disp hp drat wt qsec vs am gear carb @@ -40,9 +40,10 @@ Code listwise_delete(model) - Message + Message Refitting to remove 3 cases with missing value(s) - i lm(formula = mpg ~ hp * disp, data = listwise_delete(df_missing, c("mpg", "hp", "disp"))) + i lm(formula = mpg ~ hp * disp, data = listwise_delete(df_missing, + c("mpg", "hp", "disp"))) Output Call: @@ -57,15 +58,16 @@ # it works in a pipe Code - . - Message + get_data_with_missing() %>% lm(mpg ~ hp * disp, data = .) %>% listwise_delete() + Message Refitting to remove 3 cases with missing value(s) - i lm(formula = mpg ~ hp * disp, data = listwise_delete(., c("mpg", "hp", "disp"))) + i lm(formula = mpg ~ hp * disp, data = listwise_delete(., c("mpg", + "hp", "disp"))) Output Call: lm(formula = mpg ~ hp * disp, data = listwise_delete(., c("mpg", - "hp", "disp"))) + "hp", "disp"))) Coefficients: (Intercept) hp disp hp:disp diff --git a/tests/testthat/_snaps/supernova.md b/tests/testthat/_snaps/supernova.md index 8c5393d..2e2b101 100644 --- a/tests/testthat/_snaps/supernova.md +++ b/tests/testthat/_snaps/supernova.md @@ -2,9 +2,10 @@ Code supernova(lm(mpg ~ hp, df_missing)) - Message + Message Refitting to remove 1 case with missing value(s) - i lm(formula = mpg ~ hp, data = listwise_delete(df_missing, c("mpg", "hp"))) + i lm(formula = mpg ~ hp, data = listwise_delete(df_missing, c("mpg", + "hp"))) Output Analysis of Variance Table (Type III SS) Model: mpg ~ hp @@ -20,9 +21,10 @@ Code supernova(lm(mpg ~ disp, df_missing)) - Message + Message Refitting to remove 2 cases with missing value(s) - i lm(formula = mpg ~ disp, data = listwise_delete(df_missing, c("mpg", "disp"))) + i lm(formula = mpg ~ disp, data = listwise_delete(df_missing, c("mpg", + "disp"))) Output Analysis of Variance Table (Type III SS) Model: mpg ~ disp @@ -38,9 +40,10 @@ Code supernova(lm(mpg ~ hp * disp, df_missing)) - Message + Message Refitting to remove 3 cases with missing value(s) - i lm(formula = mpg ~ hp * disp, data = listwise_delete(df_missing, c("mpg", "hp", "disp"))) + i lm(formula = mpg ~ hp * disp, data = listwise_delete(df_missing, + c("mpg", "hp", "disp"))) Output Analysis of Variance Table (Type III SS) Model: mpg ~ hp * disp @@ -117,18 +120,3 @@ ----- --------------- | -------- --- ------ --- --- --- Total (empty model) | 1126.047 31 36.324 -# perfectly fit models print 1.000 for PRE and p - - Code - supernova(model) - Output - Analysis of Variance Table (Type III SS) - Model: c(1:10) ~ c(11:20) - - SS df MS F PRE p - ----- --------------- | ------ - ------ ------------ ------ ----- - Model (error reduced) | 82.500 1 82.500 1.202968e+32 1.0000 .0000 - Error (from model) | 0.000 8 0.000 - ----- --------------- | ------ - ------ ------------ ------ ----- - Total (empty model) | 82.500 9 9.167 - diff --git a/tests/testthat/cache_test_data.R b/tests/testthat/cache_test_data.R deleted file mode 100644 index 0899094..0000000 --- a/tests/testthat/cache_test_data.R +++ /dev/null @@ -1,38 +0,0 @@ -# Run this to create the JMRData RDS files in ./data - -library(magrittr) -remotes::install_github("UCLATALL/JMRData") - -data_dir <- "./tests/testthat/data" -if (!dir.exists(data_dir)) dir.create(data_dir) - - -# Simple nested designs --------------------------------------------------- - -JMRData::ex11.1 %>% - tidyr::gather(id, value, dplyr::starts_with("score")) %>% - dplyr::mutate(dplyr::across(c(group, instructions, id), as.factor)) %>% - readr::write_rds(file.path(data_dir, "jmr_ex11.1.Rds")) - - -# Crossed designs --------------------------------------------------------- - -JMRData::ex11.9 %>% - tidyr::gather(condition, puzzles_completed, -subject) %>% - dplyr::mutate(dplyr::across(c(subject, condition), as.factor)) %>% - readr::write_rds(file.path(data_dir, "jmr_ex11.9.Rds")) - -JMRData::ex11.17 %>% - purrr::set_names(tolower(names(.))) %>% - tidyr::gather(condition, recall, -subject) %>% - tidyr::separate(condition, c("type", "time"), -1) %>% - dplyr::mutate(dplyr::across(c(subject, type, time), as.factor)) %>% - readr::write_rds(file.path(data_dir, "jmr_ex11.17.Rds")) - - -# Mixed designs ----------------------------------------------------------- - -JMRData::ex11.22 %>% - tidyr::gather(sex, rating, Male, Female) %>% - dplyr::mutate(dplyr::across(c(couple, children, sex, yearsmarried), as.factor)) %>% - readr::write_rds(file.path(data_dir, "jmr_ex11.22.Rds")) diff --git a/tests/testthat/data/jmr_ex11.1.Rds b/tests/testthat/data/jmr_ex11.1.Rds deleted file mode 100644 index 5eeeaa4..0000000 Binary files a/tests/testthat/data/jmr_ex11.1.Rds and /dev/null differ diff --git a/tests/testthat/data/jmr_ex11.17.Rds b/tests/testthat/data/jmr_ex11.17.Rds deleted file mode 100644 index 856b91a..0000000 Binary files a/tests/testthat/data/jmr_ex11.17.Rds and /dev/null differ diff --git a/tests/testthat/data/jmr_ex11.22.Rds b/tests/testthat/data/jmr_ex11.22.Rds deleted file mode 100644 index 38d7be5..0000000 Binary files a/tests/testthat/data/jmr_ex11.22.Rds and /dev/null differ diff --git a/tests/testthat/data/jmr_ex11.9.Rds b/tests/testthat/data/jmr_ex11.9.Rds deleted file mode 100644 index 2f566dc..0000000 Binary files a/tests/testthat/data/jmr_ex11.9.Rds and /dev/null differ diff --git a/tests/testthat/expected/jmr_ex11.1.csv b/tests/testthat/expected/jmr_ex11.1.csv deleted file mode 100644 index 25f0516..0000000 --- a/tests/testthat/expected/jmr_ex11.1.csv +++ /dev/null @@ -1,6 +0,0 @@ -term,SS,df,MS,F,PRE,p -instructions,12.5,1,12.5,4.686,0.54,0.096 -Error between subjects,10.67,4,2.67,NA,NA,NA -Total between subjects,23.17,5,4.63,NA,NA,NA -Total within subjects,5.33,12,0.44,NA,NA,NA -Total,28.5,17,1.68,NA,NA,NA diff --git a/tests/testthat/expected/jmr_ex11.17.csv b/tests/testthat/expected/jmr_ex11.17.csv deleted file mode 100644 index 1bd707d..0000000 --- a/tests/testthat/expected/jmr_ex11.17.csv +++ /dev/null @@ -1,10 +0,0 @@ -term,SS,df,MS,F,PRE,p -Total between subjects,131,4,32.75,NA,NA,NA -time,65.87,2,32.93,29.94,0.88,0 -time error,8.8,8,1.1,NA,NA,NA -type,17.63,1,17.63,11.38,0.74,0.028 -type error,6.2,4,1.55,NA,NA,NA -time:type,1.87,2,0.93,9.33,0.7,0.008 -time:type error,0.8,8,0.1,NA,NA,NA -Total within subjects,101.17,25,4.05,NA,NA,NA -Total,232.17,29,8.01,NA,NA,NA diff --git a/tests/testthat/expected/jmr_ex11.22.csv b/tests/testthat/expected/jmr_ex11.22.csv deleted file mode 100644 index 045ec0f..0000000 --- a/tests/testthat/expected/jmr_ex11.22.csv +++ /dev/null @@ -1,13 +0,0 @@ -term,SS,df,MS,F,PRE,p -yearsmarried,10.125,1,10.125,9.54,0.44,0.009 -children,0.5,1,0.5,0.48,0.04,0.506 -yearsmarried:children,10.125,1,10.125,9.54,0.44,0.009 -Error between subjects,12.75,12,1.0625,NA,NA,NA -Total between subjects,33.5,15,2.2333,NA,NA,NA -sex,3.125,1,3.125,8.82,0.42,0.012 -sex:yearsmarried,2,1,2,5.66,0.32,0.035 -sex:children,0.125,1,0.125,0.35,0.03,0.565 -sex:yearsmarried:children,0.505,1,0.5,1.42,0.11,0.256 -Error within subjects,4.255,12,0.3542,NA,NA,NA -Total within subjects,10,16,0.625,NA,NA,NA -Total,43.5,31,1.4,NA,NA,NA diff --git a/tests/testthat/expected/jmr_ex11.9.csv b/tests/testthat/expected/jmr_ex11.9.csv deleted file mode 100644 index 7c23d22..0000000 --- a/tests/testthat/expected/jmr_ex11.9.csv +++ /dev/null @@ -1,6 +0,0 @@ -term,SS,df,MS,F,PRE,p -Total between subjects,18,7,2.5714,NA,NA,NA -condition,2.25,1,2.25,5.727,0.45,0.04794 -Error within subjects,2.75,7,0.3929,NA,NA,NA -Total within subjects,5,8,0.625,NA,NA,NA -Total,23,15,1.5333,NA,NA,NA diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..6086637 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1,93 @@ +# Setup code for tests +# This file is sourced by testthat before running the test files. Make sure +# to register teardown code with tools like withr::defer(..., teardown_env()) + + +# Test Data ----------------------------------------------------------------- + +if (!rlang::is_installed("JMRData")) { + remotes::install_github("UCLATALL/JMRData") +} + +# The test data frames are all named using the format `test_jmr_{exhibit_number}`, where the exhibit +# number corresponds to the exhibit number in the textbook and JMRData package. The data in the +# textbook is formatted in a readable, wide format, so before using it in the tests, it is reshaped +# to a long format. + +# simple nested designs +test_jmr_ex11.1 <- JMRData::ex11.1 %>% + tidyr::gather(id, value, dplyr::starts_with("score")) %>% + dplyr::mutate(dplyr::across(c(group, instructions, id), as.factor)) %>% + data.frame() + +# crossed designs +test_jmr_ex11.9 <- JMRData::ex11.9 %>% + tidyr::gather(condition, puzzles_completed, -subject) %>% + dplyr::mutate(dplyr::across(c(subject, condition), as.factor)) %>% + data.frame() + +test_jmr_ex11.17 <- JMRData::ex11.17 %>% + rlang::set_names(tolower(names(JMRData::ex11.17))) %>% + tidyr::gather(condition, recall, -subject) %>% + tidyr::separate(condition, c("type", "time"), -1) %>% + dplyr::mutate(dplyr::across(c(subject, type, time), as.factor)) %>% + data.frame() + +# mixed designs +test_jmr_ex11.22 <- JMRData::ex11.22 %>% + tidyr::gather(sex, rating, Male, Female) %>% + dplyr::mutate(dplyr::across(c(couple, children, sex, yearsmarried), as.factor)) %>% + data.frame() + +# Expected Results ---------------------------------------------------------- + +# The expected results are all named using the format `expected_jmr_{exhibit_number}`, where the +# exhibit number corresponds to the exhibit number in the textbook and JMRData package. These are +# tibbles with the expected results of the an ANOVA where the compact model is the null model. + +expected_jmr_ex11.1 <- tibble::tribble( + ~term, ~SS, ~df, ~MS, ~F, ~PRE, ~p, + "instructions", 12.5, 1, 12.5, 4.686, 0.54, 0.096, + "Error between subjects", 10.67, 4, 2.67, NA, NA, NA, + "Total between subjects", 23.17, 5, 4.63, NA, NA, NA, + "Total within subjects", 5.33, 12, 0.44, NA, NA, NA, + "Total", 28.5, 17, 1.68, NA, NA, NA +) %>% data.frame() + +expected_jmr_ex11.9 <- tibble::tribble( + ~term, ~SS, ~df, ~MS, ~F, ~PRE, ~p, + "Total between subjects", 18, 7, 2.5714, NA, NA, NA, + "condition", 2.25, 1, 2.25, 5.727, 0.45, 0.04794, + "Error within subjects", 2.75, 7, 0.3929, NA, NA, NA, + "Total within subjects", 5, 8, 0.625, NA, NA, NA, + "Total", 23, 15, 1.5333, NA, NA, NA +) %>% data.frame() + +expected_jmr_ex11.17 <- tibble::tribble( + ~term, ~SS, ~df, ~MS, ~F, ~PRE, ~p, + "Total between subjects", 131, 4, 32.75, NA, NA, NA, + "time", 65.87, 2, 32.93, 29.94, 0.88, 0, + "time error", 8.8, 8, 1.1, NA, NA, NA, + "type", 17.63, 1, 17.63, 11.38, 0.74, 0.028, + "type error", 6.2, 4, 1.55, NA, NA, NA, + "time:type", 1.87, 2, 0.93, 9.33, 0.7, 0.008, + "time:type error", 0.8, 8, 0.1, NA, NA, NA, + "Total within subjects", 101.17, 25, 4.05, NA, NA, NA, + "Total", 232.17, 29, 8.01, NA, NA, NA +) %>% data.frame() + +expected_jmr_ex11.22 <- tibble::tribble( + ~term, ~SS, ~df, ~MS, ~F, ~PRE, ~p, + "yearsmarried", 10.125, 1, 10.125, 9.54, 0.44, 0.009, + "children", 0.5, 1, 0.5, 0.48, 0.04, 0.506, + "yearsmarried:children", 10.125, 1, 10.125, 9.54, 0.44, 0.009, + "Error between subjects", 12.75, 12, 1.0625, NA, NA, NA, + "Total between subjects", 33.5, 15, 2.2333, NA, NA, NA, + "sex", 3.125, 1, 3.125, 8.82, 0.42, 0.012, + "sex:yearsmarried", 2, 1, 2, 5.66, 0.32, 0.035, + "sex:children", 0.125, 1, 0.125, 0.35, 0.03, 0.565, + "sex:yearsmarried:children", 0.505, 1, 0.5, 1.42, 0.11, 0.256, + "Error within subjects", 4.255, 12, 0.3542, NA, NA, NA, + "Total within subjects", 10, 16, 0.625, NA, NA, NA, + "Total", 43.5, 31, 1.4, NA, NA, NA +) %>% data.frame() diff --git a/tests/testthat/test-generate_models.R b/tests/testthat/test-generate_models.R index d2e66a3..5b47b22 100644 --- a/tests/testthat/test-generate_models.R +++ b/tests/testthat/test-generate_models.R @@ -1,4 +1,3 @@ - # Helpers ------------------------------------------------------------------------------------- test_formula <- y ~ a * b * c diff --git a/tests/testthat/test-listwise_delete.R b/tests/testthat/test-listwise_delete.R index 428a819..4100bb2 100644 --- a/tests/testthat/test-listwise_delete.R +++ b/tests/testthat/test-listwise_delete.R @@ -1,4 +1,3 @@ - get_data_with_missing <- function() { df_missing <- mtcars df_missing[1, ]$hp <- NA_real_ @@ -31,10 +30,11 @@ test_that("it refits an lm with missing data with a message about the new call", }) test_that("it works in a pipe", { - get_data_with_missing() %>% - lm(mpg ~ hp * disp, data = .) %>% - listwise_delete() %>% - expect_snapshot() + expect_snapshot( + get_data_with_missing() %>% + lm(mpg ~ hp * disp, data = .) %>% + listwise_delete() + ) }) test_that("it works when the call is long and breaks multiple lines when using deparse", { diff --git a/tests/testthat/test-supernova.lmerMod.R b/tests/testthat/test-supernova.lmerMod.R index a53c690..8c9dc40 100644 --- a/tests/testthat/test-supernova.lmerMod.R +++ b/tests/testthat/test-supernova.lmerMod.R @@ -7,18 +7,7 @@ # Helper functions -------------------------------------------------------- -get_data <- function(name) { - prefix <- if (interactive()) "./tests/testthat/" else "./" - readRDS(file.path(prefix, "data", paste0(name, ".Rds"))) -} - -get_expected <- function(name) { - prefix <- if (interactive()) "./tests/testthat/" else "./" - read.csv(file.path(prefix, "expected", paste0(name, ".csv")), stringsAsFactors = FALSE) -} - fit_lmer <- function(formula, data) { - skip_if_not_installed("lme4") lme4::lmer( formula, data = data, @@ -35,9 +24,8 @@ fit_lmer <- function(formula, data) { test_that("cannot compute SS types other than Type III for lmerMod", { model <- fit_lmer( puzzles_completed ~ condition + (1 | subject), - data = get_data("jmr_ex11.9") + test_jmr_ex11.9 ) - expect_error(supernova(model, type = 1)) expect_error(supernova(model, type = 2)) }) @@ -45,9 +33,8 @@ test_that("cannot compute SS types other than Type III for lmerMod", { test_that("there is no verbose print for lmerMod (warn and switch off)", { model <- fit_lmer( puzzles_completed ~ condition + (1 | subject), - data = get_data("jmr_ex11.9") + test_jmr_ex11.9 ) - expect_warning(supernova(model, verbose = TRUE)) }) @@ -57,7 +44,7 @@ test_that("there is no verbose print for lmerMod (warn and switch off)", { test_that("supernova object has table, fit, and models", { model <- fit_lmer( puzzles_completed ~ condition + (1 | subject), - data = get_data("jmr_ex11.9") + test_jmr_ex11.9 ) obj <- supernova(model, type = 3) @@ -80,25 +67,17 @@ test_that("supernova object has table, fit, and models", { )) }) -test_that("magrittr can pipe lmer() to supernova", { - fit_lmer( - puzzles_completed ~ condition + (1 | subject), - data = get_data("jmr_ex11.9") - ) %>% +test_that("supernova works when lmer() is piped in", { + fit_lmer(puzzles_completed ~ condition + (1 | subject), test_jmr_ex11.9) %>% supernova() %>% expect_s3_class("supernova") }) -test_that("magrittr can pipe data to lm() to supernova", { - skip_if( - package_version(R.version) < "3.5", - "This is only skipped to make this package compatible with DataCamp Light." - ) - +test_that("supernova works when data is piped into lmer() is piped in", { # Believe it or not, this might not work. Do not remove or refactor test. - # When stats::update() tries to get the call, the data object is just "." - # supernova has to middle-man with supernova::update() to get this to work - get_data("jmr_ex11.9") %>% + # When stats::update() tries to get the call, the data object is just the + # placeholder. supernova has to middle-man with supernova::update() + test_jmr_ex11.9 %>% fit_lmer(puzzles_completed ~ condition + (1 | subject), data = .) %>% supernova() %>% expect_s3_class("supernova") @@ -110,12 +89,12 @@ test_that("magrittr can pipe data to lm() to supernova", { test_that("supernova can test simple nested designs", { model <- fit_lmer( value ~ instructions + (1 | group), - data = get_data("jmr_ex11.1") + test_jmr_ex11.1 ) expect_equal( supernova(model)$tbl, - get_expected("jmr_ex11.1"), + expected_jmr_ex11.1, tolerance = 0.01 ) }) @@ -123,12 +102,12 @@ test_that("supernova can test simple nested designs", { test_that("supernova can test simple crossed designs", { model <- fit_lmer( puzzles_completed ~ condition + (1 | subject), - data = get_data("jmr_ex11.9") + test_jmr_ex11.9 ) expect_equal( supernova(model)$tbl, - get_expected("jmr_ex11.9"), + expected_jmr_ex11.9, tolerance = 0.001 ) }) @@ -136,12 +115,12 @@ test_that("supernova can test simple crossed designs", { test_that("supernova can test multiple crossed designs", { model <- fit_lmer( recall ~ time * type + (1 | subject) + (1 | time:subject) + (1 | type:subject), - data = get_data("jmr_ex11.17") + test_jmr_ex11.17 ) expect_equal( supernova(model)$tbl, - get_expected("jmr_ex11.17"), + expected_jmr_ex11.17, tolerance = 0.01 ) }) @@ -149,12 +128,12 @@ test_that("supernova can test multiple crossed designs", { test_that("supernova can test mixed designs", { model <- fit_lmer( rating ~ sex * yearsmarried * children + (1 | couple), - data = get_data("jmr_ex11.22") + test_jmr_ex11.22 ) expect_equal( supernova(model)$tbl, - get_expected("jmr_ex11.22"), + expected_jmr_ex11.22, tolerance = 0.01 ) }) @@ -165,7 +144,7 @@ test_that("supernova can test mixed designs", { test_that("nested repeated measures tables are beautifully formatted", { model <- fit_lmer( value ~ instructions + (1 | group), - data = get_data("jmr_ex11.1") + test_jmr_ex11.1 ) expect_snapshot(supernova(model)) @@ -179,7 +158,7 @@ test_that("crossed repeated measures tables are beautifully formatted", { model <- fit_lmer( rating ~ sex * yearsmarried * children + (1 | couple), - data = get_data("jmr_ex11.22") + test_jmr_ex11.22 ) expect_snapshot(supernova(model)) diff --git a/tests/testthat/test-supernova.r b/tests/testthat/test-supernova.r index 6d292dc..b7c03d9 100644 --- a/tests/testthat/test-supernova.r +++ b/tests/testthat/test-supernova.r @@ -189,13 +189,13 @@ test_that("supernova table structure is well-formed", { # TODO: what about verbose table structure? }) -test_that("magrittr can pipe lm() to supernova", { +test_that("supernova works when lm() is piped in", { lm(mpg ~ NULL, mtcars) %>% supernova() %>% expect_s3_class("supernova") }) -test_that("magrittr can pipe data to lm() to supernova", { +test_that("supernova works when data is piped into lm() is piped in", { # Believe it or not, this might not work. Do not remove or re-factor test. # When stats::update() tries to get the call, the data object is just "." # supernova has to middle-man with supernova::update() to get this to work @@ -218,15 +218,11 @@ test_that("supernova calcs. (quant. ~ NULL) ANOVA correctly", { model <- lm(mpg ~ NULL, data = mtcars) actual <- supernova(model)$tbl expected <- anova(model) + numbers_only <- function(x) unname(as.matrix(x)) - numbers_only <- function(x) { - x %>% - as.matrix() %>% - unname() - } expect_identical( - actual[3, c("SS", "df", "MS", "F", "p")] %>% numbers_only(), - expected[c("Sum Sq", "Df", "Mean Sq", "F value", "Pr(>F)")] %>% numbers_only() + numbers_only(actual[3, c("SS", "df", "MS", "F", "p")]), + numbers_only(expected[c("Sum Sq", "Df", "Mean Sq", "F value", "Pr(>F)")]) ) }) @@ -354,5 +350,8 @@ test_that("non-verbose tables do not have a description column", { test_that("perfectly fit models print 1.000 for PRE and p", { model <- lm(c(1:10) ~ c(11:20)) - expect_snapshot(supernova(model)) + # f statistic can be unreliable to reproduce + supernova(model) %>% + print() %>% + expect_output("1.0000 .0000\n") }) diff --git a/tests/testthat/test-variables.R b/tests/testthat/test-variables.R index f9483bb..b9d63fa 100644 --- a/tests/testthat/test-variables.R +++ b/tests/testthat/test-variables.R @@ -1,22 +1,12 @@ - # Helper functions -------------------------------------------------------- - -get_data <- function(name) { - prefix <- if (interactive()) "./tests/testthat/" else "./" - readRDS(file.path(prefix, "data", paste0(name, ".Rds"))) -} - - fit_lmer <- function(frm, data) { lme4::lmer(frm, data = data, na.action = na.omit, subset = NULL, weights = NULL, offset = NULL) } - # General tests ----------------------------------------------------------- - test_that("variables are extracted from bare formulae", { expect_identical(variables(mpg ~ hp), list( outcome = "mpg", @@ -124,7 +114,11 @@ test_that("variables are extracted from complex between models with interactions test_that("variables are extracted from simple nested models", { - model <- fit_lmer(value ~ instructions + (1 | group), data = get_data("jmr_ex11.1")) + model <- fit_lmer( + value ~ instructions + (1 | group), + test_jmr_ex11.1 + ) + expect_identical( variables(model), list( @@ -139,7 +133,11 @@ test_that("variables are extracted from simple nested models", { test_that("variables are extracted from simple crossed models", { - model <- fit_lmer(puzzles_completed ~ condition + (1 | subject), data = get_data("jmr_ex11.9")) + model <- fit_lmer( + puzzles_completed ~ condition + (1 | subject), + test_jmr_ex11.9 + ) + expect_identical( variables(model), list( @@ -154,7 +152,11 @@ test_that("variables are extracted from simple crossed models", { test_that("variables are extracted from simple crossed models with interactions", { - model <- fit_lmer(recall ~ type * time + (1 | subject), data = get_data("jmr_ex11.17")) + model <- fit_lmer( + recall ~ type * time + (1 | subject), + test_jmr_ex11.17 + ) + expect_identical( variables(model), list( @@ -171,7 +173,7 @@ test_that("variables are extracted from simple crossed models with interactions" test_that("variables are extracted from models with multiple crossed variables", { model <- fit_lmer( recall ~ time * type + (1 | subject) + (1 | time:subject) + (1 | type:subject), - data = get_data("jmr_ex11.17") + data = test_jmr_ex11.17 ) expect_identical( variables(model), @@ -189,7 +191,7 @@ test_that("variables are extracted from models with multiple crossed variables", test_that("variables are extracted from mixed models with interactions", { model <- fit_lmer( rating ~ sex * yearsmarried * children + (1 | couple), - data = get_data("jmr_ex11.22") + test_jmr_ex11.22 ) expect_identical( variables(model),