diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf..df8b200 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,6 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +^LICENSE\.md$ +^revdep$ +^cran-comments\.md$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..f4b17a4 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,29 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml new file mode 100644 index 0000000..ee65ccb --- /dev/null +++ b/.github/workflows/check-full.yaml @@ -0,0 +1,62 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +# +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + + - {os: windows-latest, r: 'release'} + # Use 3.6 to trigger usage of RTools35 + - {os: windows-latest, r: '3.6'} + # use 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: '4.1'} + + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true diff --git a/.gitignore b/.gitignore index 5b6a065..b64a99f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .Rhistory .RData .Ruserdata +revdep/ diff --git a/AutoPlots_1.0.0.tar.gz b/AutoPlots_1.0.0.tar.gz new file mode 100644 index 0000000..50d820b Binary files /dev/null and b/AutoPlots_1.0.0.tar.gz differ diff --git a/DESCRIPTION b/DESCRIPTION index 5b023c7..10f3794 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,24 +1,37 @@ Package: AutoPlots -Title: AutoPlots +Title: Simple Functions for Creating Echarts Visualizations Version: 1.0.0 -Date: 2023-03-15 +Date: 2023-11-06 Authors@R: - c(person(given = "Adrian", - family = "Antico", - role = c("aut","cre","ctb"))) + person("Adrian", "Antico", , "adrianantico@gmail.com", role = c("aut", "cre", "cph")) +Author: Adrian Antico [aut, cre, cph] Maintainer: Adrian Antico -Description: R package for generating plots in a simple way +Description: R package for generating Echarts visualization with a single + function call. The functions are designed to be as similar as possible + to each other, using common naming conventions. +License: AGPL (>= 3) URL: https://github.com/AdrianAntico/AutoPlots BugReports: https://github.com/AdrianAntico/AutoPlots/issues -Depends: R (>= 4.0.0) -Imports: bit64, data.table, echarts4r, dplyr -Suggests: knitr, rmarkdown -VignetteBuilder: knitr +Depends: + R (>= 4.0.0) +Imports: + combinat, + data.table, + devtools, + dplyr, + e1071, + echarts4r, + lubridate, + nortest, + quanteda, + quanteda.textstats, + scales, + stats, + utils Contact: Adrian Antico Encoding: UTF-8 Language: en-US LazyData: true NeedsCompilation: no -Packaged: 2023-03-15 14:00:00 UTC +Packaged: 2023-11-06 14:00:00 UTC RoxygenNote: 7.2.3 -Author: Adrian Antico [aut, cre] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index cbea4c2..0000000 --- a/LICENSE +++ /dev/null @@ -1,182 +0,0 @@ -GNU AFFERO GENERAL PUBLIC LICENSE -Version 3, 19 November 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. - -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. - -TERMS AND CONDITIONS -0. Definitions. -"This License" refers to version 3 of the GNU Affero 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. - -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 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 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 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 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..fab6548 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,659 @@ +GNU Affero General Public License +================================= + +_Version 3, 19 November 2007_ +_Copyright (C) 2007 Free Software Foundation, Inc. <>_ + +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. + +## TERMS AND CONDITIONS + +### 0. Definitions. + +"This License" refers to version 3 of the GNU Affero 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. + +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 +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 +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 +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 + +## 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 . diff --git a/NAMESPACE b/NAMESPACE index 33ec4d0..0e5cf00 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,9 @@ # Generated by roxygen2: do not edit by hand -export(BuildBinary) +export(AutoLagRollStats) +export(DT_GDL_Feature_Engineering) +export(DummifyDT) export(FakeDataGenerator) -export(Install) export(Plot.ACF) export(Plot.Area) export(Plot.Bar) @@ -44,7 +45,6 @@ export(Plot.Step) export(Plot.VariableImportance) export(Plot.WordCloud) export(Plots.ModelEvaluation) -export(UpdateDocs) import(data.table) importFrom(data.table,"%chin%") importFrom(data.table,"%like%") @@ -64,4 +64,20 @@ importFrom(data.table,setcolorder) importFrom(data.table,setnames) importFrom(data.table,setorderv) importFrom(lubridate,"%m+%") +importFrom(stats,as.formula) +importFrom(stats,cor) +importFrom(stats,cor.test) +importFrom(stats,dgeom) +importFrom(stats,lm) +importFrom(stats,median) +importFrom(stats,na.omit) +importFrom(stats,optimize) +importFrom(stats,pnorm) +importFrom(stats,qnorm) +importFrom(stats,quantile) +importFrom(stats,runif) +importFrom(stats,sd) +importFrom(stats,setNames) +importFrom(stats,var) +importFrom(utils,head) importFrom(utils,installed.packages) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..b375d3b --- /dev/null +++ b/NEWS.md @@ -0,0 +1,43 @@ +# AutoPlots 1.0.0 +Initial version + +100% data.table backend for fast data processing + +Chart types: + +Histogram Plots +Density Plots +Box Plots +Probability Plots +Word Cloud +Pie Charts +Donut Plot +Rosetype Plot +Bar Plots +3D Bar Plots +Stacked Bar Plots +Radar Plots +Line Plots +Step Plots +Area Plots +River Plots +Autocorrelation Plot +Partial Autocorrelation Plot +Scatter Plots +3D Scatter Plots +Copula Plots +3D Copula Plots +Correlation Matrix Plots +Parallel Plots +Heatmaps +Calibration Plots +Calibration Scatter Plots +Partital Dependence Plots +Partital Dependence Heatmaps +Variable Importance Plots +Shapely Importance Plots +ROC Plots +Confusion Matrix Heatmaps +Lift Plots +Gain Plots +BinaryMetrics diff --git a/R/AccessoryFunctions.R b/R/AccessoryFunctions.R new file mode 100644 index 0000000..741ae52 --- /dev/null +++ b/R/AccessoryFunctions.R @@ -0,0 +1,2433 @@ +# AutoPlots is a package for quickly creating high quality visualizations under a common and easy api. +# 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 WAfppRRANTY; 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 . + +# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ---- +# :: Helper Functions :: ---- +# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ---- + +#' @noRd +SummaryFunction <- function(AggMethod) { + if(AggMethod == "count") { + aggFunc <- function(x) .N + } else if(AggMethod == "mean") { + aggFunc <- function(x) mean(x, na.rm = TRUE) + } else if(AggMethod == "log(mean(x))") { + aggFunc <- function(x) log(mean(x, na.rm = TRUE)) + } else if(AggMethod == "mean(abs(x))") { + aggFunc <- function(x) mean(abs(x), na.rm = TRUE) + } else if(AggMethod == "sum") { + aggFunc <- function(x) sum(x, na.rm = TRUE) + } else if(AggMethod == "log(sum(x))") { + aggFunc <- function(x) log(sum(x, na.rm = TRUE)) + } else if(AggMethod == "sum(abs(x))") { + aggFunc <- function(x) sum(abs(x), na.rm = TRUE) + } else if(AggMethod == "median") { + aggFunc <- function(x) median(x, na.rm = TRUE) + } else if(AggMethod == "log(median(x))") { + aggFunc <- function(x) log(median(x, na.rm = TRUE)) + } else if(AggMethod == "median(abs(x))") { + aggFunc <- function(x) median(abs(x), na.rm = TRUE) + } else if(AggMethod == "sd") { + aggFunc <- function(x) sd(x, na.rm = TRUE) + } else if(AggMethod == "log(sd(x))") { + aggFunc <- function(x) log(sd(x, na.rm = TRUE)) + } else if(AggMethod == "sd(abs(x))") { + aggFunc <- function(x) sd(abs(x), na.rm = TRUE) + } else if(AggMethod == "skewness") { + aggFunc <- function(x) e1071::skewness(x, na.rm = TRUE) + } else if(AggMethod == "skewness(abs(x))") { + aggFunc <- function(x) e1071::skewness(abs(x), na.rm = TRUE) + } else if(AggMethod == "kurtosis") { + aggFunc <- function(x) e1071::kurtosis(x, na.rm = TRUE) + } else if(AggMethod == "kurtosis(abs(x))") { + aggFunc <- function(x) e1071::kurtosis(abs(x), na.rm = TRUE) + } else if(AggMethod == "CoeffVar") { + aggFunc <- function(x) sd(x, na.rm = TRUE) / mean(x, na.rm = TRUE) + } else if(AggMethod == "CoeffVar(abs(x))") { + aggFunc <- function(x) sd(abs(x), na.rm = TRUE) / mean(abs(x), na.rm = TRUE) + } + return(aggFunc) +} + +#' @noRd +ColTypes <- function(data) { + CT <- c() + for(Col in names(data)) CT <- c(CT, class(data[[Col]])[1L]) + CT +} + +#' @noRd +bold_ <- function(x) paste0('',x,'') + +#' @noRd +font_ <- function(family = "Segoe UI Symbol", size = 12, color = 'white') list(family = family, size = size, color = color) + +#' @noRd +ColNameFilter <- function(data, Types = 'all') { + if(Types == 'all') return(names(data)) + nam <- c() + for(t in Types) { + if(tolower(t) == 'numeric') { + nam <- NumericColNames(data) + } else if(tolower(t) == 'character') { + nam <- CharacterColNames(data) + } else if(tolower(t) == 'factor') { + nam <- FactorColNames(data) + } else if(tolower(t) == 'logical') { + nam <- LogicalColNames(data) + } else if(tolower(t) %chin% c("date","idate","idatetime","posixct","posix")) { + nam <- DateColNames(data) + } + } + return(nam) +} + +#' @noRd +NumericColNames <- function(data) { + x <- as.list(names(data)[which(sapply(data, is.numeric))]) + if(!identical(x, character(0))) return(x) else return(NULL) +} + +#' @noRd +CharacterColNames <- function(data) { + x <- as.list(names(data)[which(sapply(data, is.character))]) + if(!identical(x, character(0))) return(x) else return(NULL) +} + +#' @noRd +FactorColNames <- function(data) { + x <- as.list(names(data)[which(sapply(data, is.factor))]) + if(!identical(x, character(0))) return(x) else return(NULL) +} + +#' @noRd +LogicalColNames <- function(data) { + x <- as.list(names(data)[which(sapply(data, is.logical))]) + if(!identical(x, character(0))) return(x) else return(NULL) +} + +#' @noRd +DateColNames <- function(data) { + x <- list() + counter <- 0L + for(i in names(data)) { + if(class(data[[i]])[1L] %in% c("IDate","Date","date","POSIXct","POSIX")) { + counter <- counter + 1L + x[[counter]] <- i + } + } + if(length(x) > 0L) return(x) else return(NULL) +} + +#' # text & logical with NULL default +#' @noRd +CEP <- function(x) if(any(missing(x))) 'NULL' else if(!exists('x')) 'NULL' else if(is.null(x)) "NULL" else if(identical(x, character(0))) "NULL" else if(identical(x, numeric(0))) "NULL" else if(identical(x, integer(0))) "NULL" else if(identical(x, logical(0))) "NULL" else if(any(x == "")) "NULL" else if(any(is.na(x))) "NULL" else if(any(x == 'None')) "NULL" else if(is.numeric(x)) x else if(length(x) > 1) paste0("c(", noquote(paste0("'", x, "'", collapse = ',')), ")") else paste0("'", x, "'") + +#' # number and logical with FALSE / TRUE default +#' @noRd +CEPP <- function(x, Default = NULL, Type = 'character') if(missing(x)) 'NULL' else if(!exists('x')) 'NULL' else if(length(x) == 0) 'NULL' else if(any(is.na(x))) 'NULL' else if(all(x == "")) 'NULL' else if(Type == 'numeric') NumNull(x) else if(Type == 'character') CharNull(x) + +#' @title ExpandText +#' +#' @description This function is for pasting character vector arguments into their respective parameter slots for code printing (and command line vector argument passing) +#' +#' +#' @noRd +ExpandText <- function(x) { + if(length(x) > 0L) { + if(is.character(x) || is.factor(x) || lubridate::is.Date(x) || lubridate::is.POSIXct(x)) { + return(paste0("c('", paste0(x, collapse = "','"), "')")) + } else if(is.numeric(x) || is.logical(x)) { + return(paste0("c(", paste0(x, collapse = ","), ")")) + } + } else { + return('NULL') + } +} + +#' @title CharNull +#' +#' @param x Value +#' +#' @noRd +CharNull <- function(x, Char = FALSE) { + + if(missing(x)) { + print('CharNull: missing x') + return(NULL) + } + + if(!exists('x')) { + print('CharNull: x does not exist') + return(NULL) + } + + if(length(x) == 0) { + print('CharNull: length(x) == 0') + return(NULL) + } + + if(all(is.na(suppressWarnings(as.character(x))))) { + + return(NULL) + + } else if(any(is.na(suppressWarnings(as.character(x)))) && length(x) > 1) { + + x <- x[!is.na(x)] + x <- suppressWarnings(as.character(x)) + return(x) + + } else if(any(is.na(suppressWarnings(as.character(x)))) && length(x) == 1) { + + return(NULL) + + } else { + + x <- suppressWarnings(as.character(x)) + return(x) + + } + + if(!Char) { + return(NULL) + } else { + return("NULL") + } +} + +#' @title FakeDataGenerator +#' +#' @description Create fake data for examples +#' +#' @author Adrian Antico +#' @family Data Wrangling +#' +#' @param Correlation Set the correlation value for simulated data +#' @param N Number of records +#' @param ID Number of IDcols to include +#' @param ZIP Zero Inflation Model target variable creation. Select from 0 to 5 to create that number of distinctly distributed data, stratifed from small to large +#' @param FactorCount Number of factor type columns to create +#' @param AddDate Set to TRUE to include a date column +#' @param AddComment Set to TRUE to add a comment column +#' @param AddWeightsColumn Add a weights column for ML +#' @param ChainLadderData Set to TRUE to return Chain Ladder Data for using AutoMLChainLadderTrainer +#' @param Classification Set to TRUE to build classification data +#' @param MultiClass Set to TRUE to build MultiClass data +#' +#' @return data.table of data +#' @export +FakeDataGenerator <- function(Correlation = 0.70, + N = 1000L, + ID = 5L, + FactorCount = 2L, + AddDate = TRUE, + AddComment = FALSE, + AddWeightsColumn = FALSE, + ZIP = 5L, + ChainLadderData = FALSE, + Classification = FALSE, + MultiClass = FALSE) { + + # Error checking + if(sum(Classification, MultiClass) > 1) stop("Only one of the following can be set to TRUE: Classifcation, and MultiClass") + + # Create ChainLadderData + if(ChainLadderData) { + + # Overwrite N + N <- 1000 + + # Define constants + MaxCohortDays <- 15L + + # Start date + CalendarDateData <- data.table::data.table(CalendarDateColumn = rep(as.Date("2018-01-01"), N), key = "CalendarDateColumn") + + # Increment date column so it is sequential + CalendarDateData[, temp := seq_len(N)] + CalendarDateData[, CalendarDateColumn := CalendarDateColumn + lubridate::days(temp) - 1L] + CohortDate_temp <- data.table::copy(CalendarDateData) + data.table::setnames(x = CohortDate_temp, old = c("CalendarDateColumn"), new = c("CohortDate_temp")) + + # Cross join the two data sets + ChainLadderData <- data.table::setkeyv(data.table::CJ( + CalendarDateColumn = CalendarDateData$CalendarDateColumn, + CohortDateColumn = CohortDate_temp$CohortDate_temp, + sorted = TRUE, + unique = TRUE), + cols = c("CalendarDateColumn", "CohortDateColumn")) + + # Remove starter data sets and N + rm(CalendarDateData, CohortDate_temp, N) + + # Remove impossible dates + ChainLadderData <- ChainLadderData[CohortDateColumn >= CalendarDateColumn] + + # Add CohortPeriods + ChainLadderData[, CohortDays := as.numeric(difftime(CohortDateColumn, CalendarDateColumn, tz = "MST", units = "day"))] + + # Limit the number of CohortTime + ChainLadderData <- ChainLadderData[CohortDays < MaxCohortDays] + + # Add measure columns placeholder values + ChainLadderData[, ":=" (Leads = 0, Appointments = 0, Rates = 0)] + + # Sort decending both date columns + data.table::setorderv(x = ChainLadderData, cols = c("CalendarDateColumn","CohortDateColumn"), order = c(-1L, 1L)) + + # Add columns for BaselineMeasure and ConversionMeasure + UniqueCalendarDates <- unique(ChainLadderData$CalendarDateColumn) + NN <- length(UniqueCalendarDates) + LoopSeq <- c(1:15) + LoopSeq <- cumsum(LoopSeq) + LoopSeq <- c(1, LoopSeq) + LoopSeq <- c(LoopSeq, seq(135, 15*993, 15)) + for(cal in seq(NN)) { + + # Generate first element of decay data + DecayCurveData <- dgeom(x = 0, prob = runif(n = 1L, min = 0.45, max = 0.55), log = FALSE) + + # Fill in remain elements in vector + if(cal > 1L) { + zz <- seq_len(min(15L, cal)) + for(i in zz[1:min(cal-1L,15)]) { + DecayCurveData <- c(DecayCurveData, c(dgeom(x = i, prob = runif(n = 1L, min = 0.45, max = 0.55), log = FALSE))) + } + } + + # Fill ChainLadderData + data.table::set(ChainLadderData, i = (LoopSeq[cal]+1L):LoopSeq[cal + 1L], j = "Rates", value = DecayCurveData[seq_len(min(15L, cal))]) + } + + # Fill in Leads and Conversions---- + x <- unique(ChainLadderData[, .SD, .SDcols = c("CalendarDateColumn","Leads")]) + x[, Leads := runif(n = x[, .N], min = 100, max = 500)] + ChainLadderData <- merge(ChainLadderData[, .SD, .SDcols = c("CalendarDateColumn","CohortDateColumn","CohortDays","Appointments","Rates")], x, by = "CalendarDateColumn", all = FALSE) + ChainLadderData[, Appointments := Leads * Rates] + ChainLadderData[, Sales := Appointments * Rates * (runif(.N))] + ChainLadderData[, Rates := NULL] + data.table::setcolorder(ChainLadderData, c(1,2,3,5,4)) + return(ChainLadderData) + } + + # Modify---- + if(MultiClass && FactorCount == 0L) { + FactorCount <- 1L + temp <- 1L + } + + # Create data---- + Correl <- Correlation + data <- data.table::data.table(Adrian = runif(N)) + data[, x1 := qnorm(Adrian)] + data[, x2 := runif(N)] + data[, Independent_Variable1 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] + data[, Independent_Variable2 := log(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] + data[, Independent_Variable3 := exp(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] + data[, Independent_Variable4 := exp(exp(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2))))] + data[, Independent_Variable5 := sqrt(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] + data[, Independent_Variable6 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^0.10] + data[, Independent_Variable7 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^0.25] + data[, Independent_Variable8 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^0.75] + data[, Independent_Variable9 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^2] + data[, Independent_Variable10 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^4] + if(ID > 0L) for(i in seq_len(ID)) data[, paste0("IDcol_", i) := runif(N)] + data[, ":=" (x2 = NULL)] + + # FactorCount---- + for(i in seq_len(FactorCount)) { + RandomValues <- sort(c(runif(n = 4L, min = 0.01, max = 0.99))) + RandomLetters <- sort(c(sample(x = LETTERS, size = 5L, replace = FALSE))) + data[, paste0("Factor_", i) := as.factor( + data.table::fifelse(Independent_Variable1 < RandomValues[1L], RandomLetters[1L], + data.table::fifelse(Independent_Variable1 < RandomValues[2L], RandomLetters[2L], + data.table::fifelse(Independent_Variable1 < RandomValues[3L], RandomLetters[3L], + data.table::fifelse(Independent_Variable1 < RandomValues[4L], RandomLetters[4L], RandomLetters[5L])))))] + } + + # Add date---- + if(AddDate) { + if(FactorCount == 0) { + data <- data[, DateTime := as.Date(Sys.time())] + data[, temp := seq_len(.N)][, DateTime := DateTime - temp][, temp := NULL] + data <- data[order(DateTime)] + } else { + data <- data[, DateTime := as.Date(Sys.time())] + CatFeatures <- sort(c(as.numeric(which(sapply(data, is.factor))), as.numeric(which(sapply(data, is.character))))) + data[, temp := seq_len(.N), by = c(names(data)[c(CatFeatures)])][, DateTime := DateTime - temp][, temp := NULL] + data.table::setorderv(x = data, cols = c("DateTime", c(names(data)[c(CatFeatures)])), order = rep(1, length(c(names(data)[c(CatFeatures)]))+1)) + } + } + + # Zero Inflation Setup + if(!Classification && !MultiClass) { + if(ZIP == 1L) { + data[, Adrian := data.table::fifelse(Adrian < 0.5, 0, Independent_Variable8)][, Independent_Variable8 := NULL] + } else if(ZIP == 2L) { + data[, Adrian := data.table::fifelse(Adrian < 0.33, 0, data.table::fifelse(Adrian < 0.66, log(Adrian * 10), log(Adrian*20)))] + } else if(ZIP == 3L) { + data[, Adrian := data.table::fifelse(Adrian < 0.25, 0, data.table::fifelse(Adrian < 0.50, log(Adrian * 10), data.table::fifelse(Adrian < 0.75, log(Adrian * 50), log(Adrian * 150))))] + } else if(ZIP == 4L) { + data[, Adrian := data.table::fifelse(Adrian < 0.20, 0, data.table::fifelse(Adrian < 0.40, log(Adrian * 10), data.table::fifelse(Adrian < 0.60, log(Adrian * 50), data.table::fifelse(Adrian < 0.80, log(Adrian * 150), log(Adrian * 250)))))] + } else if(ZIP == 5L) { + data[, Adrian := data.table::fifelse(Adrian < 1/6, 0, data.table::fifelse(Adrian < 2/6, log(Adrian * 10), data.table::fifelse(Adrian < 3/6, log(Adrian * 50), data.table::fifelse(Adrian < 4/6, log(Adrian * 250), data.table::fifelse(Adrian < 5/6, log(Adrian * 500), log(Adrian * 1000))))))] + } + } + + # Classification + if(Classification) data[, Adrian := data.table::fifelse(jitter(x = Adrian, factor = 100) > 0.63, 1, 0)] + + # Remove---- + data[, ":=" (x1 = NULL)] + + # MultiClass + if(MultiClass) { + data[, Adrian := NULL] + data.table::setnames(data, "Factor_1", "Adrian") + } + + # Comment data + if(AddComment) { + a <- c('Hello', 'Hi', 'Howdy') + b <- c('really like', 'absolutely adore', 'sucks ass') + c <- c('noload', 'download', 'upload') + N1 <- 1/length(a) + N2 <- 1/length(b) + N3 <- 1/length(c) + N11 <- 1/N1 + N22 <- 1/N2 + N33 <- 1/N3 + RandomText <- function(N1,N11,N2,N22,N3,N33,a,b,c) { + paste(sample(x = a, size = 1, replace = TRUE, prob = rep(N1, N11)), + sample(x = b, size = 1, replace = TRUE, prob = rep(N2, N22)), + sample(x = c, size = 1, replace = TRUE, prob = rep(N3, N33))) + } + data[, Comment := "a"] + for(i in seq_len(data[, .N])) { + data.table::set(data, i = i, j = "Comment", value = RandomText(N1,N11,N2,N22,N3,N33,a,b,c)) + } + } + + # Add weights column + if(AddWeightsColumn) { + data[, Weights := runif(.N)] + } + + # Return data + return(data) +} + +#' @title Standardize +#' +#' @description Generate standardized values for multiple variables, by groups if provided, and with a selected granularity +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' +#' @param data Source data.table +#' @param ColNames Character vector of column names +#' @param GroupVars Character vector of column names to have percent ranks by the group levels +#' @param Center TRUE +#' @param Scale TRUE +#' @param ScoreTable FALSE. Set to TRUE to return a data.table that can be used to apply or backtransform via StandardizeScoring +#' +#' @examples +#' \dontrun{ +#' data <- data.table::fread(file.choose()) +#' x <- Standardize(data = data, ColNames = c('Weekly_Sales', 'XREG3'), GroupVars = c('Region','Store','Dept'), Center = TRUE, Scale = TRUE, ScoreTable = TRUE) +#' } +#' +#' @noRd +Standardize <- function(data, ColNames, GroupVars = NULL, Center = TRUE, Scale = TRUE, ScoreTable = FALSE) { + + # Standardize + if(length(GroupVars) == 0L) { + data[, paste0(ColNames, '_Standardize') := lapply(.SD, FUN = function(x) (x - mean(x, na.rm = TRUE)) / sd(x, na.rm = TRUE)), .SDcols = c(ColNames)] + } else { + data[, paste0(ColNames, '_Standardize') := lapply(.SD, FUN = function(x) (x - mean(x, na.rm = TRUE)) / sd(x, na.rm = TRUE)), .SDcols = c(ColNames), by = c(eval(GroupVars))] + } + + # ScoreTable creation + if(ScoreTable) { + x <- data[, lapply(.SD, mean, na.rm = TRUE), .SDcols = c(ColNames), by = c(GroupVars)] + data.table::setnames(x = x, old = ColNames, new = paste0(ColNames, "_mean")) + y <- data[, lapply(.SD, sd, na.rm = TRUE), .SDcols = c(ColNames), by = c(GroupVars)] + data.table::setnames(x = y, old = ColNames, new = paste0(ColNames, "_sd")) + xy <- cbind(x,y[, (GroupVars) := NULL]) + } + + # Return + if(!ScoreTable) { + return(data) + } else { + return(list( + data = data, + ScoreTable = xy + )) + } +} + +#' @title StandardizeScoring +#' +#' @description Generate standardized values for multiple variables, by groups if provided, and with a selected granularity +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' +#' @param data Source data.table +#' @param Apply 'apply' or 'backtransform' +#' @param ColNames Character vector of column names +#' @param GroupVars Character vector of column names to have percent ranks by the group levels +#' @param Center TRUE +#' @param Scale TRUE +#' +#' @examples +#' \dontrun{ +#' x <- Standardize(data = data, ColNames = c('Weekly_Sales', 'XREG1'), GroupVars = c('Region','Store','Dept'), Center = TRUE, Scale = TRUE) +#' } +#' +#' @noRd +StandardizeScoring <- function(data, ScoreTable, Apply = 'apply', GroupVars = NULL) { + + # Facts + nam <- names(ScoreTable)[which(!names(ScoreTable) %in% GroupVars)] + + # Apply will apply standardization to new data + # Backtransform will undo standardization + if(Apply == 'apply') { + data.table::setkeyv(x = data, cols = GroupVars) + data.table::setkeyv(x = ScoreTable, cols = GroupVars) + data[ScoreTable, paste0(nam) := mget(paste0('i.', nam))] + nams <- nam[seq_len(length(nam) / 2)] + ColNames <- gsub(pattern = "_mean", replacement = "", x = nams) + for(i in ColNames) data[, paste0(i, "_Standardize") := (get(i) - get(paste0(i, "_mean"))) / get(paste0(i, "_sd"))] + data.table::set(data, j = c(nam), value = NULL) + } else { + data.table::setkeyv(x = data, cols = GroupVars) + data.table::setkeyv(x = ScoreTable, cols = GroupVars) + data[ScoreTable, paste0(nam) := mget(paste0('i.', nam))] + nams <- nam[seq_len(length(nam) / 2)] + ColNames <- gsub(pattern = "_mean", replacement = "", x = nams) + for(i in ColNames) data[, eval(i) := get(paste0(i, "_Standardize")) * get(paste0(i, "_sd")) + get(paste0(i, "_mean"))] + data.table::set(data, j = c(nam), value = NULL) + } + + # Return + return(data) +} + +#' @title PercRank +#' +#' @description Generate percent ranks for multiple variables, by groups if provided, and with a selected granularity +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' +#' @param data Source data.table +#' @param ColNames Character vector of column names +#' @param GroupVars Character vector of column names to have percent ranks by the group levels +#' @param Granularity Provide a value such that data.table::frank(Variable) * (1 / Granularity) / .N * Granularity. Default is 0.001 +#' @param ScoreTable = FALSE. Set to TRUE to get the reference values for applying to new data. Pass to scoring version of this function +#' +#' @examples +#' \dontrun{ +#' data <- data.table::fread(file.choose()) +#' x <- PercRank(data, ColNames = c('Weekly_Sales', 'XREG1'), GroupVars = c('Region','Store','Dept'), Granularity = 0.001, ScoreTable = TRUE) +#' } +#' +#' @noRd +PercRank <- function(data, ColNames, GroupVars = NULL, Granularity = 0.001, ScoreTable = FALSE) { + if(length(GroupVars) == 0L) { + data[, paste0(ColNames, '_PercRank') := lapply(.SD, FUN = function(x) data.table::frank(x) * (1 / Granularity) / .N * Granularity), .SDcols = c(ColNames)] + } else { + data[, paste0(ColNames, '_PercRank') := lapply(.SD, FUN = function(x) data.table::frank(x) * (1 / Granularity) / .N * Granularity), .SDcols = c(ColNames), by = c(eval(GroupVars))] + } + if(!ScoreTable) { + return(data) + } else { + return(list( + data = data, + ScoreTable = unique(data[, .SD, .SDcols = c(ColNames, paste0(ColNames, '_PercRank'))]) + )) + } +} + +#' Test YeoJohnson Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param eps erorr tolerance +#' @param ... Arguments to pass along +#' @return YeoJohnson results +Test_YeoJohnson <- function(x, + eps = 0.001, + ...) { + stopifnot(is.numeric(x)) + lambda <- Estimate_YeoJohnson_Lambda(x, eps = eps, ...) + trans_data <- x + na_idx <- is.na(x) + trans_data[!na_idx] <- Apply_YeoJohnson(x[!na_idx], lambda, eps) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "YeoJohnson", Data = trans_data, Lambda = lambda, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Estimate YeoJohnson Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param lower the lower bound for search +#' @param upper the upper bound for search +#' @param eps erorr tolerance +#' @return YeoJohnson results +Estimate_YeoJohnson_Lambda <- function(x, + lower = -5, + upper = 5, + eps = 0.001) { + + n <- length(x) + ccID <- !is.na(x) + x <- x[ccID] + + # See references, Yeo & Johnson Biometrika (2000) + yj_loglik <- function(lambda) { + x_t <- Apply_YeoJohnson(x, lambda, eps) + x_t_bar <- mean(x_t) + x_t_var <- var(x_t) * (n - 1) / n + constant <- sum(sign(x) * log(abs(x) + 1)) + - 0.5 * n * log(x_t_var) + (lambda - 1) * constant + } + + results <- optimize( + yj_loglik, + lower = lower, + upper = upper, + maximum = TRUE, + tol = .0001) + return(results$maximum) +} + +#' Apply YeoJohnson Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param lambda optimal lambda +#' @param eps erorr tolerance +#' @return YeoJohnson results +Apply_YeoJohnson <- function(x, + lambda, + eps = 0.001) { + pos_idx <- x >= 0 + neg_idx <- x < 0 + + # Transform negative values + if(any(pos_idx)) { + if(abs(lambda) < eps) { + x[pos_idx] <- log(x[pos_idx] + 1) + } else { + x[pos_idx] <- ((x[pos_idx] + 1) ^ lambda - 1) / lambda + } + } + + # Transform nonnegative values + if(any(neg_idx)) { + if(abs(lambda - 2) < eps) { + x[neg_idx] <- -log(-x[neg_idx] + 1) + } else { + x[neg_idx] <- -((-x[neg_idx] + 1) ^ (2 - lambda) - 1) / (2 - lambda) + } + } + return(x) +} + +#' Inverse YeoJohnson Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param lambda optimal lambda +#' @param eps erorr tolerance +#' @return YeoJohnson results +InvApply_YeoJohnson <- function(x, + lambda, + eps = 0.001) { + val <- x + neg_idx <- x < 0 + if(any(!neg_idx)) { + if(abs(lambda) < eps) { + val[!neg_idx] <- exp(x[!neg_idx]) - 1 + } else { + val[!neg_idx] <- (x[!neg_idx] * lambda + 1) ^ (1 / lambda) - 1 + } + } + if(any(neg_idx)) { + if(abs(lambda - 2) < eps) { + val[neg_idx] <- -expm1(-x[neg_idx]) + } else { + val[neg_idx] <- 1 - (-(2 - lambda) * x[neg_idx] + 1) ^ (1 / (2 - lambda)) + } + } + return(val) +} + +#' Test BoxCox Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param ... Arguments to pass along +#' @return BoxCox results +Test_BoxCox <- function(x, ...) { + stopifnot(is.numeric(x)) + lambda <- Estimate_BoxCox_Lambda(x, ...) + trans_data <- Apply_BoxCox(x, lambda) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "BoxCox", Data = trans_data, Lambda = lambda, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Estimate BoxCox Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param lower the lower bound for search +#' @param upper the upper bound for search +#' @param eps erorr tolerance +#' @return BoxCox results +Estimate_BoxCox_Lambda <- function(x, + lower = -1, + upper = 2, + eps = 0.001) { + n <- length(x) + ccID <- !is.na(x) + x <- x[ccID] + if (any(x <= 0)) stop("x must be positive") + log_x <- log(x) + xbar <- exp(mean(log_x)) + fit <- lm(x ~ 1, data = data.frame(x = x)) + xqr <- fit$qr + boxcox_loglik <- function(lambda) { + if (abs(lambda) > eps) + xt <- (x ^ lambda - 1) / lambda + else + xt <- log_x * (1 + (lambda * log_x) / 2 * + (1 + (lambda * log_x) / 3 * + (1 + (lambda * log_x) / 4))) + - n / 2 * log(sum(qr.resid(xqr, xt / xbar ^ (lambda - 1)) ^ 2)) + } + + results <- optimize( + boxcox_loglik, + lower = lower, + upper = upper, + maximum = TRUE, + tol = .0001) + return(results$maximum) +} + +#' Apply BoxCox Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param lambda optimal lambda +#' @param eps erorr tolerance +#' @return BoxCox results +Apply_BoxCox <- function(x, + lambda, + eps = 0.001) { + if(lambda < 0) x[x < 0] <- NA + if(abs(lambda) < eps) { + val <- log(x) + } else { + val <- (sign(x) * abs(x) ^ lambda - 1) / lambda + } + return(val) +} + +#' Inverse BoxCox Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @param lambda optimal lambda +#' @param eps erorr tolerance +#' @return BoxCox results +InvApply_BoxCox <- function(x, + lambda, + eps = 0.001) { + if(lambda < 0) x[x > -1 / lambda] <- NA + if(abs(lambda) < eps) { + val <- exp(x) + } else { + x <- x * lambda + 1 + val <- sign(x) * abs(x) ^ (1 / lambda) + } + return(val) +} + +#' Test Asinh Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Asinh results +Test_Asinh <- function(x) { + stopifnot(is.numeric(x)) + trans_data <- asinh(x) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "Asinh", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Inverse Asinh Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Asinh results +Apply_Asinh <- function(x) { + return(asinh(x)) +} + +#' Inverse Asinh Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Asinh results +InvApply_Asinh <- function(x) { + return(sinh(x)) +} + +#' Test Asin Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Asin results +Test_Asin <- function(x) { + stopifnot(is.numeric(x)) + trans_data <- asin(sqrt(x)) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "Asin", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Inverse Asin Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Asin results +Apply_Asin <- function(x) { + return(asin(sqrt(x))) +} + +#' Inverse Asin Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Asin results +InvApply_Asin <- function(x) { + return(sin(x) ^ 2) +} + +#' Test Logit Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Logit results +Test_Logit <- function(x) { + stopifnot(is.numeric(x)) + trans_data <- log(x / (1 - x)) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "Logit", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Apply Logit Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Logit results +Apply_Logit <- function(x) { + return(log(x / (1 - x))) +} + +#' Inverse Logit Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Logit results +InvApply_Logit <- function(x) { + return(1 / (1 + exp(-x))) +} + +#' Test Identity Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Identity results +Test_Identity <- function(x) { + stopifnot(is.numeric(x)) + x.t <- x + mu <- mean(x.t, na.rm = TRUE) + sigma <- sd(x.t, na.rm = TRUE) + x.t <- (x.t - mu) / sigma + ptest <- nortest::pearson.test(x.t) + val <- list(Name = "Identity", Data = x, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Test Log Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Log results +Test_Log <- function(x) { + stopifnot(is.numeric(x)) + trans_data <- log(x) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "Log", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Apply Log Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Log results +Apply_Log <- function(x) { + return(log(x)) +} + +#' Inverse Log Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Log results +InvApply_Log <- function(x) { + return(exp(x)) +} + +#' Test LogPlus1 Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return LogPlus1 results +Test_LogPlus1 <- function(x) { + stopifnot(is.numeric(x)) + xx <- min(x, na.rm = TRUE) + if(xx <= 0) trans_data <- log(x+abs(xx)+1) else trans_data <- log(x) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "LogPlus1", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Apply LogPlus1 Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Log results +Apply_LogPlus1 <- function(x) { + return(log(x+1)) +} + +#' Inverse LogPlus1 Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Log results +InvApply_LogPlus1 <- function(x) { + return(exp(x)-1) +} + +#' Test Sqrt Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Sqrt results +Test_Sqrt <- function(x) { + stopifnot(is.numeric(x)) + trans_data <- sqrt(x) + mu <- mean(trans_data, na.rm = TRUE) + sigma <- sd(trans_data, na.rm = TRUE) + trans_data_standardized <- (trans_data - mu) / sigma + ptest <- nortest::pearson.test(trans_data_standardized) + val <- list(Name = "Sqrt", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) + return(val) +} + +#' Apply Sqrt Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Log results +Apply_Sqrt <- function(x) { + return(sqrt(x)) +} + +#' Inverse Sqrt Transformation +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @noRd +#' @param x The data in numerical vector form +#' @return Log results +InvApply_Sqrt <- function(x) { + return(x^2) +} + +#' @title AutoTransformationCreate +#' +#' @description AutoTransformationCreate is a function for automatically identifying the optimal transformations for numeric features and transforming them once identified. This function will loop through your selected transformation options (YeoJohnson, BoxCox, Asinh, Asin, and Logit) and find the one that produces data that is the closest to normally distributed data. It then makes the transformation and collects the metadata information for use in the AutoTransformationScore() function, either by returning the objects (always) or saving them to file (optional). +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' @param data This is your source data +#' @param ColumnNames List your columns names in a vector, for example, c("Target", "IV1") +#' @param Methods Choose from "YeoJohnson", "BoxCox", "Asinh", "Log", "LogPlus1", "Asin", "Logit", and "Identity". Note, LogPlus1 runs +#' @param Path Set to the directly where you want to save all of your modeling files +#' @param TransID Set to a character value that corresponds with your modeling project +#' @param SaveOutput Set to TRUE to save necessary file to run AutoTransformationScore() +#' @return data with transformed columns and the transformation object for back-transforming later +#' @examples +#' \dontrun{ +#' # Create Fake Data +#' data <- FakeDataGenerator( +#' Correlation = 0.85, +#' N = 25000, +#' ID = 2L, +#' ZIP = 0, +#' FactorCount = 2L, +#' AddDate = FALSE, +#' Classification = FALSE, +#' MultiClass = FALSE) +#' +#' # Columns to transform +#' Cols <- names(data)[1L:11L] +#' print(Cols) +#' +#' # Run function +#' data <- AutoTransformationCreate( +#' data, +#' ColumnNames = Cols, +#' Methods = c("YeoJohnson", "BoxCox", "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "Identity"), +#' Path = getwd(), +#' TransID = "Trans", +#' SaveOutput = TRUE) +#' } +#' @noRd +AutoTransformationCreate <- function(data, + ColumnNames = NULL, + Methods = c("BoxCox","YeoJohnson","Asinh","Log","LogPlus1","Sqrt","Asin","Logit","Identity"), + Path = NULL, + TransID = "ModelID", + SaveOutput = FALSE) { + + # Check arguments + Methods <- unique(tolower(Methods)) + if(!data.table::is.data.table(data)) data.table::setDT(data) + if(!any(tolower(Methods) %chin% c("boxcox", "yeojohnson", "asinh", "sqrt", "log", "logplus1", "asin", "logit"))) stop("Methods not supported") + # if(!"identity" %chin% Methods) Methods <- c(Methods, "identity") + if(is.numeric(ColumnNames) || is.integer(ColumnNames)) ColumnNames <- names(data)[ColumnNames] + for(i in ColumnNames) if(!(any(class(data[[eval(i)]]) %chin% c("numeric", "integer")))) stop("ColumnNames must be for numeric or integer columns") + + # Loop through ColumnNames + # colNames = 1 + for(colNames in seq_along(ColumnNames)) {# colNames = 1L + + # Collection Object + if(length(Methods) < 5) { + EvaluationTable <- data.table::data.table( + ColumnName = rep("BLABLA", length(ColumnNames) * (length(Methods)+1)), + MethodName = rep("BLABLA", length(ColumnNames) * (length(Methods)+1)), + Lambda = rep(1.0, length(ColumnNames) * (length(Methods)+1)), + NormalizedStatistics = rep(1.0, length(ColumnNames) * (length(Methods)+1))) + } else { + EvaluationTable <- data.table::data.table( + ColumnName = rep("BLABLA", length(ColumnNames) * (length(Methods) + 1)), + MethodName = rep("BLABLA", length(ColumnNames) * (length(Methods) + 1)), + Lambda = rep(1.0, length(ColumnNames) * (length(Methods) + 1)), + NormalizedStatistics = rep(1.0, length(ColumnNames) * (length(Methods) + 1))) + } + DataCollection <- list() + Counter <- 0L + + # Check range of data + MinVal <- min(data[[eval(ColumnNames[colNames])]], na.rm = TRUE) + MaxVal <- max(data[[eval(ColumnNames[colNames])]], na.rm = TRUE) + + # Create Final Methods Object + FinalMethods <- Methods + + # Update Methods + if(MinVal <= 0) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("boxcox","log","logit"))] + if(MinVal < 0) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("sqrt","asin"))] + if(MaxVal > 1) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("asin"))] + if(MaxVal >= 1) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("logit"))] + + # Store column data as vector + x <- data[[eval(ColumnNames[colNames])]] + + # YeoJohnson + if(any(tolower(FinalMethods) %chin% "yeojohnson")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_YeoJohnson(x) + DataCollection[["yeojohnson"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # Log + if(any(tolower(FinalMethods) %chin% "log")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_Log(x) + DataCollection[["log"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = NA) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # LogPlus1 + if(any(tolower(FinalMethods) %chin% "logplus1")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_LogPlus1(x) + DataCollection[["logplus1"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = NA) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # Sqrt + if(any(tolower(FinalMethods) %chin% "sqrt")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_Sqrt(x) + DataCollection[["sqrt"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = NA) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # BoxCox + if(any(tolower(FinalMethods) %chin% "boxcox")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_BoxCox(x) + DataCollection[["boxcox"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # Asinh + if(any(tolower(FinalMethods) %chin% "asinh")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_Asinh(x) + DataCollection[["asinh"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # Asin + if(any(tolower(FinalMethods) %chin% "asin")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_Asin(x) + DataCollection[["asin"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # Logit + if(any(tolower(FinalMethods) %chin% "logit")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_Logit(x) + DataCollection[["logit"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # Identity + if(any(tolower(FinalMethods) %chin% "identity")) { + Counter <- Counter + 1L + data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) + output <- Test_Identity(x) + DataCollection[["identity"]] <- output$Data + data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) + data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) + data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) + } + + # Pick winner + EvaluationTable <- EvaluationTable[MethodName != "BLABLA"] + if(colNames == 1L) { + Results <- EvaluationTable[order(NormalizedStatistics)][1L] + } else { + Results <- data.table::rbindlist(list(Results, EvaluationTable[order(NormalizedStatistics)][1L])) + } + + # Apply to data---- + data <- tryCatch({data[, ColumnNames[colNames] := DataCollection[[tolower(Results[eval(colNames), MethodName])]]]}, error = function(x) data) + } + + # Save output---- + if(SaveOutput && !is.null(Path)) data.table::fwrite(Results, file = file.path(normalizePath(Path), paste0(TransID, "_transformation.csv"))) + + # Return data---- + return(list(Data = data, FinalResults = Results)) +} + +#' @title ClassificationMetrics +#' +#' @description ClassificationMetrics +#' +#' @author Adrian Antico +#' @family Model Evaluation +#' +#' @param TestData Test data from your modeling +#' @param Thresholds Value +#' @param Target Name of your target variable +#' @param PredictColumnName Name of your predicted value variable +#' @param PositiveOutcome The value of the positive outcome level +#' @param NegativeOutcome The value of the negative outcome level +#' @param CostMatrix c(True Positive Cost, False Negative Cost, False Positive Cost, True Negative Cost) +#' @noRd +ClassificationMetrics <- function(TestData, + Thresholds, + Target, + PredictColumnName, + PositiveOutcome, + NegativeOutcome, + CostMatrix = c(0,1,1,0)) { + + if("Target" %chin% names(TestData)) data.table::set(TestData, j = "Target", value = NULL) + ThreshLength <- rep(1, length(Thresholds)) + ThresholdOutput <- data.table::data.table( + Threshold = ThreshLength, + TN = ThreshLength, + TP = ThreshLength, + FN = ThreshLength, + FP = ThreshLength, + N = ThreshLength, + P = ThreshLength, + MCC = ThreshLength, + Accuracy = ThreshLength, + TPR = ThreshLength, + TNR = ThreshLength, + FNR = ThreshLength, + FPR = ThreshLength, + FDR = ThreshLength, + FOR = ThreshLength, + F1_Score = ThreshLength, + F2_Score = ThreshLength, + F0.5_Score = ThreshLength, + NPV = ThreshLength, + PPV = ThreshLength, + ThreatScore = ThreshLength, + Utility = ThreshLength) + counter <- 0L + for(Thresh in Thresholds) { + counter <- counter + 1L + TN <- TestData[, sum(data.table::fifelse(get(PredictColumnName) < Thresh & get(Target) == eval(NegativeOutcome), 1, 0))] + TP <- TestData[, sum(data.table::fifelse(get(PredictColumnName) > Thresh & get(Target) == eval(PositiveOutcome), 1, 0))] + FN <- TestData[, sum(data.table::fifelse(get(PredictColumnName) < Thresh & get(Target) == eval(PositiveOutcome), 1, 0))] + FP <- TestData[, sum(data.table::fifelse(get(PredictColumnName) > Thresh & get(Target) == eval(NegativeOutcome), 1, 0))] + N1 <- TestData[, .N] + N <- TestData[get(PredictColumnName) < eval(Thresh), .N] + P1 <- TestData[get(Target) == 1, .N] + P <- TestData[get(Target) == 1 & get(PredictColumnName) > Thresh, .N] + + # Calculate metrics ---- + MCC <- (TP*TN-FP*FN)/sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)) + Accuracy <- (TP+TN)/N1 + TPR <- TP/P1 + TNR <- TN/(N1-P1) + FNR <- FN / P1 + FPR <- FP / N1 + FDR <- FP / (FP + TP) + FOR <- FN / (FN + TN) + F1_Score <- 2 * TP / (2 * TP + FP + FN) + F2_Score <- 3 * TP / (2 * TP + FP + FN) + F0.5_Score <- 1.5 * TP / (0.5 * TP + FP + FN) + NPV <- TN / (TN + FN) + PPV <- TP / (TP + FP) + ThreatScore <- TP / (TP + FN + FP) + Utility <- P1/N1 * (CostMatrix[1L] * TPR + CostMatrix[2L] * (1 - TPR)) + (1 - P1/N1) * (CostMatrix[3L] * FPR + CostMatrix[4L] * (1 - FPR)) + + # Fill in values ---- + data.table::set(ThresholdOutput, i = counter, j = "Threshold", value = Thresh) + data.table::set(ThresholdOutput, i = counter, j = "P", value = P) + data.table::set(ThresholdOutput, i = counter, j = "N", value = N) + data.table::set(ThresholdOutput, i = counter, j = "TN", value = TN) + data.table::set(ThresholdOutput, i = counter, j = "TP", value = TP) + data.table::set(ThresholdOutput, i = counter, j = "FP", value = FP) + data.table::set(ThresholdOutput, i = counter, j = "FN", value = FN) + data.table::set(ThresholdOutput, i = counter, j = "Utility", value = Utility) + data.table::set(ThresholdOutput, i = counter, j = "MCC", value = MCC) + data.table::set(ThresholdOutput, i = counter, j = "Accuracy", value = Accuracy) + data.table::set(ThresholdOutput, i = counter, j = "F1_Score", value = F1_Score) + data.table::set(ThresholdOutput, i = counter, j = "F0.5_Score", value = F0.5_Score) + data.table::set(ThresholdOutput, i = counter, j = "F2_Score", value = F2_Score) + data.table::set(ThresholdOutput, i = counter, j = "NPV", value = NPV) + data.table::set(ThresholdOutput, i = counter, j = "TPR", value = TPR) + data.table::set(ThresholdOutput, i = counter, j = "TNR", value = TNR) + data.table::set(ThresholdOutput, i = counter, j = "FNR", value = FNR) + data.table::set(ThresholdOutput, i = counter, j = "FPR", value = FPR) + data.table::set(ThresholdOutput, i = counter, j = "FDR", value = FDR) + data.table::set(ThresholdOutput, i = counter, j = "FOR", value = FOR) + data.table::set(ThresholdOutput, i = counter, j = "PPV", value = PPV) + data.table::set(ThresholdOutput, i = counter, j = "ThreatScore", value = ThreatScore) + } + + # Remove NA's + ThresholdOutput <- ThresholdOutput[, RowSum := rowSums(x = as.matrix(ThresholdOutput))][!is.na(RowSum)][, RowSum := NULL] + return(ThresholdOutput) +} + +#' @title RemixClassificationMetrics +#' +#' @description RemixClassificationMetrics +#' +#' @author Adrian Antico +#' @family Model Evaluation +#' +#' @param TargetVariable Name of your target variable +#' @param Thresholds seq(0.01,0.99,0.01), +#' @param CostMatrix c(1,0,0,1) c(TP utility, FN utility, FP utility, TN utility) +#' @param ClassLabels c(1,0), +#' @param ValidationData. Test data +#' @examples +#' \dontrun{ +#' RemixClassificationMetrics <- function( + #' TargetVariable = "Adrian", +#' Thresholds = seq(0.01,0.99,0.01), +#' CostMatrix = c(1,0,0,1), +#' ClassLabels = c(1,0), +#' ValidationData. = ValidationData) +#' } +#' @noRd +RemixClassificationMetrics <- function(TargetVariable = NULL, + Thresholds = seq(0.01,0.99,0.01), + CostMatrix = c(1,0,0,1), + ClassLabels = c(1,0), + ValidationData. = NULL) { + + # Create metrics + if(!"p1" %chin% names(ValidationData.)) data.table::setnames(ValidationData., "Predict", "p1") + temp <- ClassificationMetrics( + TestData = ValidationData., + Target = eval(TargetVariable), + PredictColumnName = "p1", + Thresholds = Thresholds, + PositiveOutcome = ClassLabels[1L], + NegativeOutcome = ClassLabels[2L], + CostMatrix = CostMatrix) + if(temp[,.N] > 95) data.table::setorderv(temp, cols = "MCC", order = -1L, na.last = TRUE) + + # Return values---- + return(temp) +} + +#' @title BinaryMetrics +#' +#' @description Compute binary metrics and save them to file +#' +#' @author Adrian Antico +#' @family Model Evaluation +#' +#' @param ClassWeights. = ClassWeights +#' @param CostMatrixWeights. = CostMatrixWeights +#' @param SaveModelObjects. = SaveModelObjects +#' @param ValidationData. = ValidationData +#' @param TrainOnFull. = TrainOnFull +#' @param TargetColumnName. = TargetColumnName +#' @param ModelID. = ModelID +#' @param model_path. = model_path +#' @param metadata_path. = metadata_path +#' @param Method 'threshold' for 0.01 to 0.99 by 0.01 thresholds or 'bins' for 20 equally sized bins +#' +#' @noRd +BinaryMetrics <- function(ClassWeights. = ClassWeights, + CostMatrixWeights. = CostMatrixWeights, + SaveModelObjects. = SaveModelObjects, + ValidationData. = ValidationData, + TrainOnFull. = TrainOnFull, + TargetColumnName. = TargetColumnName, + ModelID. = ModelID, + model_path. = model_path, + metadata_path. = metadata_path, + Method = "threshold") { + if(is.null(CostMatrixWeights.)) CostMatrixWeights. <- c(ClassWeights.[1L], 0, 0, ClassWeights.[2L]) + if(Method == "threshold") { + vals <- seq(0.01,0.99,0.01) + } else if(Method == "bins") { + temp <- ValidationData.$p1 + vals <- quantile(temp, probs = seq(0.05,1,0.05), type = 7) + } + if(SaveModelObjects. && !TrainOnFull.) { + EvalMetrics <- RemixClassificationMetrics(TargetVariable = eval(TargetColumnName.), Thresholds = unique(vals), CostMatrix = CostMatrixWeights., ClassLabels = c(1,0), ValidationData. = ValidationData.) + } else { + EvalMetrics <- RemixClassificationMetrics(TargetVariable = eval(TargetColumnName.), Thresholds = unique(vals), CostMatrix = CostMatrixWeights., ClassLabels = c(1,0), ValidationData. = ValidationData.) + } + EvalMetrics[, P_Predicted := TP + FP] + data.table::setcolorder(EvalMetrics, c(1,ncol(EvalMetrics),2:(ncol(EvalMetrics)-1))) + data.table::setcolorder(EvalMetrics, c(1:8, ncol(EvalMetrics), 9:10, 17:19, 11:16, 20:(ncol(EvalMetrics)-1))) + data.table::setcolorder(EvalMetrics, c(1:14, ncol(EvalMetrics), 15:(ncol(EvalMetrics)-1))) + data.table::setorderv(EvalMetrics, "Utility", -1) + return(EvalMetrics) +} + +#' @title DummifyDT +#' +#' @description DummifyDT creates dummy variables for the selected columns. Either one-hot encoding, N+1 columns for N levels, or N columns for N levels. +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' +#' @param data The data set to run the micro auc on +#' @param cols A vector with the names of the columns you wish to dichotomize +#' @param TopN Default is NULL. Scalar to apply to all categorical columns or a vector to apply to each categorical variable. Only create dummy variables for the TopN number of levels. Will be either TopN or max(levels) +#' @param OneHot Set to TRUE to run one hot encoding, FALSE to generate N columns for N levels +#' @param KeepFactorCols Set to TRUE to keep the original columns used in the dichotomization process +#' @param SaveFactorLevels Set to TRUE to save unique levels of each factor column to file as a csv +#' @param SavePath Provide a file path to save your factor levels. Use this for models that you have to create dummy variables for. +#' @param ImportFactorLevels Instead of using the data you provide, import the factor levels csv to ensure you build out all of the columns you trained with in modeling. +#' @param FactorLevelsList Supply a list of factor variable levels +#' @param ClustScore This is for scoring AutoKMeans. It converts the added dummy column names to conform with H2O dummy variable naming convention +#' @param ReturnFactorLevels If you want a named list of all the factor levels returned, set this to TRUE. Doing so will cause the function to return a list with the source data.table and the list of factor variables' levels +#' @param GroupVar Ignore this +#' @examples +#' \dontrun{ +# # Create fake data with 10 categorical columns +#' data <- FakeDataGenerator( +#' Correlation = 0.85, +#' N = 25000, +#' ID = 2L, +#' ZIP = 0, +#' FactorCount = 10L, +#' AddDate = FALSE, +#' Classification = FALSE, +#' MultiClass = FALSE) +#' +#' # Create dummy variables +#' data <- DummifyDT( +#' data = data, +#' cols = c("Factor_1", +#' "Factor_2", +#' "Factor_3", +#' "Factor_4", +#' "Factor_5", +#' "Factor_6", +#' "Factor_8", +#' "Factor_9", +#' "Factor_10"), +#' TopN = c(rep(3,9)), +#' KeepFactorCols = TRUE, +#' OneHot = FALSE, +#' SaveFactorLevels = TRUE, +#' SavePath = getwd(), +#' ImportFactorLevels = FALSE, +#' FactorLevelsList = NULL, +#' ClustScore = FALSE, +#' ReturnFactorLevels = FALSE) +#' +#' # Create Fake Data for Scoring Replication +#' data <- FakeDataGenerator( +#' Correlation = 0.85, +#' N = 25000, +#' ID = 2L, +#' ZIP = 0, +#' FactorCount = 10L, +#' AddDate = FALSE, +#' Classification = FALSE, +#' MultiClass = FALSE) +#' +#' # Scoring Version +#' data <- DummifyDT( +#' data = data, +#' cols = c("Factor_1", +#' "Factor_2", +#' "Factor_3", +#' "Factor_4", +#' "Factor_5", +#' "Factor_6", +#' "Factor_8", +#' "Factor_9", +#' "Factor_10"), +#' TopN = c(rep(3,9)), +#' KeepFactorCols = TRUE, +#' OneHot = FALSE, +#' SaveFactorLevels = TRUE, +#' SavePath = getwd(), +#' ImportFactorLevels = TRUE, +#' FactorLevelsList = NULL, +#' ClustScore = FALSE, +#' ReturnFactorLevels = FALSE) +#' } +#' @return Either a data table with new dummy variables columns and optionally removes base columns (if ReturnFactorLevels is FALSE), otherwise a list with the data.table and a list of the factor levels. +#' @export +DummifyDT <- function(data, + cols, + TopN = NULL, + KeepFactorCols = FALSE, + OneHot = FALSE, + SaveFactorLevels = FALSE, + SavePath = NULL, + ImportFactorLevels = FALSE, + FactorLevelsList = NULL, + ClustScore = FALSE, + ReturnFactorLevels = FALSE, + GroupVar = FALSE) { + + # Check data.table ---- + if(!data.table::is.data.table(data)) data.table::setDT(data) + + # Check arguments ---- + if(!is.null(TopN)) if(length(TopN) > 1L && length(TopN) != length(cols)) stop("TopN must match the length of cols") + if(!is.null(TopN)) if(length(TopN) > 1L) TopN <- rev(TopN) + if(!is.character(cols)) stop("cols needs to be a character vector of names") + if(!is.logical(KeepFactorCols)) stop("KeepFactorCols needs to be either TRUE or FALSE") + if(!is.logical(KeepFactorCols)) stop("KeepFactorCols needs to be either TRUE or FALSE") + if(!is.logical(OneHot)) stop("OneHot needs to be either TRUE or FALSE") + if(!is.logical(SaveFactorLevels)) stop("SaveFactorLevels needs to be either TRUE or FALSE") + if(!is.logical(ImportFactorLevels)) stop("ImportFactorLevels needs to be either TRUE or FALSE") + if(!is.logical(ClustScore)) stop("ClustScore needs to be either TRUE or FALSE") + if(!is.null(SavePath)) if(!is.character(SavePath)) stop("SavePath needs to be a character value of a folder location") + + # Ensure correct argument settings ---- + if(OneHot && ClustScore) { + OneHot <- FALSE + KeepFactorCols <- FALSE + } + + # Build dummies start ---- + FactorsLevelsList <- list() + if(!GroupVar) if(length(cols) > 1L && "GroupVar" %chin% cols) cols <- cols[!cols %chin% "GroupVar"] + if(length(TopN) > 1L) Counter <- 1L + for(col in cols) { + size <- ncol(data) + Names <- setdiff(names(data), col) + if(ImportFactorLevels) { + temp <- data.table::fread(file.path(SavePath, paste0(col, ".csv")), sep = ",") + inds <- sort(unique(temp[[eval(col)]])) + } else if(!is.null(FactorLevelsList)) { + temp <- FactorLevelsList[[eval(col)]] + inds <- sort(unique(temp[[eval(col)]])) + } else if(!is.null(TopN)) { + if(length(TopN) > 1L) { + indss <- data[, .N, by = eval(col)][order(-N)] + inds <- sort(indss[seq_len(min(TopN[Counter], .N)), get(col)]) + if(length(TopN) > 1L) Counter <- Counter + 1L + } else { + indss <- data[, .N, by = eval(col)][order(-N)] + inds <- sort(indss[seq_len(min(TopN, .N)), get(col)]) + } + } else { + indss <- data[, .N, by = eval(col)][order(-N)] + inds <- sort(unique(data[[eval(col)]])) + } + + # Allocate columns ---- + data.table::alloc.col(data, n = ncol(data) + length(inds)) + + # Save factor levels for scoring later ---- + if(SaveFactorLevels) { + if(!is.null(TopN)) { + if(length(TopN) > 1L) { + temp <- indss[seq_len(min(TopN[Counter-1L], .N))][, N := NULL] + data.table::fwrite(x = temp, file = file.path(SavePath, paste0(col, ".csv")), sep = ",") + } else { + temp <- indss[seq_len(min(TopN, .N))][, N := NULL] + data.table::fwrite(x = temp, file = file.path(SavePath, paste0(col, ".csv")), sep = ",") + } + } else { + temp <- indss[, N := NULL] + data.table::fwrite(x = temp, file = file.path(SavePath, paste0(col, ".csv")), sep = ",") + } + } + + # Collect Factor Levels ---- + if(ReturnFactorLevels && SaveFactorLevels) { + FactorsLevelsList[[eval(col)]] <- temp + } else if(ReturnFactorLevels) { + FactorsLevelsList[[eval(col)]] <- data[, get(col), by = eval(col)][, V1 := NULL] + } + + # Convert to character if col is factor ---- + if(is.factor(data[[eval(col)]])) data.table::set(data, j = eval(col), value = as.character(data[[eval(col)]])) + + # If for clustering set up old school way ---- + if(!ClustScore) { + data.table::set(data, j = paste0(col, "_", inds), value = 0L) + } else { + data.table::set(data, j = paste0(col, inds), value = 0L) + } + + # Build dummies ---- + for(ind in inds) { + if(!ClustScore) { + data.table::set(data, i = which(data[[col]] %in% ind), j = paste0(col, "_", ind), value = 1L) + } else { + data.table::set(data, i = which(data[[col]] %in% ind), j = paste0(col, ind),value = 1L) + } + } + + # Remove original factor columns ---- + if(!KeepFactorCols) data.table::set(data, j = eval(col), value = NULL) + if(ClustScore) setcolorder(data, c(setdiff(names(data), Names), Names)) + if(OneHot) data.table::set(data, j = paste0(col, "_Base"), value = 0L) + } + + # Clustering section ---- + if(ClustScore) data.table::setnames(data, names(data), tolower(gsub('[[:punct:] ]+', replacement = "", names(data)))) + + # Return data ---- + if(ReturnFactorLevels) { + return(list(data = data, FactorLevelsList = FactorsLevelsList)) + } else { + return(data) + } +} + +#' @title AutoLagRollStats +#' +#' @description AutoLagRollStats Builds lags and a large variety of rolling statistics with options to generate them for hierarchical categorical interactions. +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' +#' @param data A data.table you want to run the function on +#' @param Targets A character vector of the column names for the reference column in which you will build your lags and rolling stats +#' @param DateColumn The column name of your date column used to sort events over time +#' @param IndependentGroups A vector of categorical column names that you want to have run independently of each other. This will mean that no interaction will be done. +#' @param HierarchyGroups A vector of categorical column names that you want to have generate all lags and rolling stats done for the individual columns and their full set of interactions. +#' @param TimeGroups A vector of TimeUnits indicators to specify any time-aggregated GDL features you want to have returned. E.g. c("raw" (no aggregation is done),"hour", "day","week","month","quarter","year") +#' @param TimeBetween Specify a desired name for features created for time between events. Set to NULL if you don't want time between events features created. +#' @param TimeUnit List the time aggregation level for the time between events features, such as "hour", "day", "weeks", "months", "quarter", or "year" +#' @param TimeUnitAgg List the time aggregation of your data that you want to use as a base time unit for your features. E.g. "raw" or "day" +#' @param Lags A numeric vector of the specific lags you want to have generated. You must include 1 if WindowingLag = 1. +#' @param MA_RollWindows A numeric vector of the specific rolling statistics window sizes you want to utilize in the calculations. +#' @param SD_RollWindows A numeric vector of Standard Deviation rolling statistics window sizes you want to utilize in the calculations. +#' @param Skew_RollWindows A numeric vector of Skewness rolling statistics window sizes you want to utilize in the calculations. +#' @param Kurt_RollWindows A numeric vector of Kurtosis rolling statistics window sizes you want to utilize in the calculations. +#' @param Quantile_RollWindows A numeric vector of Quantile rolling statistics window sizes you want to utilize in the calculations. +#' @param Quantiles_Selected Select from the following c("q5", "q10", "q15", "q20", "q25", "q30", "q35", "q40", "q45", "q50", "q55", "q60"," q65", "q70", "q75", "q80", "q85", "q90", "q95") +#' @param RollOnLag1 Set to FALSE to build rolling stats off of target columns directly or set to TRUE to build the rolling stats off of the lag-1 target +#' @param Type List either "Lag" if you want features built on historical values or "Lead" if you want features built on future values +#' @param SimpleImpute Set to TRUE for factor level imputation of "0" and numeric imputation of -1 +#' @param ShortName Default TRUE. If FALSE, Group Variable names will be added to the rolling stat and lag names. If you plan on have multiple versions of lags and rollings stats by different group variables then set this to FALSE. +#' @param Debug Set to TRUE to get a print of which steps are running +#' @return data.table of original data plus created lags, rolling stats, and time between event lags and rolling stats +#' @export +AutoLagRollStats <- function(data, + Targets = NULL, + HierarchyGroups = NULL, + IndependentGroups = NULL, + DateColumn = NULL, + TimeUnit = NULL, + TimeUnitAgg = NULL, + TimeGroups = NULL, + TimeBetween = NULL, + RollOnLag1 = TRUE, + Type = "Lag", + SimpleImpute = TRUE, + Lags = NULL, + MA_RollWindows = NULL, + SD_RollWindows = NULL, + Skew_RollWindows = NULL, + Kurt_RollWindows = NULL, + Quantile_RollWindows = NULL, + Quantiles_Selected = NULL, + ShortName = TRUE, + Debug = FALSE) { + + # Define args ---- + RollFunctions <- c() + if(!is.null(MA_RollWindows)) RollFunctions <- c(RollFunctions,"mean") + if(!is.null(SD_RollWindows)) RollFunctions <- c(RollFunctions,"sd") + if(!is.null(Skew_RollWindows)) RollFunctions <- c(RollFunctions,"skew") + if(!is.null(Kurt_RollWindows)) RollFunctions <- c(RollFunctions,"kurt") + if(!is.null(Quantiles_Selected)) RollFunctions <- c(RollFunctions,Quantiles_Selected) + if(is.null(TimeBetween)) TimeBetween <- NULL else TimeBetween <- "TimeBetweenRecords" + if(RollOnLag1) RollOnLag1 <- 1L else RollOnLag1 <- 0L + TimeGroupPlaceHolder <- c() + if("raw" %chin% tolower(TimeGroups)) TimeGroupPlaceHolder <- c(TimeGroupPlaceHolder, "raw") + if(any(c("hours","hour","hr","hrs","hourly") %chin% tolower(TimeGroups))) { + TimeGroupPlaceHolder <- c(TimeGroupPlaceHolder, "hour") + if(is.list(Lags)) names(Lags)[which(names(Lags) %chin% c("hours","hour","hr","hrs","hourly"))] <- "hour" + if(is.list(MA_RollWindows)) names(MA_RollWindows)[which(names(MA_RollWindows) %chin% c("hours","hour","hr","hrs","hourly"))] <- "hour" + if(is.list(SD_RollWindows)) names(SD_RollWindows)[which(names(SD_RollWindows) %chin% c("hours","hour","hr","hrs","hourly"))] <- "hour" + if(is.list(Skew_RollWindows)) names(Skew_RollWindows)[which(names(Skew_RollWindows) %chin% c("hours","hour","hr","hrs","hourly"))] <- "hour" + if(is.list(Kurt_RollWindows)) names(Kurt_RollWindows)[which(names(Kurt_RollWindows) %chin% c("hours","hour","hr","hrs","hourly"))] <- "hour" + if(is.list(Quantile_RollWindows)) names(Quantile_RollWindows)[which(names(Quantile_RollWindows) %chin% c("hours","hour","hr","hrs","hourly"))] <- "hour" + } + if(any(c("days","day","dy","dd","d") %chin% tolower(TimeGroups))) { + TimeGroupPlaceHolder <- c(TimeGroupPlaceHolder, "day") + if(is.list(Lags)) names(Lags)[which(names(Lags) %chin% c("days","day","dy","dd","d"))] <- "day" + if(is.list(MA_RollWindows)) names(MA_RollWindows)[which(names(MA_RollWindows) %chin% c("days","day","dy","dd","d"))] <- "day" + if(is.list(SD_RollWindows)) names(SD_RollWindows)[which(names(SD_RollWindows) %chin% c("days","day","dy","dd","d"))] <- "day" + if(is.list(Skew_RollWindows)) names(Skew_RollWindows)[which(names(Skew_RollWindows) %chin% c("days","day","dy","dd","d"))] <- "day" + if(is.list(Kurt_RollWindows)) names(Kurt_RollWindows)[which(names(Kurt_RollWindows) %chin% c("days","day","dy","dd","d"))] <- "day" + if(is.list(Quantile_RollWindows)) names(Quantile_RollWindows)[which(names(Quantile_RollWindows) %chin% c("days","day","dy","dd","d"))] <- "day" + } + if(any(c("weeks","week","weaks","weak","wk","wkly","wks") %chin% tolower(TimeGroups))) { + TimeGroupPlaceHolder <- c(TimeGroupPlaceHolder, "weeks") + if(is.list(Lags)) names(Lags)[which(names(Lags) %chin% c("weeks","week","weaks","weak","wk","wkly","wks"))] <- "weeks" + if(is.list(MA_RollWindows)) names(MA_RollWindows)[which(names(MA_RollWindows) %chin% c("weeks","week","weaks","weak","wk","wkly","wks"))] <- "weeks" + if(is.list(SD_RollWindows)) names(SD_RollWindows)[which(names(SD_RollWindows) %chin% c("weeks","week","weaks","weak","wk","wkly","wks"))] <- "weeks" + if(is.list(Skew_RollWindows)) names(Skew_RollWindows)[which(names(Skew_RollWindows) %chin% c("weeks","week","weaks","weak","wk","wkly","wks"))] <- "weeks" + if(is.list(Kurt_RollWindows)) names(Kurt_RollWindows)[which(names(Kurt_RollWindows) %chin% c("weeks","week","weaks","weak","wk","wkly","wks"))] <- "weeks" + if(is.list(Quantile_RollWindows)) names(Quantile_RollWindows)[which(names(Quantile_RollWindows) %chin% c("weeks","week","weaks","weak","wk","wkly","wks"))] <- "weeks" + } + if(any(c("months","month","mth","mnth","monthly","mnthly") %chin% tolower(TimeGroups))) { + TimeGroupPlaceHolder <- c(TimeGroupPlaceHolder, "months") + if(is.list(Lags)) names(Lags)[which(names(Lags) %chin% c("months","month","mth","mnth","monthly","mnthly"))] <- "months" + if(is.list(MA_RollWindows)) names(MA_RollWindows)[which(names(MA_RollWindows) %chin% c("months","month","mth","mnth","monthly","mnthly"))] <- "months" + if(is.list(SD_RollWindows)) names(SD_RollWindows)[which(names(SD_RollWindows) %chin% c("months","month","mth","mnth","monthly","mnthly"))] <- "months" + if(is.list(Skew_RollWindows)) names(Skew_RollWindows)[which(names(Skew_RollWindows) %chin% c("months","month","mth","mnth","monthly","mnthly"))] <- "months" + if(is.list(Kurt_RollWindows)) names(Kurt_RollWindows)[which(names(Kurt_RollWindows) %chin% c("months","month","mth","mnth","monthly","mnthly"))] <- "months" + if(is.list(Quantile_RollWindows)) names(Quantile_RollWindows)[which(names(Quantile_RollWindows) %chin% c("months","month","mth","mnth","monthly","mnthly"))] <- "months" + } + if(any(c("quarter","quarters","qarter","quarterly","q","qtly") %chin% tolower(TimeGroups))) { + TimeGroupPlaceHolder <- c(TimeGroupPlaceHolder, "quarter") + if(is.list(Lags)) names(Lags)[which(names(Lags) %chin% c("quarter","qarter","quarterly","q","qtly"))] <- "quarter" + if(is.list(MA_RollWindows)) names(MA_RollWindows)[which(names(MA_RollWindows) %chin% c("quarter","qarter","quarterly","q","qtly"))] <- "quarter" + if(is.list(SD_RollWindows)) names(SD_RollWindows)[which(names(SD_RollWindows) %chin% c("quarter","qarter","quarterly","q","qtly"))] <- "quarter" + if(is.list(Skew_RollWindows)) names(Skew_RollWindows)[which(names(Skew_RollWindows) %chin% c("quarter","qarter","quarterly","q","qtly"))] <- "quarter" + if(is.list(Kurt_RollWindows)) names(Kurt_RollWindows)[which(names(Kurt_RollWindows) %chin% c("quarter","qarter","quarterly","q","qtly"))] <- "quarter" + if(is.list(Quantile_RollWindows)) names(Quantile_RollWindows)[which(names(Quantile_RollWindows) %chin% c("quarter","qarter","quarterly","q","qtly"))] <- "quarter" + } + if(any(c("year","years","annual","yearly","annually","ann","yr","yrly") %chin% tolower(TimeGroups))) { + TimeGroupPlaceHolder <- c(TimeGroupPlaceHolder, "year") + if(is.list(Lags)) names(Lags)[which(names(Lags) %chin% c("year","annual","yearly","annually","ann","yr","yrly"))] <- "year" + if(is.list(MA_RollWindows)) names(MA_RollWindows)[which(names(MA_RollWindows) %chin% c("year","annual","yearly","annually","ann","yr","yrly"))] <- "year" + if(is.list(SD_RollWindows)) names(SD_RollWindows)[which(names(SD_RollWindows) %chin% c("year","annual","yearly","annually","ann","yr","yrly"))] <- "year" + if(is.list(Skew_RollWindows)) names(Skew_RollWindows)[which(names(Skew_RollWindows) %chin% c("year","annual","yearly","annually","ann","yr","yrly"))] <- "year" + if(is.list(Kurt_RollWindows)) names(Kurt_RollWindows)[which(names(Kurt_RollWindows) %chin% c("year","annual","yearly","annually","ann","yr","yrly"))] <- "year" + if(is.list(Quantile_RollWindows)) names(Quantile_RollWindows)[which(names(Quantile_RollWindows) %chin% c("year","annual","yearly","annually","ann","yr","yrly"))] <- "year" + } + TimeGroups <- TimeGroupPlaceHolder + if(is.null(TimeUnitAgg)) TimeUnitAgg <- TimeGroups[1L] + #The correct TimeGroups are: c("hour", "day", "weeks", "months", "quarter", "year", "1min", "5min", "10min", "15min", "30min", "45min") + + # Ensure date column is proper ---- + if(Debug) print("Data Wrangling: Convert DateColumnName to Date or POSIXct----") + if(!(tolower(TimeUnit) %chin% c("1min","5min","10min","15min","30min","hour"))) { + if(is.character(data[[eval(DateColumn)]])) { + x <- data[1,get(DateColumn)] + x1 <- lubridate::guess_formats(x, orders = c("mdY", "BdY", "Bdy", "bdY", "bdy", "mdy", "dby", "Ymd", "Ydm")) + data.table::set(data, j = eval(DateColumn), value = as.Date(data[[eval(DateColumn)]], tryFormats = x1)) + } + } else { + data.table::set(data, j = eval(DateColumn), value = as.POSIXct(data[[eval(DateColumn)]])) + } + + # Debugging---- + if(Debug) print("AutoLagRollStats: No Categoricals") + + # No Categoricals---- + if(is.null(IndependentGroups) && is.null(HierarchyGroups)) { + + # Initialize Counter---- + Counter <- 0L + + # Loop through various time aggs---- + for(timeaggs in TimeGroups) { + + # Increment Counter---- + Counter <- Counter + 1L + + # Copy data---- + tempData <- data.table::copy(data) + + # Check time scale---- + if(Counter > 1) { + + # Floor Date column to timeagg level---- + data.table::set(tempData, j = eval(DateColumn), value = lubridate::floor_date(x = tempData[[eval(DateColumn)]], unit = timeaggs)) + + # Agg by date column---- + tempData <- tempData[, lapply(.SD, mean, na.rm = TRUE), .SDcols = c(eval(Targets)), by = c(eval(DateColumn))] + + # Build features---- + tempData <- DT_GDL_Feature_Engineering( + tempData, + lags = if(is.list(Lags)) Lags[[timeaggs]] else Lags, + periods = if(is.list(MA_RollWindows)) MA_RollWindows[[timeaggs]] else MA_RollWindows, + SDperiods = if(is.list(SD_RollWindows)) SD_RollWindows[[timeaggs]] else SD_RollWindows, + Skewperiods = if(is.list(Skew_RollWindows)) Skew_RollWindows[[timeaggs]] else Skew_RollWindows, + Kurtperiods = if(is.list(Kurt_RollWindows)) Kurt_RollWindows[[timeaggs]] else Kurt_RollWindows, + Quantileperiods = if(is.list(Quantile_RollWindows)) Quantile_RollWindows[[timeaggs]] else Quantile_RollWindows, + statsFUNs = RollFunctions, + targets = Targets, + groupingVars = NULL, + sortDateName = DateColumn, + timeDiffTarget = NULL, + timeAgg = timeaggs, + WindowingLag = RollOnLag1, + ShortName = ShortName, + Type = Type, + SimpleImpute = SimpleImpute) + + } else { + + # Build features---- + data.table::setkeyv(data <- DT_GDL_Feature_Engineering( + data, + lags = if(is.list(Lags)) Lags[[timeaggs]] else Lags, + periods = if(is.list(MA_RollWindows)) MA_RollWindows[[timeaggs]] else MA_RollWindows, + SDperiods = if(is.list(SD_RollWindows)) SD_RollWindows[[timeaggs]] else SD_RollWindows, + Skewperiods = if(is.list(Skew_RollWindows)) Skew_RollWindows[[timeaggs]] else Skew_RollWindows, + Kurtperiods = if(is.list(Kurt_RollWindows)) Kurt_RollWindows[[timeaggs]] else Kurt_RollWindows, + Quantileperiods = if(is.list(Quantile_RollWindows)) Quantile_RollWindows[[timeaggs]] else Quantile_RollWindows, + statsFUNs = RollFunctions, + targets = Targets, + groupingVars = NULL, + sortDateName = DateColumn, + timeDiffTarget = NULL, + timeAgg = timeaggs, + WindowingLag = RollOnLag1, + ShortName = ShortName, + Type = Type, + SimpleImpute = SimpleImpute), DateColumn) + } + + # Check if timeaggs is same of TimeUnit---- + if(Counter > 1L) { + data.table::setkeyv(data[, TEMPDATE := lubridate::floor_date(get(DateColumn), unit = eval(timeaggs))], "TEMPDATE") + data[tempData, (setdiff(names(tempData), names(data))) := mget(paste0("i.", setdiff(names(tempData), names(data))))] + data.table::set(data, j = "TEMPDATE", value = NULL) + } + } + } + + # Debugging---- + if(Debug) print("AutoLagRollStats: Indep + Hierach") + + # Hierarchy Categoricals---- + if(!is.null(HierarchyGroups)) { + + # Categorical Names Fully Interacted---- + Categoricals <- FullFactorialCatFeatures(GroupVars = HierarchyGroups, BottomsUp = TRUE) + + # Categorical Names Fully Interacted (Check if there already)---- + for(cat in seq_len(length(Categoricals)-length(HierarchyGroups))) { + if(!any(names(data) %chin% Categoricals[cat])) data[, eval(Categoricals[cat]) := do.call(paste, c(.SD, sep = " ")), .SDcols = c(unlist(data.table::tstrsplit(Categoricals[cat], "_")))] + } + + # Loop through each feature interaction + Counter <- 0L + for(Fact in Categoricals) { + + # Loop through all TimeGroups---- + for(timeaggs in TimeGroups) { + + # Counter incrementing + Counter <- Counter + 1L + + # Check if timeaggs is same of TimeUnitAgg ---- + if(Counter > 1L) { + + # Aggregate tempData and tempRegs to correct dimensional level---- + tempData <- data[, .SD, .SDcols = c(eval(Targets), eval(DateColumn), eval(Fact))] + + # Agg by date column ---- + if(timeaggs != "raw") { + tempData[, eval(DateColumn) := lubridate::floor_date(x = get(DateColumn), unit = timeaggs)] + tempData <- tempData[, lapply(.SD, mean, na.rm = TRUE), .SDcols = c(eval(Targets)), by = c(eval(DateColumn), eval(Fact))] + } + + # Build GDL Features---- + data.table::setkeyv(tempData <- DT_GDL_Feature_Engineering( + tempData, + lags = if(is.list(Lags)) Lags[[timeaggs]] else Lags, + periods = if(is.list(MA_RollWindows)) MA_RollWindows[[timeaggs]] else MA_RollWindows, + SDperiods = if(is.list(SD_RollWindows)) SD_RollWindows[[timeaggs]] else SD_RollWindows, + Skewperiods = if(is.list(Skew_RollWindows)) Skew_RollWindows[[timeaggs]] else Skew_RollWindows, + Kurtperiods = if(is.list(Kurt_RollWindows)) Kurt_RollWindows[[timeaggs]] else Kurt_RollWindows, + Quantileperiods = if(is.list(Quantile_RollWindows)) Quantile_RollWindows[[timeaggs]] else Quantile_RollWindows, + statsFUNs = RollFunctions, + targets = Targets, + groupingVars = Fact, + sortDateName = DateColumn, + timeDiffTarget = NULL, + timeAgg = timeaggs, + WindowingLag = RollOnLag1, + ShortName = ShortName, + Type = Type, + SimpleImpute = SimpleImpute), c(Fact, DateColumn)) + + } else { + + # Build GDL Features---- + data <- DT_GDL_Feature_Engineering( + data, + lags = if(is.list(Lags)) Lags[[timeaggs]] else Lags, + periods = if(is.list(MA_RollWindows)) MA_RollWindows[[timeaggs]] else MA_RollWindows, + SDperiods = if(is.list(SD_RollWindows)) SD_RollWindows[[timeaggs]] else SD_RollWindows, + Skewperiods = if(is.list(Skew_RollWindows)) Skew_RollWindows[[timeaggs]] else Skew_RollWindows, + Kurtperiods = if(is.list(Kurt_RollWindows)) Kurt_RollWindows[[timeaggs]] else Kurt_RollWindows, + Quantileperiods = if(is.list(Quantile_RollWindows)) Quantile_RollWindows[[timeaggs]] else Quantile_RollWindows, + statsFUNs = RollFunctions, + targets = Targets, + groupingVars = Fact, + sortDateName = DateColumn, + timeDiffTarget = NULL, + timeAgg = timeaggs, + WindowingLag = RollOnLag1, + ShortName = ShortName, + Type = Type, + SimpleImpute = SimpleImpute) + } + + # Check if timeaggs is same of TimeUnit---- + if(Counter > 1L) { + data.table::setkeyv(data[, TEMPDATE := lubridate::floor_date(get(DateColumn), unit = eval(timeaggs))], c(Fact,"TEMPDATE")) + data[tempData, (setdiff(names(tempData), names(data))) := mget(paste0("i.", setdiff(names(tempData), names(data))))] + data.table::set(data, j = "TEMPDATE", value = NULL) + } + } + } + } + + # Debugging---- + if(Debug) print("AutoLagRollStats: Indep") + + # Single categoricals at a time AND no hierarchical: if there are hierarchical the single cats will be handled above---- + if(!is.null(IndependentGroups) && is.null(HierarchyGroups)) { + + # Loop through IndependentGroups---- + Counter <- 0L + # Fact = IndependentGroups[1] + # timeaggs = TimeGroups[1] + for(Fact in IndependentGroups) { + + # Loop through all TimeGroups---- + for(timeaggs in TimeGroups) { + + # Counter incrementing + Counter <- Counter + 1L + + # Copy data---- + tempData <- data.table::copy(data) + + # Check if timeaggs is same of TimeUnit ---- + if(Counter > 1L) { + + # Floor Date column to timeagg level ---- + tempData[, eval(DateColumn) := lubridate::floor_date(x = get(DateColumn), unit = timeaggs)] + + # Agg by date column---- + tempData <- tempData[, lapply(.SD, mean, na.rm = TRUE), .SDcols = c(eval(Targets)), by = c(eval(DateColumn),eval(Fact))] + + # Build GDL Features---- + data.table::setkeyv(tempData <- DT_GDL_Feature_Engineering( + tempData, + lags = if(is.list(Lags)) Lags[[timeaggs]] else Lags, + periods = if(is.list(MA_RollWindows)) MA_RollWindows[[timeaggs]] else MA_RollWindows, + SDperiods = if(is.list(SD_RollWindows)) SD_RollWindows[[timeaggs]] else SD_RollWindows, + Skewperiods = if(is.list(Skew_RollWindows)) Skew_RollWindows[[timeaggs]] else Skew_RollWindows, + Kurtperiods = if(is.list(Kurt_RollWindows)) Kurt_RollWindows[[timeaggs]] else Kurt_RollWindows, + Quantileperiods = if(is.list(Quantile_RollWindows)) Quantile_RollWindows[[timeaggs]] else Quantile_RollWindows, + statsFUNs = RollFunctions, + targets = Targets, + groupingVars = Fact, + sortDateName = DateColumn, + timeDiffTarget = NULL, + timeAgg = timeaggs, + ShortName = ShortName, + WindowingLag = RollOnLag1, + Type = Type, + SimpleImpute = SimpleImpute), c(Fact, DateColumn)) + + } else { + + # Set up for binary search instead of vector scan + data.table::setkeyv(x = data, cols = c(eval(Fact),eval(DateColumn))) + + # Build GDL Features + data <- DT_GDL_Feature_Engineering( + data, + lags = if(is.list(Lags)) Lags[[timeaggs]] else Lags, + periods = if(is.list(MA_RollWindows)) MA_RollWindows[[timeaggs]] else MA_RollWindows, + SDperiods = if(is.list(SD_RollWindows)) SD_RollWindows[[timeaggs]] else SD_RollWindows, + Skewperiods = if(is.list(Skew_RollWindows)) Skew_RollWindows[[timeaggs]] else Skew_RollWindows, + Kurtperiods = if(is.list(Kurt_RollWindows)) Kurt_RollWindows[[timeaggs]] else Kurt_RollWindows, + Quantileperiods = if(is.list(Quantile_RollWindows)) Quantile_RollWindows[[timeaggs]] else Quantile_RollWindows, + statsFUNs = RollFunctions, + targets = Targets, + groupingVars = Fact, + sortDateName = DateColumn, + timeDiffTarget = TimeBetween, + timeAgg = timeaggs, + WindowingLag = RollOnLag1, + Type = Type, + ShortName = ShortName, + SimpleImpute = SimpleImpute) + } + + # Check if timeaggs is same of TimeUnit ---- + if(Counter > 1L) { + data.table::setkeyv(data[, TEMPDATE := lubridate::floor_date(get(DateColumn), unit = eval(timeaggs))], c(Fact, "TEMPDATE")) + data[tempData, (setdiff(names(tempData), names(data))) := mget(paste0("i.", setdiff(names(tempData), names(data))))] + data.table::set(data, j = "TEMPDATE", value = NULL) + } + } + } + } + + # Simple impute missed ---- + if(SimpleImpute) { + for(miss in seq_along(data)) { + data.table::set(data, i = which(is.na(data[[miss]])), j = miss, value = -1) + } + } + + # Return data ---- + if("TEMPDATE" %chin% names(data)) data.table::set(data, j = "TEMPDATE", value = NULL) + return(data) +} + +#' @title DT_GDL_Feature_Engineering +#' +#' @description Builds autoregressive and moving average from target columns and distributed lags and distributed moving average for independent features distributed across time. On top of that, you can also create time between instances along with their associated lags and moving averages. This function works for data with groups and without groups. +#' +#' @author Adrian Antico +#' @family Feature Engineering +#' +#' @param data A data.table you want to run the function on +#' @param lags A numeric vector of the specific lags you want to have generated. You must include 1 if WindowingLag = 1. +#' @param periods A numeric vector of the specific rolling statistics window sizes you want to utilize in the calculations. +#' @param SDperiods A numeric vector of Standard Deviation rolling statistics window sizes you want to utilize in the calculations. +#' @param Skewperiods A numeric vector of Skewness rolling statistics window sizes you want to utilize in the calculations. +#' @param Kurtperiods A numeric vector of Kurtosis rolling statistics window sizes you want to utilize in the calculations. +#' @param Quantileperiods A numeric vector of Quantile rolling statistics window sizes you want to utilize in the calculations. +#' @param statsFUNs Select from the following c("mean","sd","skew","kurt","q5","q10","q15","q20","q25","q30","q35","q40","q45","q50","q55","q60","q65","q70","q75","q80","q85","q90","q95") +#' @param targets A character vector of the column names for the reference column in which you will build your lags and rolling stats +#' @param groupingVars A character vector of categorical variable names you will build your lags and rolling stats by +#' @param sortDateName The column name of your date column used to sort events over time +#' @param timeDiffTarget Specify a desired name for features created for time between events. Set to NULL if you don't want time between events features created. +#' @param timeAgg List the time aggregation level for the time between events features, such as "hour", "day", "week", "month", "quarter", or "year" +#' @param WindowingLag Set to 0 to build rolling stats off of target columns directly or set to 1 to build the rolling stats off of the lag-1 target +#' @param Type List either "Lag" if you want features built on historical values or "Lead" if you want features built on future values +#' @param ShortName Default TRUE. If FALSE, Group Variable names will be added to the rolling stat and lag names. If you plan on have multiple versions of lags and rollings stats by different group variables then set this to FALSE. +#' @param SimpleImpute Set to TRUE for factor level imputation of "0" and numeric imputation of -1 +#' @return data.table of original data plus created lags, rolling stats, and time between event lags and rolling stats +#' @export +DT_GDL_Feature_Engineering <- function(data, + lags = 1, + periods = 0, + SDperiods = 0, + Skewperiods = 0, + Kurtperiods = 0, + Quantileperiods = 0, + statsFUNs = c("mean"), + targets = NULL, + groupingVars = NULL, + sortDateName = NULL, + timeDiffTarget = NULL, + timeAgg = c("days"), + WindowingLag = 0, + ShortName = TRUE, + Type = c("Lag"), + SimpleImpute = TRUE) { + + # timeAgg + if(is.null(timeAgg)) { + timeAgg <- "TimeUnitNULL" + } else if(tolower(timeAgg) == "raw") { + timeAggss <- "transactional" + timeAgg <- "day" + } else { + timeAggss <- timeAgg + } + + # Number of targets + tarNum <- length(targets) + + # Argument Checks + if(is.null(lags) && WindowingLag == 1) lags <- 1 + if(!(1 %in% lags) && WindowingLag == 1) lags <- c(1, lags) + if(any(lags < 0)) stop("lags need to be positive integers") + if(!is.null(groupingVars)) if(!is.character(groupingVars)) stop("groupingVars needs to be a character scalar or vector") + if(!is.character(targets)) stop("targets needs to be a character scalar or vector") + if(!is.character(sortDateName)) stop("sortDateName needs to be a character scalar or vector") + if(!is.null(timeAgg)) if(!is.character(timeAgg)) stop("timeAgg needs to be a character scalar or vector") + if(!(WindowingLag %in% c(0, 1))) stop("WindowingLag needs to be either 0 or 1") + if(!(tolower(Type) %chin% c("lag", "lead"))) stop("Type needs to be either Lag or Lead") + if(!is.logical(SimpleImpute)) stop("SimpleImpute needs to be TRUE or FALSE") + + # Ensure enough columns are allocated beforehand + if(!is.null(groupingVars)) { + if(ncol(data) + (length(lags) + length(periods)) * tarNum * length(groupingVars) * length(statsFUNs) > data.table::truelength(data)) { + data.table::alloc.col(DT = data, n = ncol(data) + (length(lags) + length(periods)) * tarNum * length(groupingVars) * length(statsFUNs)) + } + } else { + if(ncol(data) + (length(lags) + length(periods)) * tarNum * length(statsFUNs) > data.table::truelength(data)) { + data.table::alloc.col(DT = data, n = ncol(data) + (length(lags) + length(periods)) * tarNum * length(statsFUNs)) + } + } + + # Begin feature engineering---- + if(!is.null(groupingVars)) { + for(i in seq_along(groupingVars)) {# i = 1 + Targets <- targets + + # Sort data---- + if(tolower(Type) == "lag") { + colVar <- c(groupingVars[i], sortDateName[1L]) + data.table::setorderv(data, colVar, order = 1L) + } else { + colVar <- c(groupingVars[i], sortDateName[1L]) + data.table::setorderv(data, colVar, order = -1L) + } + + # Lags ---- + LAG_Names <- c() + for(t in Targets) { + if(ShortName) { + LAG_Names <- c(LAG_Names, paste0(timeAggss, "_LAG_", lags, "_", t)) + } else { + LAG_Names <- c(LAG_Names, paste0(timeAggss, "_", groupingVars[i], "_LAG_", lags, "_", t)) + } + } + data[, paste0(LAG_Names) := data.table::shift(.SD, n = lags, type = "lag"), by = c(groupingVars[i]), .SDcols = c(Targets)] + + # Define targets---- + if(WindowingLag != 0L) { + if(ShortName) { + Targets <- paste0(timeAggss, "_LAG_", WindowingLag, "_", Targets) + } else { + Targets <- paste0(timeAggss, "_", groupingVars[i], "_LAG_", WindowingLag, "_", Targets) + } + } + + # MA stats ---- + if(any(tolower(statsFUNs) %chin% "mean") && !all(periods %in% c(0L, 1L))) { + periods <- periods[periods > 1L] + MA_Names <- c() + for(t in Targets) for(j in seq_along(periods)) MA_Names <- c(MA_Names, paste0("Mean_", periods[j],"_", t)) + data[, paste0(MA_Names) := data.table::frollmean( + x = .SD, n = periods, fill = NA, algo = "fast", align = "right", na.rm = TRUE, hasNA = TRUE, adaptive = FALSE), + by = c(groupingVars[i]), .SDcols = c(Targets)] + } + + # SD stats ---- + if(any(tolower(statsFUNs) %chin% c("sd")) && !all(SDperiods %in% c(0L,1L))) { + tempperiods <- SDperiods[SDperiods > 1L] + SD_Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) SD_Names <- c(SD_Names, paste0("SD_", tempperiods[j], "_", t)) + data[, paste0(SD_Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = sd, na.rm = TRUE), by = c(groupingVars[i]), .SDcols = c(Targets)] + } + + # Skewness stats ---- + if(any(tolower(statsFUNs) %chin% c("skew")) && !all(Skewperiods %in% c(0L,1L,2L))) { + tempperiods <- Skewperiods[Skewperiods > 2L] + Skew_Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) Skew_Names <- c(Skew_Names, paste0("Skew_", tempperiods[j], "_", t)) + data[, paste0(Skew_Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = e1071::skewness, na.rm = TRUE), by = c(groupingVars[i]), .SDcols = Targets] + } + + # Kurtosis stats ---- + if(any(tolower(statsFUNs) %chin% c("kurt")) && !all(Kurtperiods %in% c(0L,1L,2L,3L,4L))) { + tempperiods <- Kurtperiods[Kurtperiods > 3L] + Kurt_Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) Kurt_Names <- c(Kurt_Names, paste0("Kurt_", tempperiods[j], "_", t)) + data[, paste0(Kurt_Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = e1071::kurtosis, na.rm = TRUE), by = c(groupingVars[i]), .SDcols = c(Targets)] + } + + # Quantiles ---- + if(!all(Quantileperiods %in% c(0L,1L,2L,3L,4L))) { + tempperiods <- Quantileperiods[Quantileperiods > 4L] + for(z in c(seq(5L,95L,5L))) { + if(any(paste0("q",z) %chin% statsFUNs)) { + Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) Names <- c(Names, paste0("Q_", z, "_", tempperiods[j], "_", t)) + data[, paste0(Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = quantile, probs = z/100, na.rm = TRUE), by = c(groupingVars[i]), .SDcols = c(Targets)] + } + } + } + } + + # Impute missing values ---- + if(SimpleImpute) { + for(j in seq_along(data)) { + if(is.factor(data[[j]])) { + data.table::set(data, which(!(data[[j]] %in% levels(data[[j]]))), j, "0") + } else { + data.table::set(data, which(is.na(data[[j]])), j, -1) + } + } + } + + # Done!! ---- + return(data) + + } else { + + # Sort data + if(tolower(Type) == "lag") { + data.table::setorderv(data, c(sortDateName[1L]), order = 1L) + } else { + data.table::setorderv(data, c(sortDateName[1L]), order = -1L) + } + Targets <- targets + + # Lags ---- + LAG_Names <- c() + for(t in Targets) LAG_Names <- c(LAG_Names, paste0(timeAggss, "_", "LAG_", lags, "_", t)) + + # Build features ---- + data[, eval(LAG_Names) := data.table::shift(.SD, n = lags, type = "lag"), .SDcols = c(Targets)] + + # Define targets ---- + if(WindowingLag != 0L) { + Targets <- paste0(timeAggss, "_", "LAG_", WindowingLag, "_", Targets) + } else { + Targets <- Targets + } + + # MA stats ---- + if(any(tolower(statsFUNs) %chin% "mean") && !all(periods %in% c(0L, 1L))) { + periods <- periods[periods > 1L] + MA_Names <- c() + for(t in Targets) for(j in seq_along(periods)) MA_Names <- c(MA_Names, paste0("Mean_", periods[j], "_", t)) + data[, paste0(MA_Names) := data.table::frollmean(x = .SD, n = periods, fill = NA, algo = "fast", align = "right", na.rm = TRUE, hasNA = TRUE, adaptive = FALSE), .SDcols = c(Targets)] + } + + # SD stats ---- + if(any(tolower(statsFUNs) %chin% c("sd")) && !all(SDperiods %in% c(0L,1L))) { + tempperiods <- SDperiods[SDperiods > 1L] + SD_Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) SD_Names <- c(SD_Names, paste0("SD_", tempperiods[j], "_", t)) + data[, paste0(SD_Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = sd, na.rm = TRUE), .SDcols = c(Targets)] + } + + # Skewness stats ---- + if(any(tolower(statsFUNs) %chin% c("skew")) && !all(Skewperiods %in% c(0L,1L,2L))) { + tempperiods <- Skewperiods[Skewperiods > 2L] + Skew_Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) Skew_Names <- c(Skew_Names, paste0("Skew_", tempperiods[j], "_", t)) + data[, paste0(Skew_Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = e1071::skewness, na.rm = TRUE), .SDcols = c(Targets)] + } + + # Kurtosis stats ---- + if(any(tolower(statsFUNs) %chin% c("kurt")) && !all(Kurtperiods %in% c(0L,1L,2L,3L))) { + tempperiods <- Kurtperiods[Kurtperiods > 3L] + Kurt_Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) Kurt_Names <- c(Kurt_Names, paste0("Kurt_", tempperiods[j], "_", t)) + data[, paste0(Kurt_Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = e1071::kurtosis, na.rm = TRUE), .SDcols = c(Targets)] + } + + # Quantiles ---- + if(!all(Quantileperiods %in% c(0L,1L,2L,3L,4L))) { + tempperiods <- Quantileperiods[Quantileperiods > 4L] + for(z in c(seq(5L,95L,5L))) { + if(any(paste0("q",z) %chin% statsFUNs)) { + Names <- c() + for(t in Targets) for(j in seq_along(tempperiods)) Names <- c(Names, paste0("Q_", z, "_", tempperiods[j], "_", t)) + data[, paste0(Names) := data.table::frollapply(x = .SD, n = tempperiods, FUN = quantile, probs = z/100, na.rm = TRUE), .SDcols = c(Targets)] + } + } + } + + # Impute missing values ---- + if(SimpleImpute) { + for(j in seq_along(data)) { + if(is.factor(data[[j]])) { + data.table::set(data, which(!(data[[j]] %in% levels(data[[j]]))), j, "0") + } else { + data.table::set(data, which(is.na(data[[j]])), j, -1) + } + } + } + + # Done!! ---- + return(data) + } +} + +#' @title FullFactorialCatFeatures +#' +#' @description FullFactorialCatFeatures reverses the difference +#' +#' @family Data Wrangling +#' +#' @author Adrian Antico +#' +#' @param GroupVars Character vector of categorical columns to fully interact +#' @param MaxCombin The max K in N choose K. If NULL, K will loop through 1 to length(GroupVars) +#' @param BottomsUp TRUE or FALSE. TRUE starts with the most comlex interaction to the main effects +#' +#' @noRd +FullFactorialCatFeatures <- function(GroupVars = NULL, + MaxCombin = NULL, + BottomsUp = TRUE) { + + if(is.null(MaxCombin)) { + MaxCombin <- N <- length(GroupVars) + } else { + N <- MaxCombin + } + Categoricals <- c() + + # N choose 1 case + for(j in seq_along(GroupVars)) Categoricals <- c(Categoricals,GroupVars[j]) + + # N choose i for 2 <= i < N + for(i in seq_len(N)[-1L]) { + + # Case 2: N choose 2 up to N choose N-1: Middle-Hierarchy Interactions + if(MaxCombin == length(GroupVars)) { + if(i < N) { + temp <- combinat::combn(GroupVars, m = i) + temp2 <- c() + for(k in seq_len(ncol(temp))) { + for(l in seq_len(i)) { + if(l == 1L) { + temp2 <- temp[l,k] + } else { + temp2 <- paste(temp2,temp[l,k], sep = '_') + } + } + Categoricals <- c(Categoricals, temp2) + } + + # Case 3: N choose N - Full Interaction + } else if(i == length(GroupVars)) { + temp <- combinat::combn(GroupVars, m = i) + for(m in seq_len(N)) { + if(m == 1) { + temp2 <- temp[m] + } else { + temp2 <- paste(temp2,temp[m], sep = '_') + } + } + Categoricals <- c(Categoricals, temp2) + } + } else { + if(i <= N) { + temp <- combinat::combn(GroupVars, m = i) + temp2 <- c() + for(k in seq_len(ncol(temp))) { + for(l in seq_len(i)) { + if(l == 1L) { + temp2 <- temp[l,k] + } else { + temp2 <- paste(temp2,temp[l,k], sep = '_') + } + } + Categoricals <- c(Categoricals, temp2) + } + + # Case 3: N choose N - Full Interaction + } else if(i == length(GroupVars)) { + temp <- combinat::combn(GroupVars, m = i) + for(m in seq_len(N)) { + if(m == 1) { + temp2 <- temp[m] + } else { + temp2 <- paste(temp2,temp[m], sep = '_') + } + } + Categoricals <- c(Categoricals, temp2) + } + } + } + + # Order of output + if(BottomsUp) return(rev(Categoricals)) else return(Categoricals) +} + +# ---- + +# ---- diff --git a/R/GlobalVariables.R b/R/GlobalVariables.R new file mode 100644 index 0000000..aca05de --- /dev/null +++ b/R/GlobalVariables.R @@ -0,0 +1,94 @@ +# AutoQuant is a package for quickly creating high quality visualizations under a common and easy api. +# 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 . + +utils::globalVariables( + names = c( + "1 - Specificity", + "Adrian", + "Appointments", + "Buckets", + "CalendarDateColumn", + "ClassWeights", + "CohortDateColumn", + "CohortDays", + "Comment", + "CostMatrixWeights", + "Date", + "DateTime", + "FP", + "Gain", + "GroupVariables", + "GroupVars", + "Importance", + "Independent_Variable1", + "Independent_Variable10", + "Independent_Variable2", + "Independent_Variable3", + "Independent_Variable4", + "Independent_Variable5", + "Independent_Variable6", + "Independent_Variable7", + "Independent_Variable8", + "Independent_Variable9", + "Leads", + "Level", + "Lift", + "Mean.X", + "Measure_Variable", + "Measures", + "MethodName", + "Metric", + "ModelID", + "N", + "NegScore", + "Normal Line", + "NormalizedStatistics", + "NumNull", + "P_Predicted", + "Percentile", + "Plot.Polar", + "Population", + "Proportion in Target", + "Rates", + "RowSum", + "Sales", + "SaveModelObjects", + "Specificity", + "TEMPDATE", + "TP", + "Target - Predicted", + "TargetColumnName", + "Theoretical Quantiles", + "TimeLine", + "TrainOnFull", + "ValidationData", + "Weights", + "Y_Scroll", + "V1", + "ZVar", + "classPredict", + "i.Metric", + "metadata_path", + "model_path", + "size_vals", + "spearman", + "temp__", + "temp_i", + "x1", + "x2", + "xx" + ) +) diff --git a/R/Imports.R b/R/Imports.R index d36a109..bc23b33 100644 --- a/R/Imports.R +++ b/R/Imports.R @@ -18,5 +18,7 @@ #' @importFrom data.table data.table %chin% .I .N .SD := as.data.table fwrite is.data.table rbindlist set setcolorder setnames setorderv as.IDate as.ITime %like% #' @importFrom lubridate %m+% #' @importFrom utils installed.packages +#' @importFrom stats as.formula cor cor.test dgeom lm median na.omit optimize pnorm qnorm quantile runif sd setNames var +#' @importFrom utils head NULL .datatable.aware = TRUE diff --git a/R/PlotFunctions.R b/R/PlotFunctions.R index a78dc60..8e9e7a9 100644 --- a/R/PlotFunctions.R +++ b/R/PlotFunctions.R @@ -7,1346 +7,13 @@ # 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 +# but WITHOUT ANY WAfppRRANTY; 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 . -# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ---- -# :: Helper Functions :: ---- -# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ---- - -#' @noRd -SummaryFunction <- function(AggMethod) { - if(AggMethod == "count") { - aggFunc <- function(x) .N - } else if(AggMethod == "mean") { - aggFunc <- function(x) mean(x, na.rm = TRUE) - } else if(AggMethod == "log(mean(x))") { - aggFunc <- function(x) log(mean(x, na.rm = TRUE)) - } else if(AggMethod == "mean(abs(x))") { - aggFunc <- function(x) mean(abs(x), na.rm = TRUE) - } else if(AggMethod == "sum") { - aggFunc <- function(x) sum(x, na.rm = TRUE) - } else if(AggMethod == "log(sum(x))") { - aggFunc <- function(x) log(sum(x, na.rm = TRUE)) - } else if(AggMethod == "sum(abs(x))") { - aggFunc <- function(x) sum(abs(x), na.rm = TRUE) - } else if(AggMethod == "median") { - aggFunc <- function(x) median(x, na.rm = TRUE) - } else if(AggMethod == "log(median(x))") { - aggFunc <- function(x) log(median(x, na.rm = TRUE)) - } else if(AggMethod == "median(abs(x))") { - aggFunc <- function(x) median(abs(x), na.rm = TRUE) - } else if(AggMethod == "sd") { - aggFunc <- function(x) sd(x, na.rm = TRUE) - } else if(AggMethod == "log(sd(x))") { - aggFunc <- function(x) log(sd(x, na.rm = TRUE)) - } else if(AggMethod == "sd(abs(x))") { - aggFunc <- function(x) sd(abs(x), na.rm = TRUE) - } else if(AggMethod == "skewness") { - aggFunc <- function(x) e1071::skewness(x, na.rm = TRUE) - } else if(AggMethod == "skewness(abs(x))") { - aggFunc <- function(x) e1071::skewness(abs(x), na.rm = TRUE) - } else if(AggMethod == "kurtosis") { - aggFunc <- function(x) e1071::kurtosis(x, na.rm = TRUE) - } else if(AggMethod == "kurtosis(abs(x))") { - aggFunc <- function(x) e1071::kurtosis(abs(x), na.rm = TRUE) - } else if(AggMethod == "CoeffVar") { - aggFunc <- function(x) sd(x, na.rm = TRUE) / mean(x, na.rm = TRUE) - } else if(AggMethod == "CoeffVar(abs(x))") { - aggFunc <- function(x) sd(abs(x), na.rm = TRUE) / mean(abs(x), na.rm = TRUE) - } - return(aggFunc) -} - -#' @noRd -ColTypes <- function(data) { - CT <- c() - for(Col in names(data)) CT <- c(CT, class(data[[Col]])[1L]) - CT -} - -#' @noRd -bold_ <- function(x) paste0('',x,'') - -#' @noRd -font_ <- function(family = "Segoe UI Symbol", size = 12, color = 'white') list(family = family, size = size, color = color) - -#' @noRd -ColNameFilter <- function(data, Types = 'all') { - if(Types == 'all') return(names(data)) - nam <- c() - for(t in Types) { - if(tolower(t) == 'numeric') { - nam <- NumericColNames(data) - } else if(tolower(t) == 'character') { - nam <- CharacterColNames(data) - } else if(tolower(t) == 'factor') { - nam <- FactorColNames(data) - } else if(tolower(t) == 'logical') { - nam <- LogicalColNames(data) - } else if(tolower(t) %chin% c("date","idate","idatetime","posixct","posix")) { - nam <- DateColNames(data) - } - } - return(nam) -} - -#' @noRd -NumericColNames <- function(data) { - x <- as.list(names(data)[which(sapply(data, is.numeric))]) - if(!identical(x, character(0))) return(x) else return(NULL) -} - -#' @noRd -CharacterColNames <- function(data) { - x <- as.list(names(data)[which(sapply(data, is.character))]) - if(!identical(x, character(0))) return(x) else return(NULL) -} - -#' @noRd -FactorColNames <- function(data) { - x <- as.list(names(data)[which(sapply(data, is.factor))]) - if(!identical(x, character(0))) return(x) else return(NULL) -} - -#' @noRd -LogicalColNames <- function(data) { - x <- as.list(names(data)[which(sapply(data, is.logical))]) - if(!identical(x, character(0))) return(x) else return(NULL) -} - -#' @noRd -DateColNames <- function(data) { - x <- list() - counter <- 0L - for(i in names(data)) { - if(class(data[[i]])[1L] %in% c("IDate","Date","date","POSIXct","POSIX")) { - counter <- counter + 1L - x[[counter]] <- i - } - } - if(length(x) > 0L) return(x) else return(NULL) -} - -#' # text & logical with NULL default -#' @noRd -CEP <- function(x) if(any(missing(x))) 'NULL' else if(!exists('x')) 'NULL' else if(is.null(x)) "NULL" else if(identical(x, character(0))) "NULL" else if(identical(x, numeric(0))) "NULL" else if(identical(x, integer(0))) "NULL" else if(identical(x, logical(0))) "NULL" else if(any(x == "")) "NULL" else if(any(is.na(x))) "NULL" else if(any(x == 'None')) "NULL" else if(is.numeric(x)) x else if(length(x) > 1) paste0("c(", noquote(paste0("'", x, "'", collapse = ',')), ")") else paste0("'", x, "'") - -#' # number and logical with FALSE / TRUE default -#' @noRd -CEPP <- function(x, Default = NULL, Type = 'character') if(missing(x)) 'NULL' else if(!exists('x')) 'NULL' else if(length(x) == 0) 'NULL' else if(any(is.na(x))) 'NULL' else if(all(x == "")) 'NULL' else if(Type == 'numeric') AutoPlots:::NumNull(x) else if(Type == 'character') AutoPlots:::CharNull(x) - -#' @title ExpandText -#' -#' @description This function is for pasting character vector arguments into their respective parameter slots for code printing (and command line vector argument passing) -#' -#' -#' @noRd -ExpandText <- function(x) { - if(length(x) > 0L) { - if(is.character(x) || is.factor(x) || lubridate::is.Date(x) || lubridate::is.POSIXct(x)) { - return(paste0("c('", paste0(x, collapse = "','"), "')")) - } else if(is.numeric(x) || is.logical(x)) { - return(paste0("c(", paste0(x, collapse = ","), ")")) - } - } else { - return('NULL') - } -} - -#' @title CharNull -#' -#' @param x Value -#' -#' @noRd -CharNull <- function(x, Char = FALSE) { - - if(missing(x)) { - print('CharNull: missing x') - return(NULL) - } - - if(!exists('x')) { - print('CharNull: x does not exist') - return(NULL) - } - - if(length(x) == 0) { - print('CharNull: length(x) == 0') - return(NULL) - } - - if(all(is.na(suppressWarnings(as.character(x))))) { - - return(NULL) - - } else if(any(is.na(suppressWarnings(as.character(x)))) && length(x) > 1) { - - x <- x[!is.na(x)] - x <- suppressWarnings(as.character(x)) - return(x) - - } else if(any(is.na(suppressWarnings(as.character(x)))) && length(x) == 1) { - - return(NULL) - - } else { - - x <- suppressWarnings(as.character(x)) - return(x) - - } - - if(!Char) { - return(NULL) - } else { - return("NULL") - } -} - -#' @title FakeDataGenerator -#' -#' @description Create fake data for examples -#' -#' @author Adrian Antico -#' @family Data Wrangling -#' -#' @param Correlation Set the correlation value for simulated data -#' @param N Number of records -#' @param ID Number of IDcols to include -#' @param ZIP Zero Inflation Model target variable creation. Select from 0 to 5 to create that number of distinctly distributed data, stratifed from small to large -#' @param FactorCount Number of factor type columns to create -#' @param AddDate Set to TRUE to include a date column -#' @param AddComment Set to TRUE to add a comment column -#' @param TimeSeries For testing AutoBanditSarima -#' @param TimeSeriesTimeAgg Choose from "1min", "5min", "10min", "15min", "30min", "hour", "day", "week", "month", "quarter", "year", -#' @param ChainLadderData Set to TRUE to return Chain Ladder Data for using AutoMLChainLadderTrainer -#' @param Classification Set to TRUE to build classification data -#' @param MultiClass Set to TRUE to build MultiClass data -#' @export -FakeDataGenerator <- function(Correlation = 0.70, - N = 1000L, - ID = 5L, - FactorCount = 2L, - AddDate = TRUE, - AddComment = FALSE, - AddWeightsColumn = FALSE, - ZIP = 5L, - TimeSeries = FALSE, - TimeSeriesTimeAgg = "day", - ChainLadderData = FALSE, - Classification = FALSE, - MultiClass = FALSE) { - - # Error checking - if(sum(TimeSeries, Classification, MultiClass) > 1) stop("Only one of the following can be set to TRUE: TimeSeries, Classifcation, and MultiClass") - - # TimeSeries - if(TimeSeries) { - - # Error msg - if(is.null(TimeSeriesTimeAgg)) stop("TimeSeriesAgg cannot be NULL when using TimeSeries = TRUE") - - # Pull in data - data <- data.table::as.data.table(as.numeric(fpp::cafe)) - - # Change names to common names for other calls in this function - data.table::setnames(data, "V1", "Weekly_Sales") - - # Pick a starting date - data.table::set(data, j = "Date", value = "1982-01-01") - data.table::setcolorder(data, c(2L, 1L)) - data[, Date := as.Date(Date)] - - # "1min" - if(tolower(TimeSeriesTimeAgg) %chin% c("1min","1mins","minutes","min","mins","01min","01mins")) { - data[, xx := 1:.N][, Date := Date + lubridate::minutes(1 * 1:.N)][, xx := NULL] - } - - # "5min" - if(tolower(TimeSeriesTimeAgg) %chin% c("5min","5mins","5minutes","min5","mins5","05min")) { - data[, Date := Date + lubridate::minutes(5 * 1:.N)] - } - - # "10min" - if(tolower(TimeSeriesTimeAgg) %chin% c("10min","10mins","10minutes","min10","mins10")) { - data[, Date := Date + lubridate::minutes(10 * 1:.N)] - } - - # "15min" - if(tolower(TimeSeriesTimeAgg) %chin% c("15min","15mins","15minutes","min15","mins15")) { - data[, Date := Date + lubridate::minutes(15 * 1:.N)] - } - - # "30min" - if(tolower(TimeSeriesTimeAgg) %chin% c("30min","30mins","30minutes","min30","mins30")) { - data[, Date := Date + lubridate::minutes(30 * 1:.N)] - } - - # "hour" - if(tolower(TimeSeriesTimeAgg) %chin% c("hour","hours","hr","hrs","our","ours")) { - data[, Date := Date + lubridate::hours(1:.N)] - } - - # "day" - if(tolower(TimeSeriesTimeAgg) %chin% c("day","days","daily","dy","das")) { - data[, Date := Date + lubridate::days(1:.N)] - } - - # "week" - if(tolower(TimeSeriesTimeAgg) %chin% c("week","weeks","wk","wks")) { - data[, Date := Date + lubridate::weeks(1:.N)] - } - - # "month" - if(tolower(TimeSeriesTimeAgg) %chin% c("month","months","mth","mths")) { - data[, Date := Date %m+% months(1:.N)] - } - - # "quarter" - if(tolower(TimeSeriesTimeAgg) %chin% c("quarter","quarters"," qtr","qtrs","qarter")) { - data[, Date := Date %m+% months(3 * 1:.N)] - } - - # "year" - if(tolower(TimeSeriesTimeAgg) %chin% c("year","years","yr","yrs","yts")) { - data[, Date := Date + lubridate::years(1:.N)] - } - - # Return data - return(data) - } - - # Create ChainLadderData - if(ChainLadderData) { - - # Overwrite N - N <- 1000 - - # Define constants - MaxCohortDays <- 15L - - # Start date - CalendarDateData <- data.table::data.table(CalendarDateColumn = rep(as.Date("2018-01-01"), N), key = "CalendarDateColumn") - - # Increment date column so it is sequential - CalendarDateData[, temp := seq_len(N)] - CalendarDateData[, CalendarDateColumn := CalendarDateColumn + lubridate::days(temp) - 1L] - CohortDate_temp <- data.table::copy(CalendarDateData) - data.table::setnames(x = CohortDate_temp, old = c("CalendarDateColumn"), new = c("CohortDate_temp")) - - # Cross join the two data sets - ChainLadderData <- data.table::setkeyv(data.table::CJ( - CalendarDateColumn = CalendarDateData$CalendarDateColumn, - CohortDateColumn = CohortDate_temp$CohortDate_temp, - sorted = TRUE, - unique = TRUE), - cols = c("CalendarDateColumn", "CohortDateColumn")) - - # Remove starter data sets and N - rm(CalendarDateData, CohortDate_temp, N) - - # Remove impossible dates - ChainLadderData <- ChainLadderData[CohortDateColumn >= CalendarDateColumn] - - # Add CohortPeriods - ChainLadderData[, CohortDays := as.numeric(difftime(CohortDateColumn, CalendarDateColumn, tz = "MST", units = "day"))] - - # Limit the number of CohortTime - ChainLadderData <- ChainLadderData[CohortDays < MaxCohortDays] - - # Add measure columns placeholder values - ChainLadderData[, ":=" (Leads = 0, Appointments = 0, Rates = 0)] - - # Sort decending both date columns - data.table::setorderv(x = ChainLadderData, cols = c("CalendarDateColumn","CohortDateColumn"), order = c(-1L, 1L)) - - # Add columns for BaselineMeasure and ConversionMeasure - UniqueCalendarDates <- unique(ChainLadderData$CalendarDateColumn) - NN <- length(UniqueCalendarDates) - LoopSeq <- c(1:15) - LoopSeq <- cumsum(LoopSeq) - LoopSeq <- c(1, LoopSeq) - LoopSeq <- c(LoopSeq, seq(135, 15*993, 15)) - for(cal in seq(NN)) { - - # Generate first element of decay data - DecayCurveData <- dgeom(x = 0, prob = runif(n = 1L, min = 0.45, max = 0.55), log = FALSE) - - # Fill in remain elements in vector - if(cal > 1L) { - zz <- seq_len(min(15L, cal)) - for(i in zz[1:min(cal-1L,15)]) { - DecayCurveData <- c(DecayCurveData, c(dgeom(x = i, prob = runif(n = 1L, min = 0.45, max = 0.55), log = FALSE))) - } - } - - # Fill ChainLadderData - data.table::set(ChainLadderData, i = (LoopSeq[cal]+1L):LoopSeq[cal + 1L], j = "Rates", value = DecayCurveData[seq_len(min(15L, cal))]) - } - - # Fill in Leads and Conversions---- - x <- unique(ChainLadderData[, .SD, .SDcols = c("CalendarDateColumn","Leads")]) - x[, Leads := runif(n = x[, .N], min = 100, max = 500)] - ChainLadderData <- merge(ChainLadderData[, .SD, .SDcols = c("CalendarDateColumn","CohortDateColumn","CohortDays","Appointments","Rates")], x, by = "CalendarDateColumn", all = FALSE) - ChainLadderData[, Appointments := Leads * Rates] - ChainLadderData[, Sales := Appointments * Rates * (runif(.N))] - ChainLadderData[, Rates := NULL] - data.table::setcolorder(ChainLadderData, c(1,2,3,5,4)) - return(ChainLadderData) - } - - # Modify---- - if(MultiClass && FactorCount == 0L) { - FactorCount <- 1L - temp <- 1L - } - - # Create data---- - Correl <- Correlation - data <- data.table::data.table(Adrian = runif(N)) - data[, x1 := qnorm(Adrian)] - data[, x2 := runif(N)] - data[, Independent_Variable1 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] - data[, Independent_Variable2 := log(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] - data[, Independent_Variable3 := exp(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] - data[, Independent_Variable4 := exp(exp(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2))))] - data[, Independent_Variable5 := sqrt(pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))] - data[, Independent_Variable6 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^0.10] - data[, Independent_Variable7 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^0.25] - data[, Independent_Variable8 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^0.75] - data[, Independent_Variable9 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^2] - data[, Independent_Variable10 := (pnorm(Correl * x1 + sqrt(1-Correl^2) * qnorm(x2)))^4] - if(ID > 0L) for(i in seq_len(ID)) data[, paste0("IDcol_", i) := runif(N)] - data[, ":=" (x2 = NULL)] - - # FactorCount---- - for(i in seq_len(FactorCount)) { - RandomValues <- sort(c(runif(n = 4L, min = 0.01, max = 0.99))) - RandomLetters <- sort(c(sample(x = LETTERS, size = 5L, replace = FALSE))) - data[, paste0("Factor_", i) := as.factor( - data.table::fifelse(Independent_Variable1 < RandomValues[1L], RandomLetters[1L], - data.table::fifelse(Independent_Variable1 < RandomValues[2L], RandomLetters[2L], - data.table::fifelse(Independent_Variable1 < RandomValues[3L], RandomLetters[3L], - data.table::fifelse(Independent_Variable1 < RandomValues[4L], RandomLetters[4L], RandomLetters[5L])))))] - } - - # Add date---- - if(AddDate) { - if(FactorCount == 0) { - data <- data[, DateTime := as.Date(Sys.time())] - data[, temp := seq_len(.N)][, DateTime := DateTime - temp][, temp := NULL] - data <- data[order(DateTime)] - } else { - data <- data[, DateTime := as.Date(Sys.time())] - CatFeatures <- sort(c(as.numeric(which(sapply(data, is.factor))), as.numeric(which(sapply(data, is.character))))) - data[, temp := seq_len(.N), by = c(names(data)[c(CatFeatures)])][, DateTime := DateTime - temp][, temp := NULL] - data.table::setorderv(x = data, cols = c("DateTime", c(names(data)[c(CatFeatures)])), order = rep(1, length(c(names(data)[c(CatFeatures)]))+1)) - } - } - - # Zero Inflation Setup - if(!Classification && !MultiClass) { - if(ZIP == 1L) { - data[, Adrian := data.table::fifelse(Adrian < 0.5, 0, Independent_Variable8)][, Independent_Variable8 := NULL] - } else if(ZIP == 2L) { - data[, Adrian := data.table::fifelse(Adrian < 0.33, 0, data.table::fifelse(Adrian < 0.66, log(Adrian * 10), log(Adrian*20)))] - } else if(ZIP == 3L) { - data[, Adrian := data.table::fifelse(Adrian < 0.25, 0, data.table::fifelse(Adrian < 0.50, log(Adrian * 10), data.table::fifelse(Adrian < 0.75, log(Adrian * 50), log(Adrian * 150))))] - } else if(ZIP == 4L) { - data[, Adrian := data.table::fifelse(Adrian < 0.20, 0, data.table::fifelse(Adrian < 0.40, log(Adrian * 10), data.table::fifelse(Adrian < 0.60, log(Adrian * 50), data.table::fifelse(Adrian < 0.80, log(Adrian * 150), log(Adrian * 250)))))] - } else if(ZIP == 5L) { - data[, Adrian := data.table::fifelse(Adrian < 1/6, 0, data.table::fifelse(Adrian < 2/6, log(Adrian * 10), data.table::fifelse(Adrian < 3/6, log(Adrian * 50), data.table::fifelse(Adrian < 4/6, log(Adrian * 250), data.table::fifelse(Adrian < 5/6, log(Adrian * 500), log(Adrian * 1000))))))] - } - } - - # Classification - if(Classification) data[, Adrian := data.table::fifelse(jitter(x = Adrian, factor = 100) > 0.63, 1, 0)] - - # Remove---- - data[, ":=" (x1 = NULL)] - - # MultiClass - if(MultiClass) { - data[, Adrian := NULL] - data.table::setnames(data, "Factor_1", "Adrian") - } - - # Comment data - if(AddComment) { - a <- c('Hello', 'Hi', 'Howdy') - b <- c('really like', 'absolutely adore', 'sucks ass') - c <- c('noload', 'download', 'upload') - N1 <- 1/length(a) - N2 <- 1/length(b) - N3 <- 1/length(c) - N11 <- 1/N1 - N22 <- 1/N2 - N33 <- 1/N3 - RandomText <- function(N1,N11,N2,N22,N3,N33,a,b,c) { - paste(sample(x = a, size = 1, replace = TRUE, prob = rep(N1, N11)), - sample(x = b, size = 1, replace = TRUE, prob = rep(N2, N22)), - sample(x = c, size = 1, replace = TRUE, prob = rep(N3, N33))) - } - data[, Comment := "a"] - for(i in seq_len(data[, .N])) { - data.table::set(data, i = i, j = "Comment", value = RandomText(N1,N11,N2,N22,N3,N33,a,b,c)) - } - } - - # Add weights column - if(AddWeightsColumn) { - data[, Weights := runif(.N)] - } - - # Return data - return(data) -} - -#' @title Standardize -#' -#' @description Generate standardized values for multiple variables, by groups if provided, and with a selected granularity -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' -#' @param data Source data.table -#' @param ColNames Character vector of column names -#' @param GroupVars Character vector of column names to have percent ranks by the group levels -#' @param Center TRUE -#' @param Scale TRUE -#' @param ScoreTable FALSE. Set to TRUE to return a data.table that can be used to apply or backtransform via StandardizeScoring -#' -#' @examples -#' \dontrun{ -#' data <- data.table::fread(file.choose()) -#' x <- Standardize(data = data, ColNames = c('Weekly_Sales', 'XREG3'), GroupVars = c('Region','Store','Dept'), Center = TRUE, Scale = TRUE, ScoreTable = TRUE) -#' } -#' -#' @noRd -Standardize <- function(data, ColNames, GroupVars = NULL, Center = TRUE, Scale = TRUE, ScoreTable = FALSE) { - - # Standardize - if(length(GroupVars) == 0L) { - data[, paste0(ColNames, '_Standardize') := lapply(.SD, FUN = function(x) (x - mean(x, na.rm = TRUE)) / sd(x, na.rm = TRUE)), .SDcols = c(ColNames)] - } else { - data[, paste0(ColNames, '_Standardize') := lapply(.SD, FUN = function(x) (x - mean(x, na.rm = TRUE)) / sd(x, na.rm = TRUE)), .SDcols = c(ColNames), by = c(eval(GroupVars))] - } - - # ScoreTable creation - if(ScoreTable) { - x <- data[, lapply(.SD, mean, na.rm = TRUE), .SDcols = c(ColNames), by = c(GroupVars)] - data.table::setnames(x = x, old = ColNames, new = paste0(ColNames, "_mean")) - y <- data[, lapply(.SD, sd, na.rm = TRUE), .SDcols = c(ColNames), by = c(GroupVars)] - data.table::setnames(x = y, old = ColNames, new = paste0(ColNames, "_sd")) - xy <- cbind(x,y[, (GroupVars) := NULL]) - } - - # Return - if(!ScoreTable) { - return(data) - } else { - return(list( - data = data, - ScoreTable = xy - )) - } -} - -#' @title StandardizeScoring -#' -#' @description Generate standardized values for multiple variables, by groups if provided, and with a selected granularity -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' -#' @param data Source data.table -#' @param Apply 'apply' or 'backtransform' -#' @param ColNames Character vector of column names -#' @param GroupVars Character vector of column names to have percent ranks by the group levels -#' @param Center TRUE -#' @param Scale TRUE -#' -#' @examples -#' \dontrun{ -#' x <- Standardize(data = data, ColNames = c('Weekly_Sales', 'XREG1'), GroupVars = c('Region','Store','Dept'), Center = TRUE, Scale = TRUE) -#' } -#' -#' @noRd -StandardizeScoring <- function(data, ScoreTable, Apply = 'apply', GroupVars = NULL) { - - # Facts - nam <- names(ScoreTable)[which(!names(ScoreTable) %in% GroupVars)] - - # Apply will apply standardization to new data - # Backtransform will undo standardization - if(Apply == 'apply') { - data.table::setkeyv(x = data, cols = GroupVars) - data.table::setkeyv(x = ScoreTable, cols = GroupVars) - data[ScoreTable, paste0(nam) := mget(paste0('i.', nam))] - nams <- nam[seq_len(length(nam) / 2)] - ColNames <- gsub(pattern = "_mean", replacement = "", x = nams) - for(i in ColNames) data[, paste0(i, "_Standardize") := (get(i) - get(paste0(i, "_mean"))) / get(paste0(i, "_sd"))] - data.table::set(data, j = c(nam), value = NULL) - } else { - data.table::setkeyv(x = data, cols = GroupVars) - data.table::setkeyv(x = ScoreTable, cols = GroupVars) - data[ScoreTable, paste0(nam) := mget(paste0('i.', nam))] - nams <- nam[seq_len(length(nam) / 2)] - ColNames <- gsub(pattern = "_mean", replacement = "", x = nams) - for(i in ColNames) data[, eval(i) := get(paste0(i, "_Standardize")) * get(paste0(i, "_sd")) + get(paste0(i, "_mean"))] - data.table::set(data, j = c(nam), value = NULL) - } - - # Return - return(data) -} - -#' @title PercRank -#' -#' @description Generate percent ranks for multiple variables, by groups if provided, and with a selected granularity -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' -#' @param data Source data.table -#' @param ColNames Character vector of column names -#' @param GroupVars Character vector of column names to have percent ranks by the group levels -#' @param Granularity Provide a value such that data.table::frank(Variable) * (1 / Granularity) / .N * Granularity. Default is 0.001 -#' @param ScoreTable = FALSE. Set to TRUE to get the reference values for applying to new data. Pass to scoring version of this function -#' -#' @examples -#' \dontrun{ -#' data <- data.table::fread(file.choose()) -#' x <- PercRank(data, ColNames = c('Weekly_Sales', 'XREG1'), GroupVars = c('Region','Store','Dept'), Granularity = 0.001, ScoreTable = TRUE) -#' } -#' -#' @noRd -PercRank <- function(data, ColNames, GroupVars = NULL, Granularity = 0.001, ScoreTable = FALSE) { - if(length(GroupVars) == 0L) { - data[, paste0(ColNames, '_PercRank') := lapply(.SD, FUN = function(x) data.table::frank(x) * (1 / Granularity) / .N * Granularity), .SDcols = c(ColNames)] - } else { - data[, paste0(ColNames, '_PercRank') := lapply(.SD, FUN = function(x) data.table::frank(x) * (1 / Granularity) / .N * Granularity), .SDcols = c(ColNames), by = c(eval(GroupVars))] - } - if(!ScoreTable) { - return(data) - } else { - return(list( - data = data, - ScoreTable = unique(data[, .SD, .SDcols = c(ColNames, paste0(ColNames, '_PercRank'))]) - )) - } -} - -#' Test YeoJohnson Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param eps erorr tolerance -#' @param ... Arguments to pass along -#' @return YeoJohnson results -Test_YeoJohnson <- function(x, - eps = 0.001, - ...) { - stopifnot(is.numeric(x)) - lambda <- Estimate_YeoJohnson_Lambda(x, eps = eps, ...) - trans_data <- x - na_idx <- is.na(x) - trans_data[!na_idx] <- Apply_YeoJohnson(x[!na_idx], lambda, eps) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "YeoJohnson", Data = trans_data, Lambda = lambda, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Estimate YeoJohnson Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param lower the lower bound for search -#' @param upper the upper bound for search -#' @param eps erorr tolerance -#' @return YeoJohnson results -Estimate_YeoJohnson_Lambda <- function(x, - lower = -5, - upper = 5, - eps = 0.001) { - - n <- length(x) - ccID <- !is.na(x) - x <- x[ccID] - - # See references, Yeo & Johnson Biometrika (2000) - yj_loglik <- function(lambda) { - x_t <- Apply_YeoJohnson(x, lambda, eps) - x_t_bar <- mean(x_t) - x_t_var <- var(x_t) * (n - 1) / n - constant <- sum(sign(x) * log(abs(x) + 1)) - - 0.5 * n * log(x_t_var) + (lambda - 1) * constant - } - - results <- optimize( - yj_loglik, - lower = lower, - upper = upper, - maximum = TRUE, - tol = .0001) - return(results$maximum) -} - -#' Apply YeoJohnson Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param lambda optimal lambda -#' @param eps erorr tolerance -#' @return YeoJohnson results -Apply_YeoJohnson <- function(x, - lambda, - eps = 0.001) { - pos_idx <- x >= 0 - neg_idx <- x < 0 - - # Transform negative values - if(any(pos_idx)) { - if(abs(lambda) < eps) { - x[pos_idx] <- log(x[pos_idx] + 1) - } else { - x[pos_idx] <- ((x[pos_idx] + 1) ^ lambda - 1) / lambda - } - } - - # Transform nonnegative values - if(any(neg_idx)) { - if(abs(lambda - 2) < eps) { - x[neg_idx] <- -log(-x[neg_idx] + 1) - } else { - x[neg_idx] <- -((-x[neg_idx] + 1) ^ (2 - lambda) - 1) / (2 - lambda) - } - } - return(x) -} - -#' Inverse YeoJohnson Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param lambda optimal lambda -#' @param eps erorr tolerance -#' @return YeoJohnson results -InvApply_YeoJohnson <- function(x, - lambda, - eps = 0.001) { - val <- x - neg_idx <- x < 0 - if(any(!neg_idx)) { - if(abs(lambda) < eps) { - val[!neg_idx] <- exp(x[!neg_idx]) - 1 - } else { - val[!neg_idx] <- (x[!neg_idx] * lambda + 1) ^ (1 / lambda) - 1 - } - } - if(any(neg_idx)) { - if(abs(lambda - 2) < eps) { - val[neg_idx] <- -expm1(-x[neg_idx]) - } else { - val[neg_idx] <- 1 - (-(2 - lambda) * x[neg_idx] + 1) ^ (1 / (2 - lambda)) - } - } - return(val) -} - -#' Test BoxCox Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param ... Arguments to pass along -#' @return BoxCox results -Test_BoxCox <- function(x, ...) { - stopifnot(is.numeric(x)) - lambda <- Estimate_BoxCox_Lambda(x, ...) - trans_data <- Apply_BoxCox(x, lambda) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "BoxCox", Data = trans_data, Lambda = lambda, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Estimate BoxCox Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param lower the lower bound for search -#' @param upper the upper bound for search -#' @param eps erorr tolerance -#' @return BoxCox results -Estimate_BoxCox_Lambda <- function(x, - lower = -1, - upper = 2, - eps = 0.001) { - n <- length(x) - ccID <- !is.na(x) - x <- x[ccID] - if (any(x <= 0)) stop("x must be positive") - log_x <- log(x) - xbar <- exp(mean(log_x)) - fit <- lm(x ~ 1, data = data.frame(x = x)) - xqr <- fit$qr - boxcox_loglik <- function(lambda) { - if (abs(lambda) > eps) - xt <- (x ^ lambda - 1) / lambda - else - xt <- log_x * (1 + (lambda * log_x) / 2 * - (1 + (lambda * log_x) / 3 * - (1 + (lambda * log_x) / 4))) - - n / 2 * log(sum(qr.resid(xqr, xt / xbar ^ (lambda - 1)) ^ 2)) - } - - results <- optimize( - boxcox_loglik, - lower = lower, - upper = upper, - maximum = TRUE, - tol = .0001) - return(results$maximum) -} - -#' Apply BoxCox Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param lambda optimal lambda -#' @param eps erorr tolerance -#' @return BoxCox results -Apply_BoxCox <- function(x, - lambda, - eps = 0.001) { - if(lambda < 0) x[x < 0] <- NA - if(abs(lambda) < eps) { - val <- log(x) - } else { - val <- (sign(x) * abs(x) ^ lambda - 1) / lambda - } - return(val) -} - -#' Inverse BoxCox Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @param lambda optimal lambda -#' @param eps erorr tolerance -#' @return BoxCox results -InvApply_BoxCox <- function(x, - lambda, - eps = 0.001) { - if(lambda < 0) x[x > -1 / lambda] <- NA - if(abs(lambda) < eps) { - val <- exp(x) - } else { - x <- x * lambda + 1 - val <- sign(x) * abs(x) ^ (1 / lambda) - } - return(val) -} - -#' Test Asinh Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Asinh results -Test_Asinh <- function(x) { - stopifnot(is.numeric(x)) - trans_data <- asinh(x) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "Asinh", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Inverse Asinh Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Asinh results -Apply_Asinh <- function(x) { - return(asinh(x)) -} - -#' Inverse Asinh Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Asinh results -InvApply_Asinh <- function(x) { - return(sinh(x)) -} - -#' Test Asin Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Asin results -Test_Asin <- function(x) { - stopifnot(is.numeric(x)) - trans_data <- asin(sqrt(x)) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "Asin", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Inverse Asin Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Asin results -Apply_Asin <- function(x) { - return(asin(sqrt(x))) -} - -#' Inverse Asin Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Asin results -InvApply_Asin <- function(x) { - return(sin(x) ^ 2) -} - -#' Test Logit Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Logit results -Test_Logit <- function(x) { - stopifnot(is.numeric(x)) - trans_data <- log(x / (1 - x)) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "Logit", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Apply Logit Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Logit results -Apply_Logit <- function(x) { - return(log(x / (1 - x))) -} - -#' Inverse Logit Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Logit results -InvApply_Logit <- function(x) { - return(1 / (1 + exp(-x))) -} - -#' Test Identity Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Identity results -Test_Identity <- function(x) { - stopifnot(is.numeric(x)) - x.t <- x - mu <- mean(x.t, na.rm = TRUE) - sigma <- sd(x.t, na.rm = TRUE) - x.t <- (x.t - mu) / sigma - ptest <- nortest::pearson.test(x.t) - val <- list(Name = "Identity", Data = x, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Test Log Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Log results -Test_Log <- function(x) { - stopifnot(is.numeric(x)) - trans_data <- log(x) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "Log", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Apply Log Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Log results -Apply_Log <- function(x) { - return(log(x)) -} - -#' Inverse Log Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Log results -InvApply_Log <- function(x) { - return(exp(x)) -} - -#' Test LogPlus1 Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return LogPlus1 results -Test_LogPlus1 <- function(x) { - stopifnot(is.numeric(x)) - xx <- min(x, na.rm = TRUE) - if(xx <= 0) trans_data <- log(x+abs(xx)+1) else trans_data <- log(x) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "LogPlus1", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Apply LogPlus1 Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Log results -Apply_LogPlus1 <- function(x) { - return(log(x+1)) -} - -#' Inverse LogPlus1 Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Log results -InvApply_LogPlus1 <- function(x) { - return(exp(x)-1) -} - -#' Test Sqrt Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Sqrt results -Test_Sqrt <- function(x) { - stopifnot(is.numeric(x)) - trans_data <- sqrt(x) - mu <- mean(trans_data, na.rm = TRUE) - sigma <- sd(trans_data, na.rm = TRUE) - trans_data_standardized <- (trans_data - mu) / sigma - ptest <- nortest::pearson.test(trans_data_standardized) - val <- list(Name = "Sqrt", Data = trans_data, Lambda = NA, Normalized_Statistic = unname(ptest$statistic / ptest$df)) - return(val) -} - -#' Apply Sqrt Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Log results -Apply_Sqrt <- function(x) { - return(sqrt(x)) -} - -#' Inverse Sqrt Transformation -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @noRd -#' @param x The data in numerical vector form -#' @return Log results -InvApply_Sqrt <- function(x) { - return(x^2) -} - -#' @title AutoTransformationCreate -#' -#' @description AutoTransformationCreate is a function for automatically identifying the optimal transformations for numeric features and transforming them once identified. This function will loop through your selected transformation options (YeoJohnson, BoxCox, Asinh, Asin, and Logit) and find the one that produces data that is the closest to normally distributed data. It then makes the transformation and collects the metadata information for use in the AutoTransformationScore() function, either by returning the objects (always) or saving them to file (optional). -#' -#' @author Adrian Antico -#' @family Feature Engineering -#' @param data This is your source data -#' @param ColumnNames List your columns names in a vector, for example, c("Target", "IV1") -#' @param Methods Choose from "YeoJohnson", "BoxCox", "Asinh", "Log", "LogPlus1", "Asin", "Logit", and "Identity". Note, LogPlus1 runs -#' @param Path Set to the directly where you want to save all of your modeling files -#' @param TransID Set to a character value that corresponds with your modeling project -#' @param SaveOutput Set to TRUE to save necessary file to run AutoTransformationScore() -#' @return data with transformed columns and the transformation object for back-transforming later -#' @examples -#' \dontrun{ -#' # Create Fake Data -#' data <- AutoQuant::FakeDataGenerator( -#' Correlation = 0.85, -#' N = 25000, -#' ID = 2L, -#' ZIP = 0, -#' FactorCount = 2L, -#' AddDate = FALSE, -#' Classification = FALSE, -#' MultiClass = FALSE) -#' -#' # Columns to transform -#' Cols <- names(data)[1L:11L] -#' print(Cols) -#' -#' # Run function -#' data <- AutoQuant::AutoTransformationCreate( -#' data, -#' ColumnNames = Cols, -#' Methods = c("YeoJohnson", "BoxCox", "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "Identity"), -#' Path = getwd(), -#' TransID = "Trans", -#' SaveOutput = TRUE) -#' } -#' @noRd -AutoTransformationCreate <- function(data, - ColumnNames = NULL, - Methods = c("BoxCox","YeoJohnson","Asinh","Log","LogPlus1","Sqrt","Asin","Logit","Identity"), - Path = NULL, - TransID = "ModelID", - SaveOutput = FALSE) { - - # Check arguments - Methods <- unique(tolower(Methods)) - if(!data.table::is.data.table(data)) data.table::setDT(data) - if(!any(tolower(Methods) %chin% c("boxcox", "yeojohnson", "asinh", "sqrt", "log", "logplus1", "asin", "logit"))) stop("Methods not supported") - # if(!"identity" %chin% Methods) Methods <- c(Methods, "identity") - if(is.numeric(ColumnNames) || is.integer(ColumnNames)) ColumnNames <- names(data)[ColumnNames] - for(i in ColumnNames) if(!(any(class(data[[eval(i)]]) %chin% c("numeric", "integer")))) stop("ColumnNames must be for numeric or integer columns") - - # Loop through ColumnNames - # colNames = 1 - for(colNames in seq_along(ColumnNames)) {# colNames = 1L - - # Collection Object - if(length(Methods) < 5) { - EvaluationTable <- data.table::data.table( - ColumnName = rep("BLABLA", length(ColumnNames) * (length(Methods)+1)), - MethodName = rep("BLABLA", length(ColumnNames) * (length(Methods)+1)), - Lambda = rep(1.0, length(ColumnNames) * (length(Methods)+1)), - NormalizedStatistics = rep(1.0, length(ColumnNames) * (length(Methods)+1))) - } else { - EvaluationTable <- data.table::data.table( - ColumnName = rep("BLABLA", length(ColumnNames) * (length(Methods) + 1)), - MethodName = rep("BLABLA", length(ColumnNames) * (length(Methods) + 1)), - Lambda = rep(1.0, length(ColumnNames) * (length(Methods) + 1)), - NormalizedStatistics = rep(1.0, length(ColumnNames) * (length(Methods) + 1))) - } - DataCollection <- list() - Counter <- 0L - - # Check range of data - MinVal <- min(data[[eval(ColumnNames[colNames])]], na.rm = TRUE) - MaxVal <- max(data[[eval(ColumnNames[colNames])]], na.rm = TRUE) - - # Create Final Methods Object - FinalMethods <- Methods - - # Update Methods - if(MinVal <= 0) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("boxcox","log","logit"))] - if(MinVal < 0) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("sqrt","asin"))] - if(MaxVal > 1) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("asin"))] - if(MaxVal >= 1) FinalMethods <- FinalMethods[!(tolower(FinalMethods) %chin% c("logit"))] - - # Store column data as vector - x <- data[[eval(ColumnNames[colNames])]] - - # YeoJohnson - if(any(tolower(FinalMethods) %chin% "yeojohnson")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_YeoJohnson(x) - DataCollection[["yeojohnson"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # Log - if(any(tolower(FinalMethods) %chin% "log")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_Log(x) - DataCollection[["log"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = NA) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # LogPlus1 - if(any(tolower(FinalMethods) %chin% "logplus1")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- AutoPlots:::Test_LogPlus1(x) - DataCollection[["logplus1"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = NA) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # Sqrt - if(any(tolower(FinalMethods) %chin% "sqrt")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_Sqrt(x) - DataCollection[["sqrt"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = NA) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # BoxCox - if(any(tolower(FinalMethods) %chin% "boxcox")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_BoxCox(x) - DataCollection[["boxcox"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # Asinh - if(any(tolower(FinalMethods) %chin% "asinh")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_Asinh(x) - DataCollection[["asinh"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # Asin - if(any(tolower(FinalMethods) %chin% "asin")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_Asin(x) - DataCollection[["asin"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # Logit - if(any(tolower(FinalMethods) %chin% "logit")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_Logit(x) - DataCollection[["logit"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # Identity - if(any(tolower(FinalMethods) %chin% "identity")) { - Counter <- Counter + 1L - data.table::set(EvaluationTable, i = Counter, j = "ColumnName", value = eval(ColumnNames[colNames])) - output <- Test_Identity(x) - DataCollection[["identity"]] <- output$Data - data.table::set(EvaluationTable, i = Counter, j = "MethodName", value = output$Name) - data.table::set(EvaluationTable, i = Counter, j = "Lambda", value = output$Lambda) - data.table::set(EvaluationTable, i = Counter, j = "NormalizedStatistics", value = output$Normalized_Statistic) - } - - # Pick winner - EvaluationTable <- EvaluationTable[MethodName != "BLABLA"] - if(colNames == 1L) { - Results <- EvaluationTable[order(NormalizedStatistics)][1L] - } else { - Results <- data.table::rbindlist(list(Results, EvaluationTable[order(NormalizedStatistics)][1L])) - } - - # Apply to data---- - data <- tryCatch({data[, ColumnNames[colNames] := DataCollection[[tolower(Results[eval(colNames), MethodName])]]]}, error = function(x) data) - } - - # Save output---- - if(SaveOutput && !is.null(Path)) data.table::fwrite(Results, file = file.path(normalizePath(Path), paste0(TransID, "_transformation.csv"))) - - # Return data---- - return(list(Data = data, FinalResults = Results)) -} - -# ---- - -# ---- - # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ---- # > Automated Plot Functions ---- # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ---- @@ -1376,6 +43,8 @@ AutoTransformationCreate <- function(data, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param NumberBins For histograms +#' @param NumLevels_Y Numeric +#' @param NumLevels_X Numeric #' @param Height NULL or valid css unit #' @param Width NULL or valid css unit #' @param EchartsTheme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" @@ -1388,7 +57,7 @@ AutoTransformationCreate <- function(data, #' @param TextColor character #' @param FontSize numeric #' @param Debug Debugging purposes -#' +#' @return plot #' @export Plot.StandardPlots <- function(dt = NULL, PreAgg = FALSE, @@ -1434,7 +103,7 @@ Plot.StandardPlots <- function(dt = NULL, # Pie Plot if(tolower(PlotType) == 'pieplot') { - p1 <- AutoPlots:::Plot.Pie( + p1 <- Plot.Pie( dt = dt, PreAgg = PreAgg, AggMethod = AggMethod, @@ -1462,32 +131,32 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Pie(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::ExpandText(if(length(XVar) == 0 && length(GroupVar) > 0L) GroupVar[1L] else XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", ExpandText(if(length(XVar) == 0 && length(GroupVar) > 0L) GroupVar[1L] else XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Donut Plot if(tolower(PlotType) == 'donutplot') { - p1 <- AutoPlots:::Plot.Donut( + p1 <- Plot.Donut( dt = dt, PreAgg = PreAgg, AggMethod = AggMethod, @@ -1515,32 +184,32 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Donut(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::ExpandText(if(length(XVar) == 0 && length(GroupVar) > 0L) GroupVar[1L] else XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", ExpandText(if(length(XVar) == 0 && length(GroupVar) > 0L) GroupVar[1L] else XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Rosetype Plot if(tolower(PlotType) == 'rosetypeplot') { - p1 <- AutoPlots:::Plot.Rosetype( + p1 <- Plot.Rosetype( dt = dt, PreAgg = PreAgg, AggMethod = AggMethod, @@ -1568,32 +237,32 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Rosetype(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::ExpandText(if(length(XVar) == 0 && length(GroupVar) > 0L) GroupVar[1L] else XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", ExpandText(if(length(XVar) == 0 && length(GroupVar) > 0L) GroupVar[1L] else XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Box Plot if(tolower(PlotType) == 'boxplot') { - p1 <- AutoPlots:::Plot.Box( + p1 <- Plot.Box( dt = dt, SampleSize = SampleSize, XVar = XVar, @@ -1621,32 +290,32 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Box(", "\n ", "dt = data1", ",\n ", - "SampleSize = ", AutoPlots:::CEPP(SampleSize), ",\n ", - "XVar = ", AutoPlots:::ExpandText(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "SampleSize = ", CEPP(SampleSize), ",\n ", + "XVar = ", ExpandText(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Histogram Plot if(tolower(PlotType) == 'histogramplot') { - p1 <- AutoPlots:::Plot.Histogram( + p1 <- Plot.Histogram( dt = dt, SampleSize = SampleSize, XVar = XVar, @@ -1675,33 +344,33 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Histogram(", "\n ", "dt = data1", ",\n ", - "SampleSize = ", AutoPlots:::CEPP(SampleSize), ",\n ", - "XVar = ", AutoPlots:::ExpandText(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "NumberBins = ", AutoPlots:::CEPP(NumberBins), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "SampleSize = ", CEPP(SampleSize), ",\n ", + "XVar = ", ExpandText(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "NumberBins = ", CEPP(NumberBins), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Density Plot if(tolower(PlotType) == 'densityplot') { - p1 <- AutoPlots:::Plot.Density( + p1 <- Plot.Density( dt = dt, SampleSize = SampleSize, GroupVar=GroupVar, @@ -1729,25 +398,25 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Density(", "\n ", "dt = data1", ",\n ", - "SampleSize = ", AutoPlots:::CEPP(SampleSize), ",\n ", - "XVar = ", AutoPlots:::ExpandText(XVar), ",\n ", - "YVar = ", AutoPlots:::CEP(if(length(YVar) > 0L) YVar else XVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "SampleSize = ", CEPP(SampleSize), ",\n ", + "XVar = ", ExpandText(XVar), ",\n ", + "YVar = ", CEP(if(length(YVar) > 0L) YVar else XVar), ",\n ", + "GroupVar = ", CEP(GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -1785,28 +454,28 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Line(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(GroupVar),",\n ", - "DualYVar = ", AutoPlots:::ExpandText(DualYVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "DualYVarTrans = ", AutoPlots:::CEP(DualYVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(GroupVar),",\n ", + "DualYVar = ", ExpandText(DualYVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "DualYVarTrans = ", CEP(DualYVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -1844,28 +513,28 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Area(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(GroupVar),",\n ", - "DualYVar = ", AutoPlots:::ExpandText(DualYVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "DualYVarTrans = ", AutoPlots:::CEP(DualYVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(GroupVar),",\n ", + "DualYVar = ", ExpandText(DualYVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "DualYVarTrans = ", CEP(DualYVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -1903,28 +572,28 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Step(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(GroupVar),",\n ", - "DualYVar = ", AutoPlots:::ExpandText(DualYVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "DualYVarTrans = ", AutoPlots:::CEP(DualYVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(GroupVar),",\n ", + "DualYVar = ", ExpandText(DualYVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "DualYVarTrans = ", CEP(DualYVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -1961,33 +630,33 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.River(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(GroupVar),",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(GroupVar),",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Polar Plot if(tolower(PlotType) == 'polarplot') { - p1 <- AutoPlots:::Plot.Polar( + p1 <- Plot.Polar( dt = dt, PreAgg = PreAgg, AggMethod = AggMethod, @@ -2014,32 +683,32 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Polar(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Bar Plot if(tolower(PlotType) == 'barplot') { - p1 <- AutoPlots:::Plot.Bar( + p1 <- Plot.Bar( dt = dt, PreAgg = PreAgg, AggMethod = AggMethod, @@ -2068,26 +737,26 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Bar(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") print("AutoP 2") @@ -2096,7 +765,7 @@ Plot.StandardPlots <- function(dt = NULL, # Stacked Bar Plot if(tolower(PlotType) == 'stackedbarplot') { - p1 <- AutoPlots:::Plot.StackedBar( + p1 <- Plot.StackedBar( dt = dt, PreAgg = PreAgg, AggMethod = AggMethod, @@ -2125,26 +794,26 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.StackedBar(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -2183,30 +852,30 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.BarPlot3D(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "ZVar = ", AutoPlots:::CEP(ZVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "ZVarTrans = ", AutoPlots:::CEP(ZVarTrans), ",\n ", - "NumberBins = ", AutoPlots:::CEPP(21), ",\n ", - "NumLevels_X = ", AutoPlots:::CEPP(NumLevels_Y), ",\n ", - "NumLevels_Y = ", AutoPlots:::CEPP(NumLevels_X), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "ZVar = ", CEP(ZVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "ZVarTrans = ", CEP(ZVarTrans), ",\n ", + "NumberBins = ", CEPP(21), ",\n ", + "NumLevels_X = ", CEPP(NumLevels_Y), ",\n ", + "NumLevels_Y = ", CEPP(NumLevels_X), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -2244,37 +913,37 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.HeatMap(", "\n ", "dt = data1", ",\n ", - "AggMethod = ", AutoPlots:::CEP(AggMethod), ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "ZVar = ", AutoPlots:::CEP(ZVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "ZVarTrans = ", AutoPlots:::CEP(ZVarTrans), ",\n ", - "NumberBins = ", AutoPlots:::CEPP(21), ",\n ", - "NumLevels_X = ", AutoPlots:::CEPP(NumLevels_Y), ",\n ", - "NumLevels_Y = ", AutoPlots:::CEPP(NumLevels_X), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "AggMethod = ", CEP(AggMethod), ",\n ", + "PreAgg = ", CEPP(PreAgg), "\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "ZVar = ", CEP(ZVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "ZVarTrans = ", CEP(ZVarTrans), ",\n ", + "NumberBins = ", CEPP(21), ",\n ", + "NumLevels_X = ", CEPP(NumLevels_Y), ",\n ", + "NumLevels_Y = ", CEPP(NumLevels_X), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Correlation Matrix Plot if(tolower(PlotType) == 'correlogramplot') { - p1 <- AutoPlots:::Plot.CorrMatrix( + p1 <- Plot.CorrMatrix( dt = dt, PreAgg = PreAgg, CorrVars = YVar, @@ -2297,20 +966,20 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.CorrMatrix(", "\n ", "dt = data1", ",\n ", - "PreAgg = ", AutoPlots:::CEPP(PreAgg), "\n ", - "CorrVars = ", AutoPlots:::ExpandText(YVar), ",\n ", - "Method = ", AutoPlots:::CEP(spearman), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "PreAgg = ", CEPP(PreAgg), "\n ", + "CorrVars = ", ExpandText(YVar), ",\n ", + "Method = ", CEP(spearman), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -2318,7 +987,7 @@ Plot.StandardPlots <- function(dt = NULL, # Scatter Plot if(tolower(PlotType) %in% 'scatterplot') { if(SampleSize > 30000) SampleSize <- 30000 - p1 <- AutoPlots:::Plot.Scatter( + p1 <- Plot.Scatter( dt = dt, SampleSize = SampleSize, XVar = XVar, @@ -2346,25 +1015,25 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Scatter(", "\n ", "dt = data1", ",\n ", - "SampleSize = ", AutoPlots:::CEP(SampleSize), ",\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "SampleSize = ", CEP(SampleSize), ",\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -2372,7 +1041,7 @@ Plot.StandardPlots <- function(dt = NULL, # Copula Plot if(tolower(PlotType) %in% 'copulaplot') { if(SampleSize > 30000) SampleSize <- 30000 - p1 <- AutoPlots:::Plot.Copula( + p1 <- Plot.Copula( dt = dt, SampleSize = SampleSize, XVar = XVar, @@ -2400,32 +1069,32 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Copula(", "\n ", "dt = data1", ",\n ", - "SampleSize = ", AutoPlots:::CEP(SampleSize), ",\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::ExpandText(YVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "SampleSize = ", CEP(SampleSize), ",\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", ExpandText(YVar), ",\n ", + "GroupVar = ", CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Scatter3D Plot if(tolower(PlotType) %in% c('scatterplot3d','scatterplotd')) { - p1 <- AutoPlots:::Plot.Scatter3D( + p1 <- Plot.Scatter3D( dt = dt, SampleSize = SampleSize, XVar = XVar, @@ -2454,34 +1123,34 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Scatter3D(", "\n ", "dt = data1", ",\n ", - "SampleSize = ", AutoPlots:::CEP(SampleSize), ",\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::CEP(YVar), ",\n ", - "ZVar = ", AutoPlots:::CEP(ZVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "ZVarTrans = ", AutoPlots:::CEP(ZVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "SampleSize = ", CEP(SampleSize), ",\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", CEP(YVar), ",\n ", + "ZVar = ", CEP(ZVar), ",\n ", + "GroupVar = ", CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "ZVarTrans = ", CEP(ZVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } # Copula3D Plot if(tolower(PlotType) %in% c('copulaplot3d','copulaplotd')) { - p1 <- AutoPlots:::Plot.Copula3D( + p1 <- Plot.Copula3D( dt = dt, SampleSize = SampleSize, XVar = XVar, @@ -2510,27 +1179,27 @@ Plot.StandardPlots <- function(dt = NULL, "\n\n", "p1 <- AutoPlots::Plot.Copula3D(", "\n ", "dt = data1", ",\n ", - "SampleSize = ", AutoPlots:::CEP(SampleSize), ",\n ", - "XVar = ", AutoPlots:::CEP(XVar), ",\n ", - "YVar = ", AutoPlots:::CEP(YVar), ",\n ", - "ZVar = ", AutoPlots:::CEP(ZVar), ",\n ", - "GroupVar = ", AutoPlots:::CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", - "YVarTrans = ", AutoPlots:::CEP(YVarTrans), ",\n ", - "XVarTrans = ", AutoPlots:::CEP(XVarTrans), ",\n ", - "ZVarTrans = ", AutoPlots:::CEP(ZVarTrans), ",\n ", - "FacetRows = ", AutoPlots:::CEPP(FacetRows), ",\n ", - "FacetCols = ", AutoPlots:::CEPP(FacetCols), ",\n ", - "FacetLevels = ", AutoPlots:::ExpandText(FacetLevels), ",\n ", - "Width = ", AutoPlots:::CEP(Width), ",\n ", - "Height = ", AutoPlots:::CEP(Height), ",\n ", - "Title = ", AutoPlots:::CEP(Title), ",\n ", - "ShowLabels = ", AutoPlots:::CEPP(ShowLabels), ",\n ", - "Title.YAxis = ", AutoPlots:::CEP(Title.YAxis), ",\n ", - "Title.XAxis = ", AutoPlots:::CEP(Title.XAxis), ",\n ", - "EchartsTheme = ", AutoPlots:::CEP(EchartsTheme), ",\n ", - "TimeLine = ", AutoPlots:::CEPP(TimeLine), ",\n ", - "TextColor = ", AutoPlots:::CEP(TextColor), ",\n ", - "title.fontSize = ", AutoPlots:::CEPP(Title.FontSize), ")\n") + "SampleSize = ", CEP(SampleSize), ",\n ", + "XVar = ", CEP(XVar), ",\n ", + "YVar = ", CEP(YVar), ",\n ", + "ZVar = ", CEP(ZVar), ",\n ", + "GroupVar = ", CEP(if(all(XVar == GroupVar)) NULL else GroupVar), ",\n ", + "YVarTrans = ", CEP(YVarTrans), ",\n ", + "XVarTrans = ", CEP(XVarTrans), ",\n ", + "ZVarTrans = ", CEP(ZVarTrans), ",\n ", + "FacetRows = ", CEPP(FacetRows), ",\n ", + "FacetCols = ", CEPP(FacetCols), ",\n ", + "FacetLevels = ", ExpandText(FacetLevels), ",\n ", + "Width = ", CEP(Width), ",\n ", + "Height = ", CEP(Height), ",\n ", + "Title = ", CEP(Title), ",\n ", + "ShowLabels = ", CEPP(ShowLabels), ",\n ", + "Title.YAxis = ", CEP(Title.YAxis), ",\n ", + "Title.XAxis = ", CEP(Title.XAxis), ",\n ", + "EchartsTheme = ", CEP(EchartsTheme), ",\n ", + "TimeLine = ", CEPP(TimeLine), ",\n ", + "TextColor = ", CEP(TextColor), ",\n ", + "title.fontSize = ", CEPP(Title.FontSize), ")\n") return(list(Plot = p1, Code = Code)) } @@ -2562,11 +1231,18 @@ Plot.StandardPlots <- function(dt = NULL, #' @param NumLevels_Y = 75 #' @param NumLevels_X = 40 #' @param MouseScroll logical, zoom via mouse scroll -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" +#' @param TargetLevel character +#' @param Title character +#' @param ShowLabels logical +#' @param Title.YAxis character +#' @param Title.XAxis character +#' @param FontSize numeric #' @param TextColor hex #' @param NumberBins numeric #' @param Debug Debugging purposes +#' @return plot #' @export Plots.ModelEvaluation <- function(dt = NULL, AggMethod = "mean", @@ -2996,12 +1672,11 @@ Plots.ModelEvaluation <- function(dt = NULL, #' @param SampleSize An integer for the number of rows to use. Sampled data is randomized. If NULL then ignored #' @param YVar Y-Axis variable name #' @param YVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title 'Violin Plot' #' @param ShowLabels character -#' @param EchartsTheme = "macaron" -#' @param TimeLine Logical +#' @param EchartsTheme "macaron" #' @param TextColor 'darkblue' #' @param title.fontSize Default 22 #' @param title.fontWeight Default "bold" @@ -3045,7 +1720,7 @@ Plots.ModelEvaluation <- function(dt = NULL, #' tooltip.trigger = "axis", #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.ProbabilityPlot <- function(dt = NULL, SampleSize = 1000L, @@ -3149,12 +1824,12 @@ Plot.ProbabilityPlot <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param NumberBins = 30 -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param EchartsTheme = EchartsTheme, #' @param TimeLine logical +#' @param Title character #' @param MouseScroll logical, zoom via mouse scroll -#' @param BackGroundColor color outside of plot window. Rcolors and hex outside of plot window. Rcolors and hex character #' @param ShowLabels FALSE #' @param Title.YAxis NULL #' @param Title.XAxis NULL @@ -3208,7 +1883,7 @@ Plot.ProbabilityPlot <- function(dt = NULL, #' yaxis.fontSize = 14, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Histogram <- function(dt = NULL, SampleSize = 30000L, @@ -3420,8 +2095,8 @@ Plot.Histogram <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param MouseScroll logical, zoom via mouse scroll #' @param Title = "Density Plot" #' @param ShowLabels character @@ -3481,7 +2156,7 @@ Plot.Histogram <- function(dt = NULL, #' yaxis.fontSize = 14, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Density <- function(dt = NULL, SampleSize = 100000L, @@ -3773,8 +2448,8 @@ Plot.Density <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param AggMethod Choose from 'mean', 'sum', 'sd', and 'median' -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param ShowLabels character #' @param Title.YAxis character @@ -3783,7 +2458,6 @@ Plot.Density <- function(dt = NULL, #' @param TimeLine logical #' @param TextColor 'darkblue' #' @param title.fontSize Defaults to size 22. Numeric. This changes the size of the title. -#' @param BackGroundColor color outside of plot window. Rcolors and hex outside of plot window. Rcolors and hex character #' @param title.fontSize 22 #' @param title.fontWeight "bold" #' @param title.textShadowColor '#63aeff' @@ -3832,6 +2506,7 @@ Plot.Density <- function(dt = NULL, #' yaxis.fontSize = 14, #' Debug = FALSE) #' } +#' @return plot #' @export Plot.Pie <- function(dt = NULL, PreAgg = FALSE, @@ -3873,7 +2548,7 @@ Plot.Pie <- function(dt = NULL, if(!data.table::is.data.table(dt)) tryCatch({data.table::setDT(dt)}, error = function(x) { dt <- data.table::as.data.table(dt) }) - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) } # Convert factor to character @@ -3926,8 +2601,8 @@ Plot.Pie <- function(dt = NULL, if(Debug) print("BarPlot 2.bb") temp <- data.table::copy(dt) if(Debug) print("BarPlot 2.bbb") - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } # yvar <- temp[[YVar]] @@ -3937,7 +2612,7 @@ Plot.Pie <- function(dt = NULL, # Transformation if(YVarTrans != "Identity") { - temp <- AutoPlots:::AutoTransformationCreate(data = temp, ColumnNames = numvars, Methods = YVarTrans)$Data + temp <- AutoTransformationCreate(data = temp, ColumnNames = numvars, Methods = YVarTrans)$Data } p1 <- echarts4r::e_charts_( @@ -3997,8 +2672,8 @@ Plot.Pie <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param AggMethod Choose from 'mean', 'sum', 'sd', and 'median' -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param ShowLabels character #' @param Title.YAxis character @@ -4054,7 +2729,7 @@ Plot.Pie <- function(dt = NULL, #' yaxis.fontSize = 14, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Donut <- function(dt = NULL, PreAgg = FALSE, @@ -4096,7 +2771,7 @@ Plot.Donut <- function(dt = NULL, if(!data.table::is.data.table(dt)) tryCatch({data.table::setDT(dt)}, error = function(x) { dt <- data.table::as.data.table(dt) }) - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) } # Convert factor to character @@ -4147,8 +2822,8 @@ Plot.Donut <- function(dt = NULL, } } else { temp <- data.table::copy(dt) - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } yvar <- temp[[YVar]] @@ -4216,8 +2891,8 @@ Plot.Donut <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param AggMethod Choose from 'mean', 'sum', 'sd', and 'median' -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param ShowLabels character #' @param Title.YAxis character @@ -4273,7 +2948,7 @@ Plot.Donut <- function(dt = NULL, #' yaxis.fontSize = 14, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Rosetype <- function(dt = NULL, PreAgg = FALSE, @@ -4315,7 +2990,7 @@ Plot.Rosetype <- function(dt = NULL, if(!data.table::is.data.table(dt)) tryCatch({data.table::setDT(dt)}, error = function(x) { dt <- data.table::as.data.table(dt) }) - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) } # Convert factor to character @@ -4366,8 +3041,8 @@ Plot.Rosetype <- function(dt = NULL, } } else { temp <- data.table::copy(dt) - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } yvar <- temp[[YVar]] @@ -4434,8 +3109,8 @@ Plot.Rosetype <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -4497,7 +3172,7 @@ Plot.Rosetype <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Box <- function(dt = NULL, SampleSize = 100000L, @@ -5131,8 +3806,8 @@ Plot.Box <- function(dt = NULL, #' #' @param dt source data.table #' @param YVar Y-Axis variable name -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title = "Density Plot" #' @param EchartsTheme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" #' @param TextColor "white", @@ -5153,7 +3828,7 @@ Plot.Box <- function(dt = NULL, #' \dontrun{ #' #' # Create fake data -#' dt <- AutoPlots::FakeDataGenerator(AddComment = TRUE) +#' dt <- FakeDataGenerator(AddComment = TRUE) #' #' # Create plot #' AutoPlots::Plot.WordCloud( @@ -5177,7 +3852,7 @@ Plot.Box <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.WordCloud <- function(dt = NULL, YVar = NULL, @@ -5349,13 +4024,12 @@ Plot.WordCloud <- function(dt = NULL, #' @param YVar Y-Axis variable name. You can supply multiple YVars #' @param GroupVar One Grouping Variable #' @param YVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title "Title" #' @param ShowLabels character #' @param EchartsTheme Provide an "Echarts" theme #' @param ShowSymbol = FALSE -#' @param BackGroundColor color outside of plot window. Rcolors and hex #' @param TextColor "Not Implemented" #' @param title.fontSize 22 #' @param title.fontWeight "bold" @@ -5398,7 +4072,7 @@ Plot.WordCloud <- function(dt = NULL, #' DarkMode = FALSE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Radar <- function(dt = NULL, AggMethod = "mean", @@ -5443,7 +4117,7 @@ Plot.Radar <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.Radar # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) # Aggregate data dt1 <- dt1[, lapply(.SD, noquote(aggFunc)), by = c(GroupVar[1L])] @@ -5452,7 +4126,7 @@ Plot.Radar <- function(dt = NULL, # Transformation if(YVarTrans != "Identity") { for(yvar in YVar) { - dt1 <- AutoPlots:::AutoTransformationCreate(data = dt1, ColumnNames = yvar, Methods = YVarTrans)$Data + dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = yvar, Methods = YVarTrans)$Data } } @@ -5520,11 +4194,12 @@ Plot.Radar <- function(dt = NULL, #' @param GroupVar One Grouping Variable #' @param YVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" #' @param XVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" +#' @param DualYVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height NULL +#' @param Width NULL #' @param Title "Title" #' @param ShowLabels character #' @param Title.YAxis character @@ -5536,7 +4211,6 @@ Plot.Radar <- function(dt = NULL, #' @param Alpha 0 to 1 for setting transparency #' @param Smooth = TRUE #' @param ShowSymbol = FALSE -#' @param BackGroundColor color outside of plot window. Rcolors and hex #' @param TextColor "Not Implemented" #' @param title.fontSize 22 #' @param title.fontWeight "bold" @@ -5570,7 +4244,7 @@ Plot.Radar <- function(dt = NULL, #' GroupVar = NULL, #' EchartsTheme = "macarons") #' } -#' +#' @return plot #' @export Plot.Line <- function(dt = NULL, AggMethod = "mean", @@ -5670,7 +4344,7 @@ Plot.Line <- function(dt = NULL, # Define Aggregation function if(Debug) print("Line # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) # Aggregate data if(length(GroupVar) > 0L) { @@ -5684,10 +4358,10 @@ Plot.Line <- function(dt = NULL, # Transformation if(YVarTrans != "Identity") { - dt1 <- AutoPlots:::AutoTransformationCreate(data = dt1, ColumnNames = YVar, Methods = YVarTrans)$Data + dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = YVar, Methods = YVarTrans)$Data } if(length(DualYVar > 0L) && DualYVarTrans != "Identity") { - dt1 <- AutoPlots:::AutoTransformationCreate(data = dt1, ColumnNames = DualYVar, Methods = DualYVarTrans)$Data + dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = DualYVar, Methods = DualYVarTrans)$Data } # Group Variable Case @@ -5985,8 +4659,8 @@ Plot.Line <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title "Title" #' @param ShowLabels character #' @param Title.YAxis character @@ -6030,7 +4704,7 @@ Plot.Line <- function(dt = NULL, #' GroupVar = NULL, #' EchartsTheme = "macarons") #' } -#' +#' @return plot #' @export Plot.Area <- function(dt = NULL, AggMethod = "mean", @@ -6128,7 +4802,7 @@ Plot.Area <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.Calibration.Line # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) # Aggregate data if(length(GroupVar) > 0L) { @@ -6145,7 +4819,7 @@ Plot.Area <- function(dt = NULL, dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = YVar, Methods = YVarTrans)$Data } if(length(DualYVar > 0L) && DualYVarTrans != "Identity") { - dt1 <- AutoPlots:::AutoTransformationCreate(data = dt1, ColumnNames = DualYVar, Methods = DualYVarTrans)$Data + dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = DualYVar, Methods = DualYVarTrans)$Data } # Group Variable Case @@ -6440,8 +5114,8 @@ Plot.Area <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title "Title" #' @param ShowLabels character #' @param Title.YAxis character @@ -6482,7 +5156,7 @@ Plot.Area <- function(dt = NULL, #' GroupVar = NULL, #' EchartsTheme = "macarons") #' } -#' +#' @return plot #' @export Plot.Step <- function(dt = NULL, AggMethod = "mean", @@ -6578,7 +5252,7 @@ Plot.Step <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.Calibration.Line # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) # Aggregate data if(length(GroupVar) > 0L) { @@ -6595,7 +5269,7 @@ Plot.Step <- function(dt = NULL, dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = YVar, Methods = YVarTrans)$Data } if(length(DualYVar > 0L) && DualYVarTrans != "Identity") { - dt1 <- AutoPlots:::AutoTransformationCreate(data = dt1, ColumnNames = DualYVar, Methods = DualYVarTrans)$Data + dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = DualYVar, Methods = DualYVarTrans)$Data } # Group Variable Case @@ -6889,8 +5563,8 @@ Plot.Step <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title "Title" #' @param ShowLabels character #' @param Title.YAxis character @@ -6899,12 +5573,6 @@ Plot.Step <- function(dt = NULL, #' @param TimeLine Logical #' @param MouseScroll logical, zoom via mouse scroll #' @param ShowSymbol = FALSE -#' @param ZeroLineColor color -#' @param ZeroLineWidth 1 -#' @param BackGroundColor color outside of plot window. Rcolors and hex -#' @param ChartColor color -#' @param FillColor color -#' @param FillColorReverse character #' @param TextColor "Not Implemented" #' @param title.fontSize 22 #' @param title.fontWeight "bold" @@ -6914,9 +5582,6 @@ Plot.Step <- function(dt = NULL, #' @param title.textShadowOffsetX -1 #' @param xaxis.fontSize 14 #' @param yaxis.fontSize 14 -#' @param xaxis.rotate 0 -#' @param yaxis.rotate 0 -#' @param ContainLabel TRUE #' @param Debug Debugging purposes #' #' @examples @@ -6940,7 +5605,7 @@ Plot.Step <- function(dt = NULL, #' TextColor = "black", #' EchartsTheme = "macarons") #' } -#' +#' @return plot #' @export Plot.River <- function(dt = NULL, AggMethod = "mean", @@ -7010,7 +5675,7 @@ Plot.River <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.Calibration.Line # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) # Aggregate data if(length(GroupVar) > 0L) { @@ -7105,8 +5770,8 @@ Plot.River <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param AggMethod Choose from 'mean', 'sum', 'sd', and 'median' -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param Title.YAxis NULL. If NULL, YVar name will be used #' @param Title.XAxis NULL. If NULL, XVar name will be used @@ -7170,7 +5835,7 @@ Plot.River <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Bar <- function(dt = NULL, PreAgg = FALSE, @@ -7231,7 +5896,7 @@ Plot.Bar <- function(dt = NULL, # Define Aggregation function if(!PreAgg) { - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) } # Create base plot object @@ -7284,8 +5949,8 @@ Plot.Bar <- function(dt = NULL, } } else { temp <- data.table::copy(dt) - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } # Transformation @@ -7455,8 +6120,8 @@ Plot.Bar <- function(dt = NULL, } else { temp <- data.table::copy(dt) if(Debug) print("BarPlot 2.bb") - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } if(Debug) print("BarPlot 2.bbb") @@ -7652,8 +6317,8 @@ Plot.Bar <- function(dt = NULL, } } else { temp <- data.table::copy(dt) - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } # Transformation @@ -7805,8 +6470,8 @@ Plot.Bar <- function(dt = NULL, } } else { temp <- data.table::copy(dt) - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } # Transformation @@ -7948,17 +6613,16 @@ Plot.Bar <- function(dt = NULL, #' @author Adrian Antico #' #' @param dt source data.table -#' @param PreAgg logical #' @param YVar Y-Axis variable name #' @param DateVar Date column in data #' @param TimeUnit Select from "hour", "day", "week", "month", "quarter", "year" +#' @param MaxLags Max lag values to test #' @param YVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" #' @param AggMethod Choose from 'mean', 'sum', 'sd', and 'median' -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param EchartsTheme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" -#' @param TimeLine logical #' @param TextColor 'darkblue' #' @param title.fontSize 22 #' @param title.fontWeight "bold" @@ -7972,6 +6636,7 @@ Plot.Bar <- function(dt = NULL, #' @param yaxis.rotate 0 #' @param ContainLabel TRUE #' @param Debug Debugging purposes +#' @return plot #' @export Plot.ACF <- function(dt = NULL, YVar = NULL, @@ -8011,13 +6676,13 @@ Plot.ACF <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.ACH 1") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) if(Debug) print("Plot.ACH 2") # Transformation if(YVarTrans != "Identity") { - dt1 <- AutoPlots:::AutoTransformationCreate(data = dt1, ColumnNames = YVar, Methods = YVarTrans)$Data + dt1 <- AutoTransformationCreate(data = dt1, ColumnNames = YVar, Methods = YVarTrans)$Data } if(Debug) print("Plot.ACH 3") @@ -8027,7 +6692,7 @@ Plot.ACF <- function(dt = NULL, if(Debug) print("Plot.ACH 3.5") - dt1 <- Rodeo::AutoLagRollStats( + dt1 <- AutoLagRollStats( data = dt1, DateColumn = DateVar, Targets = YVar, @@ -8142,17 +6807,16 @@ Plot.ACF <- function(dt = NULL, #' @author Adrian Antico #' #' @param dt source data.table -#' @param PreAgg logical #' @param YVar Y-Axis variable name #' @param DateVar Date column in data +#' @param MaxLags Max value for lags to test #' @param TimeUnit Select from "hour", "day", "week", "month", "quarter", "year" #' @param YVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" #' @param AggMethod Choose from 'mean', 'sum', 'sd', and 'median' -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param EchartsTheme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" -#' @param TimeLine logical #' @param TextColor 'darkblue' #' @param title.fontSize 22 #' @param title.fontWeight "bold" @@ -8166,6 +6830,7 @@ Plot.ACF <- function(dt = NULL, #' @param yaxis.rotate 0 #' @param ContainLabel TRUE #' @param Debug Debugging purposes +#' @return plot #' @export Plot.PACF <- function(dt = NULL, YVar = NULL, @@ -8210,7 +6875,7 @@ Plot.PACF <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.PACH 1") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) if(Debug) print("Plot.PACH 2") @@ -8226,7 +6891,7 @@ Plot.PACF <- function(dt = NULL, if(Debug) print("Plot.PACH 3.5") - dt1 <- Rodeo::AutoLagRollStats( + dt1 <- AutoLagRollStats( data = dt1, DateColumn = DateVar, Targets = YVar, @@ -8421,7 +7086,7 @@ Plot.PACF <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.StackedBar <- function(dt = NULL, PreAgg = FALSE, @@ -8489,7 +7154,7 @@ Plot.StackedBar <- function(dt = NULL, check1 <- length(XVar) != 0 && length(YVar) != 0 && length(GroupVar) > 0L if(!PreAgg) { - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) } # Create base plot object @@ -8541,8 +7206,8 @@ Plot.StackedBar <- function(dt = NULL, } } else { temp <- data.table::copy(dt) - numvars <- AutoPlots:::ColNameFilter(data = temp, Types = 'numeric')[[1L]] - byvars <- unlist(AutoPlots:::ColNameFilter(data = temp, Types = "character")) + numvars <- ColNameFilter(data = temp, Types = 'numeric')[[1L]] + byvars <- unlist(ColNameFilter(data = temp, Types = "character")) } # Transformation @@ -8688,6 +7353,7 @@ Plot.StackedBar <- function(dt = NULL, #' @author Adrian Antico #' #' @param dt source data.table +#' @param PreAgg logical. Is your data pre aggregated #' @param YVar Y-Axis variable name #' @param XVar X-Axis variable name #' @param ZVar Z-Axis variable name @@ -8697,8 +7363,8 @@ Plot.StackedBar <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param MouseScroll logical, zoom via mouse scroll #' @param EchartsTheme "dark-blue" #' @param AggMethod 'mean', 'median', 'sum', 'sd', 'coeffvar', 'count' @@ -8707,6 +7373,7 @@ Plot.StackedBar <- function(dt = NULL, #' @param NumLevels_X = 20 #' @param Title "Heatmap" #' @param ShowLabels character +#' @param TextColor character #' @param Title.YAxis character #' @param Title.XAxis character #' @param title.fontSize 22 @@ -8717,6 +7384,7 @@ Plot.StackedBar <- function(dt = NULL, #' @param title.textShadowOffsetX -1 #' @param xaxis.fontSize 14 #' @param yaxis.fontSize 14 +#' @param zaxis.fontSize 14 #' @param xaxis.rotate 0 #' @param yaxis.rotate 0 #' @param ContainLabel TRUE @@ -8768,7 +7436,7 @@ Plot.StackedBar <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.BarPlot3D <- function(dt, PreAgg = FALSE, @@ -8839,7 +7507,7 @@ Plot.BarPlot3D <- function(dt, if(TimeLine && length(FacetLevels) > 0) X_Scroll <- FALSE if(!PreAgg) { - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) } # XVar == numeric or integer && YVar == numeric or integer @@ -9339,14 +8007,16 @@ Plot.BarPlot3D <- function(dt, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param MouseScroll logical, zoom via mouse scroll #' @param EchartsTheme "dark-blue" #' @param AggMethod 'mean', 'median', 'sum', 'sd', 'coeffvar', 'count' #' @param NumberBins = 21 #' @param NumLevels_Y = 20 -#' @param NumLevels_X = 20 +#' @param NumLevels_X = 20. +#' @param PreAgg logical +#' @param TextColor color #' @param Title "Heatmap" #' @param ShowLabels character #' @param Title.YAxis character @@ -9407,7 +8077,7 @@ Plot.BarPlot3D <- function(dt, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.HeatMap <- function(dt, PreAgg = FALSE, @@ -10074,14 +8744,14 @@ Plot.HeatMap <- function(dt, #' #' @param dt source data.table #' @param CorrVars vector of variable names -#' @param CorrVarsTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" +#' @param CorrVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param Method character #' @param MaxNAPercent numeric -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -10098,9 +8768,6 @@ Plot.HeatMap <- function(dt, #' @param title.textShadowOffsetX -1 #' @param xaxis.fontSize 14 #' @param yaxis.fontSize 14 -#' @param xaxis.rotate 0 -#' @param yaxis.rotate 0 -#' @param ContainLabel TRUE #' @param Debug Debugging purposes #' #' @examples @@ -10145,7 +8812,7 @@ Plot.HeatMap <- function(dt, #' xaxis.fontSize = 14, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.CorrMatrix <- function(dt = NULL, CorrVars = NULL, @@ -10251,12 +8918,13 @@ Plot.CorrMatrix <- function(dt = NULL, #' @author Adrian Antico #' #' @param dt source data.table +#' @param SampleSize Sample size #' @param CorrVars vector of variable names #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -10273,9 +8941,6 @@ Plot.CorrMatrix <- function(dt = NULL, #' @param title.textShadowOffsetX -1 #' @param xaxis.fontSize 14 #' @param yaxis.fontSize 14 -#' @param xaxis.rotate 0 -#' @param yaxis.rotate 0 -#' @param ContainLabel TRUE #' @param Debug Debugging purposes #' #' @examples @@ -10316,7 +8981,7 @@ Plot.CorrMatrix <- function(dt = NULL, #' xaxis.fontSize = 14, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Parallel <- function(dt = NULL, SampleSize = 50000, @@ -10462,12 +9127,13 @@ Plot.Parallel <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title 'Copula Plot' #' @param ShowLabels character #' @param Title.YAxis character #' @param Title.XAxis character +#' @param AddGLM logical #' @param EchartsTheme = "dark-blue", #' @param TimeLine Logical #' @param MouseScroll logical, zoom via mouse scroll @@ -10527,7 +9193,7 @@ Plot.Parallel <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Copula <- function(dt = NULL, SampleSize = 30000L, @@ -10876,8 +9542,8 @@ Plot.Copula <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title 'Copula3D Plot' #' @param ShowLabels character #' @param Title.YAxis character @@ -10893,8 +9559,10 @@ Plot.Copula <- function(dt = NULL, #' @param title.textShadowOffsetX -1 #' @param xaxis.fontSize 14 #' @param yaxis.fontSize 14 +#' @param zaxis.fontSize 14 #' @param xaxis.rotate 0 #' @param yaxis.rotate 0 +#' @param zaxis.rotate 0 #' @param ContainLabel TRUE #' @param Debug Debugging purposes #' @@ -10943,7 +9611,7 @@ Plot.Copula <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Copula3D <- function(dt = NULL, SampleSize = 100000, @@ -11170,9 +9838,11 @@ Plot.Copula3D <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title character +#' @param AddGLM logical +#' @param tooltip.trigger "axis" #' @param ShowLabels character #' @param Title.YAxis character #' @param Title.XAxis character @@ -11237,7 +9907,7 @@ Plot.Copula3D <- function(dt = NULL, #' tooltip.trigger = "axis", #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Scatter <- function(dt = NULL, SampleSize = 30000L, @@ -11597,8 +10267,8 @@ Plot.Scatter <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param Height = NULL, -#' @param Width = NULL, +#' @param Height "400px" +#' @param Width "200px" #' @param Title 'Violin Plot' #' @param ShowLabels character #' @param Title.YAxis character @@ -11614,12 +10284,13 @@ Plot.Scatter <- function(dt = NULL, #' @param title.textShadowOffsetX -1 #' @param xaxis.fontSize 14 #' @param yaxis.fontSize 14 +#' @param zaxis.fontSize 14 #' @param xaxis.rotate 0 +#' @param zaxis.rotate 0 #' @param yaxis.rotate 0 #' @param ContainLabel TRUE #' @param Debug Debugging purposes #' -#' #' @examples #' \dontrun{ #' @@ -11665,7 +10336,7 @@ Plot.Scatter <- function(dt = NULL, #' ContainLabel = TRUE, #' Debug = FALSE) #' } -#' +#' @return plot #' @export Plot.Scatter3D <- function(dt = NULL, SampleSize = 100000, @@ -11922,9 +10593,9 @@ Plot.Scatter3D <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param NumberBins numeric -#' @param ZeroLineColor character hex -#' @param ZeroLineWidth numeric #' @param Title character +#' @param Height "400px" +#' @param Width "200px" #' @param ShowLabels character #' @param Title.YAxis character #' @param Title.XAxis character @@ -11944,6 +10615,7 @@ Plot.Scatter3D <- function(dt = NULL, #' @param yaxis.rotate 0 #' @param ContainLabel TRUE #' @param Debug Debugging purposes +#' @return plot #' @export Plot.Residuals.Histogram <- function(dt = NULL, AggMethod = 'mean', @@ -12098,7 +10770,8 @@ Plot.Residuals.Histogram <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param NumberBins numeric +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -12108,6 +10781,7 @@ Plot.Residuals.Histogram <- function(dt = NULL, #' @param MouseScroll logical, zoom via mouse scroll #' @param TextColor "Not Implemented" #' @param Debug Debugging purposes +#' @return plot #' @export Plot.Residuals.Scatter <- function(dt = NULL, AggMethod = 'mean', @@ -12191,7 +10865,6 @@ Plot.Residuals.Scatter <- function(dt = NULL, #' #' @param dt source data.table #' @param AggMethod character -#' @param SampleSize numeric #' @param XVar X-Axis variable name #' @param YVar Y-Axis variable name #' @param GroupVar Character variable @@ -12201,6 +10874,8 @@ Plot.Residuals.Scatter <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param NumberBins numeric +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -12210,6 +10885,7 @@ Plot.Residuals.Scatter <- function(dt = NULL, #' @param MouseScroll logical, zoom via mouse scroll #' @param TextColor "Not Implemented" #' @param Debug Debugging purposes +#' @return plot #' @export Plot.Calibration.Line <- function(dt = NULL, AggMethod = 'mean', @@ -12251,7 +10927,7 @@ Plot.Calibration.Line <- function(dt = NULL, if(Debug) print("here 3.1") if(Debug) print("Plot.PartialDependence.Line # Define Aggregation function") if(Debug) print("here 3.2") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) if(Debug) print("here 4") @@ -12388,7 +11064,7 @@ Plot.Calibration.Line <- function(dt = NULL, # Dummify Target nam <- data.table::copy(names(dt1)) - dt1 <- Rodeo::DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) + dt1 <- DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) nam <- setdiff(names(dt1), nam) if(Debug) print("here 8") @@ -12509,6 +11185,8 @@ Plot.Calibration.Line <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. +#' @param Height "400px" +#' @param Width "200px" #' @param NumberBins numeric #' @param Title character #' @param ShowLabels character @@ -12519,6 +11197,7 @@ Plot.Calibration.Line <- function(dt = NULL, #' @param MouseScroll logical, zoom via mouse scroll #' @param TextColor "Not Implemented" #' @param Debug Debugging purposes +#' @return plot #' @export Plot.Calibration.Box <- function(dt = NULL, SampleSize = 100000L, @@ -12591,10 +11270,10 @@ Plot.Calibration.Box <- function(dt = NULL, if(Debug) print("Plot.Calibration.Box 8") # Plot - if(Debug) print(paste0("TimeLine for AutoPlots:::Plot.Box=", TimeLine)) + if(Debug) print(paste0("TimeLine for Plot.Box=", TimeLine)) dt1 <- dt1[!is.na(`Target - Predicted`)] if(Debug) print("Plot.Calibration.Box 9") - p1 <- AutoPlots:::Plot.Box( + p1 <- Plot.Box( dt = dt1, SampleSize = SampleSize, XVar = "Percentile", @@ -12643,6 +11322,8 @@ Plot.Calibration.Box <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. +#' @param Height "400px" +#' @param Width "200px" #' @param EchartsTheme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" #' @param EchartsLabels character #' @param MouseScroll logical, zoom via mouse scroll @@ -12651,6 +11332,7 @@ Plot.Calibration.Box <- function(dt = NULL, #' @param AggMethod character #' @param GroupVar Character variable #' @param Debug Debugging purposes +#' @return plot #' @export Plot.PartialDependence.Line <- function(dt = NULL, XVar = NULL, @@ -12688,7 +11370,7 @@ Plot.PartialDependence.Line <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.PartialDependence.Line # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) # Regression and Classification else MultiClass if(yvar_class %in% c("numeric","integer")) { @@ -12779,7 +11461,7 @@ Plot.PartialDependence.Line <- function(dt = NULL, # Dummify Target nam <- data.table::copy(names(dt1)) - dt1 <- Rodeo::DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) + dt1 <- DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) nam <- setdiff(names(dt1), nam) # Melt Predict Cols @@ -12866,8 +11548,6 @@ Plot.PartialDependence.Line <- function(dt = NULL, Width = Width, Title = "Partial Dependence", TextColor = TextColor, - - Debug = Debug) return(p1) } @@ -12897,6 +11577,8 @@ Plot.PartialDependence.Line <- function(dt = NULL, #' @param ShowLabels character #' @param Title.YAxis character #' @param Title.XAxis character +#' @param Height "400px" +#' @param Width "200px" #' @param EchartsTheme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" #' @param EchartsLabels character #' @param TimeLine logical @@ -12905,6 +11587,7 @@ Plot.PartialDependence.Line <- function(dt = NULL, #' @param AggMethod character #' @param GroupVar Character variable #' @param Debug Debugging purposes +#' @return plot #' @export Plot.PartialDependence.Box <- function(dt = NULL, PreAgg = FALSE, @@ -13011,6 +11694,8 @@ Plot.PartialDependence.Box <- function(dt = NULL, #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. #' @param NumberBins numeric +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -13023,6 +11708,7 @@ Plot.PartialDependence.Box <- function(dt = NULL, #' @param AggMethod character #' @param GroupVar Character variable #' @param Debug Debugging purposes +#' @return plot #' @export Plot.PartialDependence.HeatMap <- function(dt = NULL, XVar = NULL, @@ -13059,7 +11745,7 @@ Plot.PartialDependence.HeatMap <- function(dt = NULL, # Define Aggregation function if(Debug) print("Plot.PartialDependence.Line # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) # Regression and Classification else MultiClass if(yvar_class %in% c("numeric","integer")) { @@ -13072,7 +11758,7 @@ Plot.PartialDependence.HeatMap <- function(dt = NULL, dt1 <- data.table::copy(dt[, .SD, .SDcols = c(YVar, XVar, ZVar)]) if(Debug) print("Plot.PartialDependence.HeatMap # Define Aggregation function") - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) if(Debug) print("Plot.PartialDependence.HeatMap # if(length(GroupVar) == 0L)") for(i in seq_along(XVar)) { @@ -13188,7 +11874,7 @@ Plot.PartialDependence.HeatMap <- function(dt = NULL, # Dummify Target nam <- data.table::copy(names(dt1)) - dt1 <- Rodeo::DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) + dt1 <- DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) nam <- setdiff(names(dt1), nam) # Melt Predict Cols @@ -13276,13 +11962,14 @@ Plot.PartialDependence.HeatMap <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param ShowLabels character #' @param Title.YAxis character #' @param Title.XAxis character #' @param EchartsTheme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" #' @param TimeLine logical -#' @param MouseScroll logical, zoom via mouse scroll #' @param TextColor 'darkblue' #' @param title.fontSize 22 #' @param title.fontWeight "bold" @@ -13293,6 +11980,7 @@ Plot.PartialDependence.HeatMap <- function(dt = NULL, #' @param xaxis.fontSize 14 #' @param yaxis.fontSize 14 #' @param Debug Debugging purposes +#' @return plot #' @export Plot.VariableImportance <- function(dt = NULL, XVar = NULL, @@ -13383,7 +12071,8 @@ Plot.VariableImportance <- function(dt = NULL, #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. -#' @param NumberBins numeric +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -13394,6 +12083,7 @@ Plot.VariableImportance <- function(dt = NULL, #' @param SampleSize numeric #' @param TextColor character hex #' @param Debug Debugging purposes +#' @return plot #' @export Plot.ROC <- function(dt = NULL, SampleSize = 100000, @@ -13456,7 +12146,7 @@ Plot.ROC <- function(dt = NULL, # Dummify Target nam <- data.table::copy(names(dt1)) - dt1 <- Rodeo::DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) + dt1 <- DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) nam <- setdiff(names(dt1), nam) # Melt Predict Cols @@ -13643,10 +12333,15 @@ Plot.ROC <- function(dt = NULL, #' @param NumLevels_Y = NumLevels_X, #' @param GroupVar Column name of Group Variable for distinct colored histograms by group levels #' @param MouseScroll logical, zoom via mouse scroll +#' @param Height "400px" +#' @param Width "200px" #' @param Title title #' @param ShowLabels character #' @param Title.YAxis character #' @param Title.XAxis character +#' @param xaxis.rotate numeric +#' @param yaxis.rotate numeric +#' @param ContainLabel logical #' @param GroupVar = NULL #' @param AggMethod Choose from 'mean', 'sum', 'sd', and 'median' #' @param TextColor 'darkblue' @@ -13679,7 +12374,7 @@ Plot.ROC <- function(dt = NULL, #' Debug <- FALSE #' #' } -#' +#' @return plot #' @export Plot.ConfusionMatrix <- function(dt = NULL, PreAgg = FALSE, @@ -13748,7 +12443,7 @@ Plot.ConfusionMatrix <- function(dt = NULL, # Corr Matrix for the automatic ordering data.table::setorderv(dt4, c(XVar,YVar), c(1L,1L)) dt4 <- dt4[!is.na(get(ZVar))] - p1 <- AutoPlots:::Plot.HeatMap( + p1 <- Plot.HeatMap( PreAgg = TRUE, EchartsTheme = EchartsTheme, Title = Title, @@ -13763,8 +12458,6 @@ Plot.ConfusionMatrix <- function(dt = NULL, NumLevels_X = NumLevels_X, NumLevels_Y = NumLevels_Y, MouseScroll = MouseScroll, - - xaxis.rotate = xaxis.rotate, yaxis.rotate = yaxis.rotate, ContainLabel = ContainLabel) @@ -13793,6 +12486,8 @@ Plot.ConfusionMatrix <- function(dt = NULL, #' @param NumberBins numeric #' @param PreAgg logical #' @param NumberBins numeric +#' @param Height "400px" +#' @param Width "200px" #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -13802,7 +12497,7 @@ Plot.ConfusionMatrix <- function(dt = NULL, #' @param MouseScroll logical, zoom via mouse scroll #' @param TextColor character hex #' @param Debug Debugging purposes -#' +#' @return plot #' @export Plot.Lift <- function(dt = NULL, PreAgg = FALSE, @@ -13853,7 +12548,7 @@ Plot.Lift <- function(dt = NULL, # Dummify Target nam <- data.table::copy(names(dt1)) - dt1 <- Rodeo::DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) + dt1 <- DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) nam <- setdiff(names(dt1), nam) if(Debug) print("here 4") @@ -14104,6 +12799,8 @@ Plot.Lift <- function(dt = NULL, #' @param NumberBins numeric #' @param PreAgg logical #' @param NumberBins numeric +#' @param Height NULL +#' @param Width NULL #' @param Title character #' @param ShowLabels character #' @param Title.YAxis character @@ -14113,7 +12810,7 @@ Plot.Lift <- function(dt = NULL, #' @param MouseScroll logical, zoom via mouse scroll #' @param TextColor character hex #' @param Debug Debugging purposes -#' +#' @return plot #' @export Plot.Gains <- function(dt = NULL, PreAgg = FALSE, @@ -14159,7 +12856,7 @@ Plot.Gains <- function(dt = NULL, # Dummify Target nam <- data.table::copy(names(dt1)) - dt1 <- Rodeo::DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) + dt1 <- DummifyDT(data = dt1, cols = YVar, TopN = length(yvar_levels), KeepFactorCols = FALSE, OneHot = FALSE, SaveFactorLevels = FALSE, SavePath = getwd(), ImportFactorLevels = FALSE, FactorLevelsList = NULL, ClustScore = FALSE, ReturnFactorLevels = FALSE) nam <- setdiff(names(dt1), nam) if(Debug) print("here 4") @@ -14408,6 +13105,9 @@ Plot.Gains <- function(dt = NULL, #' @param YVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" #' @param XVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" #' @param ZVarTrans "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson" +#' @param CostMatrixWeights vector length 4. FP, FP, FN, TP +#' @param Height "400px" +#' @param Width "200px" #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns #' @param FacetLevels Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display. @@ -14426,6 +13126,7 @@ Plot.Gains <- function(dt = NULL, #' @param AggMethod character #' @param GroupVar Character variable #' @param Debug Debugging purposes +#' @return plot #' @export Plot.BinaryMetrics <- function(dt = NULL, PreAgg = FALSE, @@ -14480,7 +13181,7 @@ Plot.BinaryMetrics <- function(dt = NULL, # Build Plot tl <- if(length(GroupVar) == 0L) FALSE else TimeLine - dt2 <- AutoQuant:::BinaryMetrics( + dt2 <- BinaryMetrics( ValidationData. = dt1, TargetColumnName. = "BinaryTarget", CostMatrixWeights. = CostMatrixWeights, @@ -14527,6 +13228,7 @@ Plot.BinaryMetrics <- function(dt = NULL, #' @author Adrian Antico #' #' @param dt source data.table +#' @param PreAgg logical #' @param YVar Names of shap columns #' @param GroupVar Name of by variable #' @param EchartsTheme "dark-blue" @@ -14537,12 +13239,15 @@ Plot.BinaryMetrics <- function(dt = NULL, #' @param NumberBins = 21 #' @param NumLevels_Y = 20 #' @param NumLevels_X = 20 +#' @param TextColor character +#' @param Height "400px" +#' @param Width "200px" #' @param Title "Heatmap" #' @param ShowLabels character #' @param Title.YAxis character #' @param Title.XAxis character #' @param Debug = FALSE -#' +#' @return plot #' @export Plot.ShapImportance <- function(dt, PreAgg = FALSE, @@ -14581,7 +13286,7 @@ Plot.ShapImportance <- function(dt, # Define Aggregation function if(Debug) print("Plot.ShapImportance # Define Aggregation function") if(Debug) print(AggMethod) - aggFunc <- AutoPlots:::SummaryFunction(AggMethod) + aggFunc <- SummaryFunction(AggMethod) if(length(GroupVar) > 0L) { dt1 <- dt1[, lapply(.SD, FUN = noquote(aggFunc)), by = c(GroupVar)] @@ -14773,7 +13478,7 @@ Plot.ShapImportance <- function(dt, # } # } # #xx <- xx[, .SD, .SDcols = c(names(xx)[c(1,2,5,6,12)])] -# AutoQuant::PostGRE_RemoveCreateAppend( +# PostGRE_RemoveCreateAppend( # data = xx, # TableName = "ticker_data", # CloseConnection = TRUE, diff --git a/R/helpers.R b/R/helpers.R index 39024a0..77395d3 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -23,16 +23,16 @@ #' @family Utilities #' #' @param Root NULL will setwd to project root as defined in function -#' -#' @export +#' @return nothing +#' @noRd BuildBinary <- function(Root = NULL) { x <- getwd() if(!is.null(Root)) { setwd(Root) - devtools::install(pkg = "AutoQuant", dependencies = FALSE) + devtools::install(pkg = "AutoPlots", dependencies = FALSE) } else { setwd("C:/Users/Bizon/Documents/GitHub") - devtools::build(pkg = "AutoQuant") + devtools::build(pkg = "AutoPlots") } setwd(x) } @@ -46,8 +46,8 @@ BuildBinary <- function(Root = NULL) { #' @family Utilities #' #' @param Root NULL will setwd to project root as defined in function -#' -#' @export +#' @return nothing +#' @noRd Install <- function(Root = NULL) { x <- getwd() if(!is.null(Root)) { @@ -68,7 +68,10 @@ Install <- function(Root = NULL) { #' #' @family Utilities #' -#' @export +#' @param BuildVignette logical +#' @param Root character +#' @return nothing +#' @noRd UpdateDocs <- function(BuildVignette = FALSE, Root = NULL) { x <- getwd() if(!is.null(Root)) { diff --git a/README.md b/README.md index 66ab93e..9bd4334 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ ![Version:1.0.0](https://img.shields.io/static/v1?label=Version&message=1.0.0&color=blue&?style=plastic) -[![PRsWelcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=default)](http://makeapullrequest.com) + + +[![R-CMD-check](https://github.com/AdrianAntico/AutoPlots/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/AdrianAntico/AutoPlots/actions/workflows/R-CMD-check.yaml) + @@ -39,7 +42,7 @@ This package is intended to reduce or eliminate that behavior (hence the "Auto" ### Model evaluation These plot types are most useful for those looking to evaluate the performance of regression, binary classification, and multiclass models. Designing plots for multiclass models are rather challenging but I've abstracted all that work away so the user only has to pass their categorical target variable along with their categorical predicted value, and the plots will display all the levels appropriately without requiring the user to do the data manipulation ahead of time. Same goes for regression and classification, which are easier, but still requires time and energy. -Additionaly, all model evaluation plots supports grouping variables for by-analysis of models, even for multiclass models! +Additionally, all model evaluation plots supports grouping variables for by-analysis of models, even for multiclass models! - Calibration Plots - Calibration Scatter Plots - Partital Dependence Plots @@ -68,56 +71,48 @@ Another giant bonus is that the user can either pre-aggregate their data and pas # Getting Started -### Installation +### Installation from CRAN +```r +install.packages("AutoPlots") +``` + +### Installation from GitHub ```r -install.packages("bit64") +install.packages("combinat") install.packages("data.table") -install.packages("echarts4r") +install.packages("devtools") install.packages("dplyr") +install.packages("e1071") +install.packages("echarts4r") +install.packages("lubridate") +install.packages("nortest") install.packages("quanteda") install.packages("quanteda.textstats") -devtools::install_github("AdrianAntico/Rodeo", upgrade = FALSE, force = TRUE) +install.packages("scales") +install.packages("stats") +install.packages("utils") devtools::install_github("AdrianAntico/AutoPlots", upgrade = FALSE, force = TRUE) ``` -### Plot Images +### Sample of Plot Images - - - - - - - - - - - - - - - - - - - - + diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. diff --git a/inst/AutocorrelationPlot.PNG b/inst/AutocorrelationPlot.PNG deleted file mode 100644 index b9a015a..0000000 Binary files a/inst/AutocorrelationPlot.PNG and /dev/null differ diff --git a/inst/CopulaPlot3D.PNG b/inst/CopulaPlot3D.PNG deleted file mode 100644 index 96b72eb..0000000 Binary files a/inst/CopulaPlot3D.PNG and /dev/null differ diff --git a/inst/Heatmap.PNG b/inst/Heatmap.PNG deleted file mode 100644 index 44a66f4..0000000 Binary files a/inst/Heatmap.PNG and /dev/null differ diff --git a/inst/PartialAutocorrelationPlot.PNG b/inst/PartialAutocorrelationPlot.PNG deleted file mode 100644 index e05e7a0..0000000 Binary files a/inst/PartialAutocorrelationPlot.PNG and /dev/null differ diff --git a/inst/PiePlot.PNG b/inst/PiePlot.PNG deleted file mode 100644 index 2b7d0d2..0000000 Binary files a/inst/PiePlot.PNG and /dev/null differ diff --git a/inst/ProbabilityPlot.PNG b/inst/ProbabilityPlot.PNG deleted file mode 100644 index 6c50e11..0000000 Binary files a/inst/ProbabilityPlot.PNG and /dev/null differ diff --git a/inst/ScatterPlot3D.PNG b/inst/ScatterPlot3D.PNG deleted file mode 100644 index 3ec03bc..0000000 Binary files a/inst/ScatterPlot3D.PNG and /dev/null differ diff --git a/inst/WordCloud.PNG b/inst/WordCloud.PNG deleted file mode 100644 index 8ddcb69..0000000 Binary files a/inst/WordCloud.PNG and /dev/null differ diff --git a/inst/zz_CalibrationBox.PNG b/inst/zz_CalibrationBox.PNG deleted file mode 100644 index dd69526..0000000 Binary files a/inst/zz_CalibrationBox.PNG and /dev/null differ diff --git a/inst/zz_CalibrationLine.PNG b/inst/zz_CalibrationLine.PNG deleted file mode 100644 index bd55766..0000000 Binary files a/inst/zz_CalibrationLine.PNG and /dev/null differ diff --git a/inst/zz_ConfusionMatrix.PNG b/inst/zz_ConfusionMatrix.PNG deleted file mode 100644 index 2cf7e38..0000000 Binary files a/inst/zz_ConfusionMatrix.PNG and /dev/null differ diff --git a/inst/zz_Gains.PNG b/inst/zz_Gains.PNG deleted file mode 100644 index bee0720..0000000 Binary files a/inst/zz_Gains.PNG and /dev/null differ diff --git a/inst/zz_Lift.PNG b/inst/zz_Lift.PNG deleted file mode 100644 index 787c77a..0000000 Binary files a/inst/zz_Lift.PNG and /dev/null differ diff --git a/inst/zz_PartialDependenceBarPlot.PNG b/inst/zz_PartialDependenceBarPlot.PNG deleted file mode 100644 index 1c092ee..0000000 Binary files a/inst/zz_PartialDependenceBarPlot.PNG and /dev/null differ diff --git a/inst/zz_PartialDependenceLine.PNG b/inst/zz_PartialDependenceLine.PNG deleted file mode 100644 index 2b307d9..0000000 Binary files a/inst/zz_PartialDependenceLine.PNG and /dev/null differ diff --git a/inst/zz_ROC.PNG b/inst/zz_ROC.PNG deleted file mode 100644 index 9a2bc5c..0000000 Binary files a/inst/zz_ROC.PNG and /dev/null differ diff --git a/inst/zz_ResidualHistogram.PNG b/inst/zz_ResidualHistogram.PNG deleted file mode 100644 index 53aa034..0000000 Binary files a/inst/zz_ResidualHistogram.PNG and /dev/null differ diff --git a/inst/zz_ResidualScatter.PNG b/inst/zz_ResidualScatter.PNG deleted file mode 100644 index 6faf607..0000000 Binary files a/inst/zz_ResidualScatter.PNG and /dev/null differ diff --git a/inst/zz_ShapleyImportance.PNG b/inst/zz_ShapleyImportance.PNG deleted file mode 100644 index 2342685..0000000 Binary files a/inst/zz_ShapleyImportance.PNG and /dev/null differ diff --git a/inst/zz_VariableImportance.PNG b/inst/zz_VariableImportance.PNG deleted file mode 100644 index ab89d03..0000000 Binary files a/inst/zz_VariableImportance.PNG and /dev/null differ diff --git a/man/AutoLagRollStats.Rd b/man/AutoLagRollStats.Rd new file mode 100644 index 0000000..b98881d --- /dev/null +++ b/man/AutoLagRollStats.Rd @@ -0,0 +1,88 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/AccessoryFunctions.R +\name{AutoLagRollStats} +\alias{AutoLagRollStats} +\title{AutoLagRollStats} +\usage{ +AutoLagRollStats( + data, + Targets = NULL, + HierarchyGroups = NULL, + IndependentGroups = NULL, + DateColumn = NULL, + TimeUnit = NULL, + TimeUnitAgg = NULL, + TimeGroups = NULL, + TimeBetween = NULL, + RollOnLag1 = TRUE, + Type = "Lag", + SimpleImpute = TRUE, + Lags = NULL, + MA_RollWindows = NULL, + SD_RollWindows = NULL, + Skew_RollWindows = NULL, + Kurt_RollWindows = NULL, + Quantile_RollWindows = NULL, + Quantiles_Selected = NULL, + ShortName = TRUE, + Debug = FALSE +) +} +\arguments{ +\item{data}{A data.table you want to run the function on} + +\item{Targets}{A character vector of the column names for the reference column in which you will build your lags and rolling stats} + +\item{HierarchyGroups}{A vector of categorical column names that you want to have generate all lags and rolling stats done for the individual columns and their full set of interactions.} + +\item{IndependentGroups}{A vector of categorical column names that you want to have run independently of each other. This will mean that no interaction will be done.} + +\item{DateColumn}{The column name of your date column used to sort events over time} + +\item{TimeUnit}{List the time aggregation level for the time between events features, such as "hour", "day", "weeks", "months", "quarter", or "year"} + +\item{TimeUnitAgg}{List the time aggregation of your data that you want to use as a base time unit for your features. E.g. "raw" or "day"} + +\item{TimeGroups}{A vector of TimeUnits indicators to specify any time-aggregated GDL features you want to have returned. E.g. c("raw" (no aggregation is done),"hour", "day","week","month","quarter","year")} + +\item{TimeBetween}{Specify a desired name for features created for time between events. Set to NULL if you don't want time between events features created.} + +\item{RollOnLag1}{Set to FALSE to build rolling stats off of target columns directly or set to TRUE to build the rolling stats off of the lag-1 target} + +\item{Type}{List either "Lag" if you want features built on historical values or "Lead" if you want features built on future values} + +\item{SimpleImpute}{Set to TRUE for factor level imputation of "0" and numeric imputation of -1} + +\item{Lags}{A numeric vector of the specific lags you want to have generated. You must include 1 if WindowingLag = 1.} + +\item{MA_RollWindows}{A numeric vector of the specific rolling statistics window sizes you want to utilize in the calculations.} + +\item{SD_RollWindows}{A numeric vector of Standard Deviation rolling statistics window sizes you want to utilize in the calculations.} + +\item{Skew_RollWindows}{A numeric vector of Skewness rolling statistics window sizes you want to utilize in the calculations.} + +\item{Kurt_RollWindows}{A numeric vector of Kurtosis rolling statistics window sizes you want to utilize in the calculations.} + +\item{Quantile_RollWindows}{A numeric vector of Quantile rolling statistics window sizes you want to utilize in the calculations.} + +\item{Quantiles_Selected}{Select from the following c("q5", "q10", "q15", "q20", "q25", "q30", "q35", "q40", "q45", "q50", "q55", "q60"," q65", "q70", "q75", "q80", "q85", "q90", "q95")} + +\item{ShortName}{Default TRUE. If FALSE, Group Variable names will be added to the rolling stat and lag names. If you plan on have multiple versions of lags and rollings stats by different group variables then set this to FALSE.} + +\item{Debug}{Set to TRUE to get a print of which steps are running} +} +\value{ +data.table of original data plus created lags, rolling stats, and time between event lags and rolling stats +} +\description{ +AutoLagRollStats Builds lags and a large variety of rolling statistics with options to generate them for hierarchical categorical interactions. +} +\seealso{ +Other Feature Engineering: +\code{\link{DT_GDL_Feature_Engineering}()}, +\code{\link{DummifyDT}()} +} +\author{ +Adrian Antico +} +\concept{Feature Engineering} diff --git a/man/BuildBinary.Rd b/man/BuildBinary.Rd deleted file mode 100644 index 932b0fb..0000000 --- a/man/BuildBinary.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{BuildBinary} -\alias{BuildBinary} -\title{BuildBinary} -\usage{ -BuildBinary(Root = NULL) -} -\arguments{ -\item{Root}{NULL will setwd to project root as defined in function} -} -\description{ -Build package binary -} -\seealso{ -Other Utilities: -\code{\link{Install}()}, -\code{\link{UpdateDocs}()} -} -\author{ -Adrian Antico -} -\concept{Utilities} diff --git a/man/DT_GDL_Feature_Engineering.Rd b/man/DT_GDL_Feature_Engineering.Rd new file mode 100644 index 0000000..64f780e --- /dev/null +++ b/man/DT_GDL_Feature_Engineering.Rd @@ -0,0 +1,76 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/AccessoryFunctions.R +\name{DT_GDL_Feature_Engineering} +\alias{DT_GDL_Feature_Engineering} +\title{DT_GDL_Feature_Engineering} +\usage{ +DT_GDL_Feature_Engineering( + data, + lags = 1, + periods = 0, + SDperiods = 0, + Skewperiods = 0, + Kurtperiods = 0, + Quantileperiods = 0, + statsFUNs = c("mean"), + targets = NULL, + groupingVars = NULL, + sortDateName = NULL, + timeDiffTarget = NULL, + timeAgg = c("days"), + WindowingLag = 0, + ShortName = TRUE, + Type = c("Lag"), + SimpleImpute = TRUE +) +} +\arguments{ +\item{data}{A data.table you want to run the function on} + +\item{lags}{A numeric vector of the specific lags you want to have generated. You must include 1 if WindowingLag = 1.} + +\item{periods}{A numeric vector of the specific rolling statistics window sizes you want to utilize in the calculations.} + +\item{SDperiods}{A numeric vector of Standard Deviation rolling statistics window sizes you want to utilize in the calculations.} + +\item{Skewperiods}{A numeric vector of Skewness rolling statistics window sizes you want to utilize in the calculations.} + +\item{Kurtperiods}{A numeric vector of Kurtosis rolling statistics window sizes you want to utilize in the calculations.} + +\item{Quantileperiods}{A numeric vector of Quantile rolling statistics window sizes you want to utilize in the calculations.} + +\item{statsFUNs}{Select from the following c("mean","sd","skew","kurt","q5","q10","q15","q20","q25","q30","q35","q40","q45","q50","q55","q60","q65","q70","q75","q80","q85","q90","q95")} + +\item{targets}{A character vector of the column names for the reference column in which you will build your lags and rolling stats} + +\item{groupingVars}{A character vector of categorical variable names you will build your lags and rolling stats by} + +\item{sortDateName}{The column name of your date column used to sort events over time} + +\item{timeDiffTarget}{Specify a desired name for features created for time between events. Set to NULL if you don't want time between events features created.} + +\item{timeAgg}{List the time aggregation level for the time between events features, such as "hour", "day", "week", "month", "quarter", or "year"} + +\item{WindowingLag}{Set to 0 to build rolling stats off of target columns directly or set to 1 to build the rolling stats off of the lag-1 target} + +\item{ShortName}{Default TRUE. If FALSE, Group Variable names will be added to the rolling stat and lag names. If you plan on have multiple versions of lags and rollings stats by different group variables then set this to FALSE.} + +\item{Type}{List either "Lag" if you want features built on historical values or "Lead" if you want features built on future values} + +\item{SimpleImpute}{Set to TRUE for factor level imputation of "0" and numeric imputation of -1} +} +\value{ +data.table of original data plus created lags, rolling stats, and time between event lags and rolling stats +} +\description{ +Builds autoregressive and moving average from target columns and distributed lags and distributed moving average for independent features distributed across time. On top of that, you can also create time between instances along with their associated lags and moving averages. This function works for data with groups and without groups. +} +\seealso{ +Other Feature Engineering: +\code{\link{AutoLagRollStats}()}, +\code{\link{DummifyDT}()} +} +\author{ +Adrian Antico +} +\concept{Feature Engineering} diff --git a/man/DummifyDT.Rd b/man/DummifyDT.Rd new file mode 100644 index 0000000..b696103 --- /dev/null +++ b/man/DummifyDT.Rd @@ -0,0 +1,129 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/AccessoryFunctions.R +\name{DummifyDT} +\alias{DummifyDT} +\title{DummifyDT} +\usage{ +DummifyDT( + data, + cols, + TopN = NULL, + KeepFactorCols = FALSE, + OneHot = FALSE, + SaveFactorLevels = FALSE, + SavePath = NULL, + ImportFactorLevels = FALSE, + FactorLevelsList = NULL, + ClustScore = FALSE, + ReturnFactorLevels = FALSE, + GroupVar = FALSE +) +} +\arguments{ +\item{data}{The data set to run the micro auc on} + +\item{cols}{A vector with the names of the columns you wish to dichotomize} + +\item{TopN}{Default is NULL. Scalar to apply to all categorical columns or a vector to apply to each categorical variable. Only create dummy variables for the TopN number of levels. Will be either TopN or max(levels)} + +\item{KeepFactorCols}{Set to TRUE to keep the original columns used in the dichotomization process} + +\item{OneHot}{Set to TRUE to run one hot encoding, FALSE to generate N columns for N levels} + +\item{SaveFactorLevels}{Set to TRUE to save unique levels of each factor column to file as a csv} + +\item{SavePath}{Provide a file path to save your factor levels. Use this for models that you have to create dummy variables for.} + +\item{ImportFactorLevels}{Instead of using the data you provide, import the factor levels csv to ensure you build out all of the columns you trained with in modeling.} + +\item{FactorLevelsList}{Supply a list of factor variable levels} + +\item{ClustScore}{This is for scoring AutoKMeans. It converts the added dummy column names to conform with H2O dummy variable naming convention} + +\item{ReturnFactorLevels}{If you want a named list of all the factor levels returned, set this to TRUE. Doing so will cause the function to return a list with the source data.table and the list of factor variables' levels} + +\item{GroupVar}{Ignore this} +} +\value{ +Either a data table with new dummy variables columns and optionally removes base columns (if ReturnFactorLevels is FALSE), otherwise a list with the data.table and a list of the factor levels. +} +\description{ +DummifyDT creates dummy variables for the selected columns. Either one-hot encoding, N+1 columns for N levels, or N columns for N levels. +} +\examples{ +\dontrun{ +data <- FakeDataGenerator( + Correlation = 0.85, + N = 25000, + ID = 2L, + ZIP = 0, + FactorCount = 10L, + AddDate = FALSE, + Classification = FALSE, + MultiClass = FALSE) + +# Create dummy variables +data <- DummifyDT( + data = data, + cols = c("Factor_1", + "Factor_2", + "Factor_3", + "Factor_4", + "Factor_5", + "Factor_6", + "Factor_8", + "Factor_9", + "Factor_10"), + TopN = c(rep(3,9)), + KeepFactorCols = TRUE, + OneHot = FALSE, + SaveFactorLevels = TRUE, + SavePath = getwd(), + ImportFactorLevels = FALSE, + FactorLevelsList = NULL, + ClustScore = FALSE, + ReturnFactorLevels = FALSE) + +# Create Fake Data for Scoring Replication +data <- FakeDataGenerator( + Correlation = 0.85, + N = 25000, + ID = 2L, + ZIP = 0, + FactorCount = 10L, + AddDate = FALSE, + Classification = FALSE, + MultiClass = FALSE) + +# Scoring Version +data <- DummifyDT( + data = data, + cols = c("Factor_1", + "Factor_2", + "Factor_3", + "Factor_4", + "Factor_5", + "Factor_6", + "Factor_8", + "Factor_9", + "Factor_10"), + TopN = c(rep(3,9)), + KeepFactorCols = TRUE, + OneHot = FALSE, + SaveFactorLevels = TRUE, + SavePath = getwd(), + ImportFactorLevels = TRUE, + FactorLevelsList = NULL, + ClustScore = FALSE, + ReturnFactorLevels = FALSE) +} +} +\seealso{ +Other Feature Engineering: +\code{\link{AutoLagRollStats}()}, +\code{\link{DT_GDL_Feature_Engineering}()} +} +\author{ +Adrian Antico +} +\concept{Feature Engineering} diff --git a/man/FakeDataGenerator.Rd b/man/FakeDataGenerator.Rd index 42e77c7..20a0645 100644 --- a/man/FakeDataGenerator.Rd +++ b/man/FakeDataGenerator.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/PlotFunctions.R +% Please edit documentation in R/AccessoryFunctions.R \name{FakeDataGenerator} \alias{FakeDataGenerator} \title{FakeDataGenerator} @@ -13,8 +13,6 @@ FakeDataGenerator( AddComment = FALSE, AddWeightsColumn = FALSE, ZIP = 5L, - TimeSeries = FALSE, - TimeSeriesTimeAgg = "day", ChainLadderData = FALSE, Classification = FALSE, MultiClass = FALSE @@ -33,11 +31,9 @@ FakeDataGenerator( \item{AddComment}{Set to TRUE to add a comment column} -\item{ZIP}{Zero Inflation Model target variable creation. Select from 0 to 5 to create that number of distinctly distributed data, stratifed from small to large} - -\item{TimeSeries}{For testing AutoBanditSarima} +\item{AddWeightsColumn}{Add a weights column for ML} -\item{TimeSeriesTimeAgg}{Choose from "1min", "5min", "10min", "15min", "30min", "hour", "day", "week", "month", "quarter", "year",} +\item{ZIP}{Zero Inflation Model target variable creation. Select from 0 to 5 to create that number of distinctly distributed data, stratifed from small to large} \item{ChainLadderData}{Set to TRUE to return Chain Ladder Data for using AutoMLChainLadderTrainer} @@ -45,6 +41,9 @@ FakeDataGenerator( \item{MultiClass}{Set to TRUE to build MultiClass data} } +\value{ +data.table of data +} \description{ Create fake data for examples } diff --git a/man/Install.Rd b/man/Install.Rd deleted file mode 100644 index f8391ac..0000000 --- a/man/Install.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{Install} -\alias{Install} -\title{Install} -\usage{ -Install(Root = NULL) -} -\arguments{ -\item{Root}{NULL will setwd to project root as defined in function} -} -\description{ -To install the package -} -\seealso{ -Other Utilities: -\code{\link{BuildBinary}()}, -\code{\link{UpdateDocs}()} -} -\author{ -Adrian Antico -} -\concept{Utilities} diff --git a/man/Plot.ACF.Rd b/man/Plot.ACF.Rd index a053f0f..ebd5a1e 100644 --- a/man/Plot.ACF.Rd +++ b/man/Plot.ACF.Rd @@ -40,13 +40,15 @@ Plot.ACF( \item{TimeUnit}{Select from "hour", "day", "week", "month", "quarter", "year"} +\item{MaxLags}{Max lag values to test} + \item{YVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} \item{AggMethod}{Choose from 'mean', 'sum', 'sd', and 'median'} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{title} @@ -77,10 +79,9 @@ Plot.ACF( \item{ContainLabel}{TRUE} \item{Debug}{Debugging purposes} - -\item{PreAgg}{logical} - -\item{TimeLine}{logical} +} +\value{ +plot } \description{ Build an autocorrelation plot by simply passing arguments to a single function diff --git a/man/Plot.Area.Rd b/man/Plot.Area.Rd index 205f5a9..15dd7a3 100644 --- a/man/Plot.Area.Rd +++ b/man/Plot.Area.Rd @@ -72,9 +72,9 @@ Plot.Area( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{"Title"} @@ -124,6 +124,9 @@ Plot.Area( \item{Area}{logical} } +\value{ +plot +} \description{ This function automatically builds calibration plots and calibration boxplots for model evaluation using regression, quantile regression, and binary and multinomial classification } @@ -145,7 +148,6 @@ AutoPlots::Plot.Area( GroupVar = NULL, EchartsTheme = "macarons") } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Bar.Rd b/man/Plot.Bar.Rd index 713fe8d..faaf79a 100644 --- a/man/Plot.Bar.Rd +++ b/man/Plot.Bar.Rd @@ -66,9 +66,9 @@ Plot.Bar( \item{AggMethod}{Choose from 'mean', 'sum', 'sd', and 'median'} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{title} @@ -110,6 +110,9 @@ Plot.Bar( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a bar plot by simply passing arguments to a single function } @@ -155,7 +158,6 @@ AutoPlots::Plot.Bar( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.BarPlot3D.Rd b/man/Plot.BarPlot3D.Rd index 50d4ede..90e00ef 100644 --- a/man/Plot.BarPlot3D.Rd +++ b/man/Plot.BarPlot3D.Rd @@ -47,6 +47,8 @@ Plot.BarPlot3D( \arguments{ \item{dt}{source data.table} +\item{PreAgg}{logical. Is your data pre aggregated} + \item{AggMethod}{'mean', 'median', 'sum', 'sd', 'coeffvar', 'count'} \item{XVar}{X-Axis variable name} @@ -73,9 +75,9 @@ Plot.BarPlot3D( \item{NumLevels_X}{= 20} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{"Heatmap"} @@ -89,6 +91,8 @@ Plot.BarPlot3D( \item{MouseScroll}{logical, zoom via mouse scroll} +\item{TextColor}{character} + \item{title.fontSize}{22} \item{title.fontWeight}{"bold"} @@ -105,6 +109,8 @@ Plot.BarPlot3D( \item{xaxis.fontSize}{14} +\item{zaxis.fontSize}{14} + \item{xaxis.rotate}{0} \item{yaxis.rotate}{0} @@ -113,6 +119,9 @@ Plot.BarPlot3D( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a 3D Bar Plot } @@ -162,7 +171,6 @@ AutoPlots::Plot.BarPlot3D( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.BinaryMetrics.Rd b/man/Plot.BinaryMetrics.Rd index 176fbd5..da0979f 100644 --- a/man/Plot.BinaryMetrics.Rd +++ b/man/Plot.BinaryMetrics.Rd @@ -68,8 +68,14 @@ Plot.BinaryMetrics( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} +\item{CostMatrixWeights}{vector length 4. FP, FP, FN, TP} + \item{NumberBins}{numeric} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{MouseScroll}{logical, zoom via mouse scroll} @@ -90,6 +96,9 @@ Plot.BinaryMetrics( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Line plot of evaluation metrics across thresholds } diff --git a/man/Plot.Box.Rd b/man/Plot.Box.Rd index 6278c81..fcb2e8f 100644 --- a/man/Plot.Box.Rd +++ b/man/Plot.Box.Rd @@ -60,9 +60,9 @@ Plot.Box( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{character} @@ -104,6 +104,9 @@ Plot.Box( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a box plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. } @@ -147,7 +150,6 @@ AutoPlots::Plot.Box( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Calibration.Box.Rd b/man/Plot.Calibration.Box.Rd index 2525ad0..d1bd043 100644 --- a/man/Plot.Calibration.Box.Rd +++ b/man/Plot.Calibration.Box.Rd @@ -55,6 +55,10 @@ Plot.Calibration.Box( \item{NumberBins}{numeric} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{MouseScroll}{logical, zoom via mouse scroll} @@ -73,6 +77,9 @@ Plot.Calibration.Box( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ This function automatically builds calibration plots and calibration boxplots for model evaluation using regression, quantile regression, and binary and multinomial classification } diff --git a/man/Plot.Calibration.Line.Rd b/man/Plot.Calibration.Line.Rd index 3c40b2a..64cfaa6 100644 --- a/man/Plot.Calibration.Line.Rd +++ b/man/Plot.Calibration.Line.Rd @@ -52,6 +52,10 @@ Plot.Calibration.Line( \item{NumberBins}{numeric} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{ShowLabels}{character} @@ -69,8 +73,9 @@ Plot.Calibration.Line( \item{TextColor}{"Not Implemented"} \item{Debug}{Debugging purposes} - -\item{SampleSize}{numeric} +} +\value{ +plot } \description{ This function automatically builds calibration plots and calibration boxplots for model evaluation using regression, quantile regression, and binary and multinomial classification diff --git a/man/Plot.ConfusionMatrix.Rd b/man/Plot.ConfusionMatrix.Rd index d65ccfe..7042d14 100644 --- a/man/Plot.ConfusionMatrix.Rd +++ b/man/Plot.ConfusionMatrix.Rd @@ -66,6 +66,10 @@ Plot.ConfusionMatrix( \item{NumLevels_Y}{= NumLevels_X,} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{title} \item{ShowLabels}{character} @@ -86,8 +90,17 @@ Plot.ConfusionMatrix( \item{GroupVar}{= NULL} +\item{xaxis.rotate}{numeric} + +\item{yaxis.rotate}{numeric} + +\item{ContainLabel}{logical} + \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Generate variable importance plots } @@ -118,7 +131,6 @@ AggMethod <- "mean" Debug <- FALSE } - } \seealso{ Other Model Evaluation: diff --git a/man/Plot.Copula.Rd b/man/Plot.Copula.Rd index a8e992f..af13433 100644 --- a/man/Plot.Copula.Rd +++ b/man/Plot.Copula.Rd @@ -61,14 +61,16 @@ Plot.Copula( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{'Copula Plot'} \item{ShowLabels}{character} +\item{AddGLM}{logical} + \item{Title.YAxis}{character} \item{Title.XAxis}{character} @@ -105,6 +107,9 @@ Plot.Copula( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a copula plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. } @@ -150,7 +155,6 @@ AutoPlots::Plot.Copula( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Copula3D.Rd b/man/Plot.Copula3D.Rd index bc79738..76d7d0e 100644 --- a/man/Plot.Copula3D.Rd +++ b/man/Plot.Copula3D.Rd @@ -67,9 +67,9 @@ Plot.Copula3D( \item{GroupVar}{Requires an XVar and YVar already be defined} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{'Copula3D Plot'} @@ -101,14 +101,21 @@ Plot.Copula3D( \item{xaxis.fontSize}{14} +\item{zaxis.fontSize}{14} + \item{xaxis.rotate}{0} \item{yaxis.rotate}{0} +\item{zaxis.rotate}{0} + \item{ContainLabel}{TRUE} \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a 3D-copula plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. } @@ -157,7 +164,6 @@ AutoPlots::Plot.Copula3D( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.CorrMatrix.Rd b/man/Plot.CorrMatrix.Rd index 75ee6e2..248789d 100644 --- a/man/Plot.CorrMatrix.Rd +++ b/man/Plot.CorrMatrix.Rd @@ -39,6 +39,8 @@ Plot.CorrMatrix( \item{CorrVars}{vector of variable names} +\item{CorrVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} + \item{FacetRows}{Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows} \item{FacetCols}{Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns} @@ -51,9 +53,9 @@ Plot.CorrMatrix( \item{MaxNAPercent}{numeric} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{character} @@ -86,14 +88,9 @@ Plot.CorrMatrix( \item{xaxis.fontSize}{14} \item{Debug}{Debugging purposes} - -\item{CorrVarsTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} - -\item{xaxis.rotate}{0} - -\item{yaxis.rotate}{0} - -\item{ContainLabel}{TRUE} +} +\value{ +plot } \description{ Build a correlation matrix plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. @@ -140,7 +137,6 @@ AutoPlots::Plot.CorrMatrix( xaxis.fontSize = 14, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Density.Rd b/man/Plot.Density.Rd index 209a797..b90f6b6 100644 --- a/man/Plot.Density.Rd +++ b/man/Plot.Density.Rd @@ -60,9 +60,9 @@ Plot.Density( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{MouseScroll}{logical, zoom via mouse scroll} @@ -104,6 +104,9 @@ Plot.Density( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Density plots, by groups, with transparent continuous plots } @@ -145,7 +148,6 @@ AutoPlots::Plot.Density( yaxis.fontSize = 14, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Donut.Rd b/man/Plot.Donut.Rd index e114f04..4bb0a6b 100644 --- a/man/Plot.Donut.Rd +++ b/man/Plot.Donut.Rd @@ -59,9 +59,9 @@ Plot.Donut( \item{AggMethod}{Choose from 'mean', 'sum', 'sd', and 'median'} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{title} @@ -95,6 +95,9 @@ Plot.Donut( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a donut plot by simply passing arguments to a single function } @@ -136,7 +139,6 @@ AutoPlots::Plot.Donut( yaxis.fontSize = 14, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Gains.Rd b/man/Plot.Gains.Rd index 172efe9..121a722 100644 --- a/man/Plot.Gains.Rd +++ b/man/Plot.Gains.Rd @@ -58,6 +58,10 @@ Plot.Gains( \item{NumberBins}{numeric} +\item{Height}{NULL} + +\item{Width}{NULL} + \item{Title}{character} \item{ShowLabels}{character} @@ -76,6 +80,9 @@ Plot.Gains( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Create a cumulative gains chart } diff --git a/man/Plot.HeatMap.Rd b/man/Plot.HeatMap.Rd index 38900bd..6cb9568 100644 --- a/man/Plot.HeatMap.Rd +++ b/man/Plot.HeatMap.Rd @@ -46,6 +46,8 @@ Plot.HeatMap( \arguments{ \item{dt}{source data.table} +\item{PreAgg}{logical} + \item{AggMethod}{'mean', 'median', 'sum', 'sd', 'coeffvar', 'count'} \item{XVar}{X-Axis variable name} @@ -70,11 +72,11 @@ Plot.HeatMap( \item{NumLevels_Y}{= 20} -\item{NumLevels_X}{= 20} +\item{NumLevels_X}{= 20.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{"Heatmap"} @@ -88,6 +90,8 @@ Plot.HeatMap( \item{MouseScroll}{logical, zoom via mouse scroll} +\item{TextColor}{color} + \item{title.fontSize}{22} \item{title.fontWeight}{"bold"} @@ -112,6 +116,9 @@ Plot.HeatMap( \item{Debug}{Debugging parameter} } +\value{ +plot +} \description{ Create heat maps with numeric or categorical dt } @@ -158,7 +165,6 @@ AutoPlots::Plot.HeatMap( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Histogram.Rd b/man/Plot.Histogram.Rd index 40d24b1..6c0b0bc 100644 --- a/man/Plot.Histogram.Rd +++ b/man/Plot.Histogram.Rd @@ -60,12 +60,14 @@ Plot.Histogram( \item{NumberBins}{= 30} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{EchartsTheme}{= EchartsTheme,} +\item{Title}{character} + \item{MouseScroll}{logical, zoom via mouse scroll} \item{TimeLine}{logical} @@ -95,8 +97,9 @@ Plot.Histogram( \item{yaxis.fontSize}{14} \item{Debug}{Debugging purposes} - -\item{BackGroundColor}{color outside of plot window. Rcolors and hex outside of plot window. Rcolors and hex character} +} +\value{ +plot } \description{ Build a histogram plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. @@ -140,7 +143,6 @@ AutoPlots::Plot.Histogram( yaxis.fontSize = 14, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Lift.Rd b/man/Plot.Lift.Rd index 61b497b..af18552 100644 --- a/man/Plot.Lift.Rd +++ b/man/Plot.Lift.Rd @@ -58,6 +58,10 @@ Plot.Lift( \item{NumberBins}{numeric} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{ShowLabels}{character} @@ -76,6 +80,9 @@ Plot.Lift( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Create a cumulative gains chart } diff --git a/man/Plot.Line.Rd b/man/Plot.Line.Rd index 9fd57c6..b9b8a91 100644 --- a/man/Plot.Line.Rd +++ b/man/Plot.Line.Rd @@ -64,6 +64,8 @@ Plot.Line( \item{YVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} +\item{DualYVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} + \item{XVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} \item{FacetRows}{Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows} @@ -72,9 +74,9 @@ Plot.Line( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{NULL} -\item{Width}{= NULL,} +\item{Width}{NULL} \item{Title}{"Title"} @@ -125,8 +127,9 @@ Plot.Line( \item{DarkMode}{FALSE} \item{Debug}{Debugging purposes} - -\item{BackGroundColor}{color outside of plot window. Rcolors and hex} +} +\value{ +plot } \description{ This function automatically builds calibration plots and calibration boxplots for model evaluation using regression, quantile regression, and binary and multinomial classification @@ -149,7 +152,6 @@ AutoPlots::Plot.Line( GroupVar = NULL, EchartsTheme = "macarons") } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.PACF.Rd b/man/Plot.PACF.Rd index 6657c4b..67d92eb 100644 --- a/man/Plot.PACF.Rd +++ b/man/Plot.PACF.Rd @@ -40,13 +40,15 @@ Plot.PACF( \item{TimeUnit}{Select from "hour", "day", "week", "month", "quarter", "year"} +\item{MaxLags}{Max value for lags to test} + \item{YVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} \item{AggMethod}{Choose from 'mean', 'sum', 'sd', and 'median'} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{title} @@ -77,10 +79,9 @@ Plot.PACF( \item{ContainLabel}{TRUE} \item{Debug}{Debugging purposes} - -\item{PreAgg}{logical} - -\item{TimeLine}{logical} +} +\value{ +plot } \description{ Build a partial autocorrelation plot by simply passing arguments to a single function diff --git a/man/Plot.Parallel.Rd b/man/Plot.Parallel.Rd index 8a38067..e9a65a4 100644 --- a/man/Plot.Parallel.Rd +++ b/man/Plot.Parallel.Rd @@ -35,6 +35,8 @@ Plot.Parallel( \arguments{ \item{dt}{source data.table} +\item{SampleSize}{Sample size} + \item{CorrVars}{vector of variable names} \item{FacetRows}{Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows} @@ -45,9 +47,9 @@ Plot.Parallel( \item{PreAgg}{logical} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{character} @@ -80,12 +82,9 @@ Plot.Parallel( \item{xaxis.fontSize}{14} \item{Debug}{Debugging purposes} - -\item{xaxis.rotate}{0} - -\item{yaxis.rotate}{0} - -\item{ContainLabel}{TRUE} +} +\value{ +plot } \description{ Build a parallel plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. @@ -128,7 +127,6 @@ AutoPlots::Plot.Parallel( xaxis.fontSize = 14, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.PartialDependence.Box.Rd b/man/Plot.PartialDependence.Box.Rd index f18e586..c591be2 100644 --- a/man/Plot.PartialDependence.Box.Rd +++ b/man/Plot.PartialDependence.Box.Rd @@ -65,6 +65,10 @@ Plot.PartialDependence.Box( \item{AggMethod}{character} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{ShowLabels}{character} @@ -85,6 +89,9 @@ Plot.PartialDependence.Box( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ This function automatically builds partial dependence calibration plots } diff --git a/man/Plot.PartialDependence.HeatMap.Rd b/man/Plot.PartialDependence.HeatMap.Rd index 27faeb9..49628b0 100644 --- a/man/Plot.PartialDependence.HeatMap.Rd +++ b/man/Plot.PartialDependence.HeatMap.Rd @@ -59,6 +59,10 @@ Plot.PartialDependence.HeatMap( \item{AggMethod}{character} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{ShowLabels}{character} @@ -79,6 +83,9 @@ Plot.PartialDependence.HeatMap( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ This function automatically builds partial dependence calibration plots } diff --git a/man/Plot.PartialDependence.Line.Rd b/man/Plot.PartialDependence.Line.Rd index 06f4806..5def3de 100644 --- a/man/Plot.PartialDependence.Line.Rd +++ b/man/Plot.PartialDependence.Line.Rd @@ -59,6 +59,10 @@ Plot.PartialDependence.Line( \item{AggMethod}{character} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{ShowLabels}{character} @@ -79,6 +83,9 @@ Plot.PartialDependence.Line( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ This function automatically builds partial dependence calibration plots } diff --git a/man/Plot.Pie.Rd b/man/Plot.Pie.Rd index 23ea186..bd27d06 100644 --- a/man/Plot.Pie.Rd +++ b/man/Plot.Pie.Rd @@ -59,9 +59,9 @@ Plot.Pie( \item{AggMethod}{Choose from 'mean', 'sum', 'sd', and 'median'} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{title} @@ -94,8 +94,9 @@ Plot.Pie( \item{yaxis.fontSize}{14} \item{Debug}{Debugging purposes} - -\item{BackGroundColor}{color outside of plot window. Rcolors and hex outside of plot window. Rcolors and hex character} +} +\value{ +plot } \description{ Build a pie chart by simply passing arguments to a single function diff --git a/man/Plot.ProbabilityPlot.Rd b/man/Plot.ProbabilityPlot.Rd index 721c38a..04503b9 100644 --- a/man/Plot.ProbabilityPlot.Rd +++ b/man/Plot.ProbabilityPlot.Rd @@ -37,15 +37,15 @@ Plot.ProbabilityPlot( \item{YVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{'Violin Plot'} \item{ShowLabels}{character} -\item{EchartsTheme}{= "macaron"} +\item{EchartsTheme}{"macaron"} \item{TextColor}{'darkblue'} @@ -70,8 +70,9 @@ Plot.ProbabilityPlot( \item{tooltip.trigger}{Default "axis"} \item{Debug}{Debugging purposes} - -\item{TimeLine}{Logical} +} +\value{ +plot } \description{ Build a normal probability plot @@ -106,7 +107,6 @@ AutoPlots::Plot.ProbabilityPlot( tooltip.trigger = "axis", Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.ROC.Rd b/man/Plot.ROC.Rd index e839a81..f9be334 100644 --- a/man/Plot.ROC.Rd +++ b/man/Plot.ROC.Rd @@ -52,6 +52,10 @@ Plot.ROC( \item{AggMethod}{character} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{ShowLabels}{character} @@ -69,8 +73,9 @@ Plot.ROC( \item{TextColor}{character hex} \item{Debug}{Debugging purposes} - -\item{NumberBins}{numeric} +} +\value{ +plot } \description{ ROC Plot diff --git a/man/Plot.Radar.Rd b/man/Plot.Radar.Rd index 3b38738..50838ef 100644 --- a/man/Plot.Radar.Rd +++ b/man/Plot.Radar.Rd @@ -42,9 +42,9 @@ Plot.Radar( \item{YVarTrans}{"Asinh", "Log", "LogPlus1", "Sqrt", "Asin", "Logit", "PercRank", "Standardize", "BoxCox", "YeoJohnson"} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{"Title"} @@ -73,8 +73,9 @@ Plot.Radar( \item{DarkMode}{FALSE} \item{Debug}{Debugging purposes} - -\item{BackGroundColor}{color outside of plot window. Rcolors and hex} +} +\value{ +plot } \description{ Plot.Radar @@ -110,7 +111,6 @@ AutoPlots::Plot.Radar( DarkMode = FALSE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Residuals.Histogram.Rd b/man/Plot.Residuals.Histogram.Rd index 3d01a1a..fd22145 100644 --- a/man/Plot.Residuals.Histogram.Rd +++ b/man/Plot.Residuals.Histogram.Rd @@ -66,6 +66,10 @@ Plot.Residuals.Histogram( \item{NumberBins}{numeric} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{character} \item{ShowLabels}{character} @@ -105,10 +109,9 @@ Plot.Residuals.Histogram( \item{ContainLabel}{TRUE} \item{Debug}{Debugging purposes} - -\item{ZeroLineColor}{character hex} - -\item{ZeroLineWidth}{numeric} +} +\value{ +plot } \description{ Residuals Plot diff --git a/man/Plot.Residuals.Scatter.Rd b/man/Plot.Residuals.Scatter.Rd index b6652c7..a4af6a6 100644 --- a/man/Plot.Residuals.Scatter.Rd +++ b/man/Plot.Residuals.Scatter.Rd @@ -52,6 +52,10 @@ Plot.Residuals.Scatter( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{MouseScroll}{logical, zoom via mouse scroll} \item{Title}{character} @@ -69,8 +73,9 @@ Plot.Residuals.Scatter( \item{TextColor}{"Not Implemented"} \item{Debug}{Debugging purposes} - -\item{NumberBins}{numeric} +} +\value{ +plot } \description{ Residuals_2 Plot diff --git a/man/Plot.River.Rd b/man/Plot.River.Rd index 89fff42..65e1dd3 100644 --- a/man/Plot.River.Rd +++ b/man/Plot.River.Rd @@ -61,9 +61,9 @@ Plot.River( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{"Title"} @@ -100,24 +100,9 @@ Plot.River( \item{yaxis.fontSize}{14} \item{Debug}{Debugging purposes} - -\item{ZeroLineColor}{color} - -\item{ZeroLineWidth}{1} - -\item{BackGroundColor}{color outside of plot window. Rcolors and hex} - -\item{ChartColor}{color} - -\item{FillColor}{color} - -\item{FillColorReverse}{character} - -\item{xaxis.rotate}{0} - -\item{yaxis.rotate}{0} - -\item{ContainLabel}{TRUE} +} +\value{ +plot } \description{ This function automatically builds calibration plots and calibration boxplots for model evaluation using regression, quantile regression, and binary and multinomial classification @@ -143,7 +128,6 @@ AutoPlots::Plot.River( TextColor = "black", EchartsTheme = "macarons") } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Rosetype.Rd b/man/Plot.Rosetype.Rd index 7bfbd43..e23c127 100644 --- a/man/Plot.Rosetype.Rd +++ b/man/Plot.Rosetype.Rd @@ -59,9 +59,9 @@ Plot.Rosetype( \item{AggMethod}{Choose from 'mean', 'sum', 'sd', and 'median'} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{title} @@ -95,6 +95,9 @@ Plot.Rosetype( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a donut plot by simply passing arguments to a single function } @@ -136,7 +139,6 @@ AutoPlots::Plot.Rosetype( yaxis.fontSize = 14, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Scatter.Rd b/man/Plot.Scatter.Rd index 4256fe7..c97724b 100644 --- a/man/Plot.Scatter.Rd +++ b/man/Plot.Scatter.Rd @@ -62,14 +62,16 @@ Plot.Scatter( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{character} \item{ShowLabels}{character} +\item{AddGLM}{logical} + \item{Title.YAxis}{character} \item{Title.XAxis}{character} @@ -104,8 +106,13 @@ Plot.Scatter( \item{ContainLabel}{TRUE} +\item{tooltip.trigger}{"axis"} + \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a copula plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. } @@ -153,7 +160,6 @@ AutoPlots::Plot.Scatter( tooltip.trigger = "axis", Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.Scatter3D.Rd b/man/Plot.Scatter3D.Rd index 119a3d4..115623f 100644 --- a/man/Plot.Scatter3D.Rd +++ b/man/Plot.Scatter3D.Rd @@ -67,9 +67,9 @@ Plot.Scatter3D( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{'Violin Plot'} @@ -101,14 +101,21 @@ Plot.Scatter3D( \item{xaxis.fontSize}{14} +\item{zaxis.fontSize}{14} + \item{xaxis.rotate}{0} \item{yaxis.rotate}{0} +\item{zaxis.rotate}{0} + \item{ContainLabel}{TRUE} \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a 3D-copula plot by simply passing arguments to a single function. It will sample your data using SampleSize number of rows. Sampled data is randomized. } @@ -157,7 +164,6 @@ AutoPlots::Plot.Scatter3D( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.ShapImportance.Rd b/man/Plot.ShapImportance.Rd index 7fc9215..c679efd 100644 --- a/man/Plot.ShapImportance.Rd +++ b/man/Plot.ShapImportance.Rd @@ -30,6 +30,8 @@ Plot.ShapImportance( \arguments{ \item{dt}{source data.table} +\item{PreAgg}{logical} + \item{AggMethod}{"mean", "median", "sum", "sd", "skewness","kurtosis", "coeffvar", "meanabs", "medianabs", "sumabs", "sdabs", "skewnessabs", "kurtosisabs", "CoeffVarabs"} \item{YVar}{Names of shap columns} @@ -48,6 +50,10 @@ Plot.ShapImportance( \item{NumLevels_Y}{= 20} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{"Heatmap"} \item{ShowLabels}{character} @@ -58,8 +64,13 @@ Plot.ShapImportance( \item{EchartsTheme}{"dark-blue"} +\item{TextColor}{character} + \item{Debug}{= FALSE} } +\value{ +plot +} \description{ Plot.ShapImportance variable importance } diff --git a/man/Plot.StackedBar.Rd b/man/Plot.StackedBar.Rd index 05f4201..8ccd300 100644 --- a/man/Plot.StackedBar.Rd +++ b/man/Plot.StackedBar.Rd @@ -107,6 +107,9 @@ Plot.StackedBar( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Build a stacked bar plot vs a grouped bar plot } @@ -152,7 +155,6 @@ AutoPlots::Plot.StackedBar( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.StandardPlots.Rd b/man/Plot.StandardPlots.Rd index d9f9d9c..bf119d3 100644 --- a/man/Plot.StandardPlots.Rd +++ b/man/Plot.StandardPlots.Rd @@ -94,12 +94,19 @@ Plot.StandardPlots( \item{Title.XAxis}{character} +\item{NumLevels_Y}{Numeric} + +\item{NumLevels_X}{Numeric} + \item{TextColor}{character} \item{FontSize}{numeric} \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Helper for standard plots } diff --git a/man/Plot.Step.Rd b/man/Plot.Step.Rd index 16074c7..4d00e39 100644 --- a/man/Plot.Step.Rd +++ b/man/Plot.Step.Rd @@ -70,9 +70,9 @@ Plot.Step( \item{FacetLevels}{Faceting rows x columns is the max number of levels allowed in a grid. If your GroupVar has more you can supply the levels to display.} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{"Title"} @@ -116,6 +116,9 @@ Plot.Step( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ This function automatically builds calibration plots and calibration boxplots for model evaluation using regression, quantile regression, and binary and multinomial classification } @@ -137,7 +140,6 @@ AutoPlots::Plot.Step( GroupVar = NULL, EchartsTheme = "macarons") } - } \seealso{ Other Standard Plots: diff --git a/man/Plot.VariableImportance.Rd b/man/Plot.VariableImportance.Rd index c6eac3f..d446aa6 100644 --- a/man/Plot.VariableImportance.Rd +++ b/man/Plot.VariableImportance.Rd @@ -56,6 +56,10 @@ Plot.VariableImportance( \item{AggMethod}{Choose from 'mean', 'sum', 'sd', and 'median'} +\item{Height}{"400px"} + +\item{Width}{"200px"} + \item{Title}{title} \item{ShowLabels}{character} @@ -87,8 +91,9 @@ Plot.VariableImportance( \item{yaxis.fontSize}{14} \item{Debug}{Debugging purposes} - -\item{MouseScroll}{logical, zoom via mouse scroll} +} +\value{ +plot } \description{ Generate variable importance plots diff --git a/man/Plot.WordCloud.Rd b/man/Plot.WordCloud.Rd index 3015f24..fdaa7d3 100644 --- a/man/Plot.WordCloud.Rd +++ b/man/Plot.WordCloud.Rd @@ -31,9 +31,9 @@ Plot.WordCloud( \item{YVar}{Y-Axis variable name} -\item{Height}{= NULL,} +\item{Height}{"400px"} -\item{Width}{= NULL,} +\item{Width}{"200px"} \item{Title}{= "Density Plot"} @@ -65,6 +65,9 @@ Plot.WordCloud( \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ WordCloud plots } @@ -72,7 +75,7 @@ WordCloud plots \dontrun{ # Create fake data -dt <- AutoPlots::FakeDataGenerator(AddComment = TRUE) +dt <- FakeDataGenerator(AddComment = TRUE) # Create plot AutoPlots::Plot.WordCloud( @@ -96,7 +99,6 @@ AutoPlots::Plot.WordCloud( ContainLabel = TRUE, Debug = FALSE) } - } \seealso{ Other Standard Plots: diff --git a/man/Plots.ModelEvaluation.Rd b/man/Plots.ModelEvaluation.Rd index 0703d2c..07a388e 100644 --- a/man/Plots.ModelEvaluation.Rd +++ b/man/Plots.ModelEvaluation.Rd @@ -48,6 +48,8 @@ Plots.ModelEvaluation( \item{YVar}{Y-Axis variable name} +\item{TargetLevel}{character} + \item{ZVar}{Z-Axis variable name} \item{XVar}{X-Axis variable name} @@ -72,9 +74,17 @@ Plots.ModelEvaluation( \item{MouseScroll}{logical, zoom via mouse scroll} -\item{Height}{= NULL,} +\item{Height}{"400px"} + +\item{Width}{"200px"} + +\item{Title}{character} + +\item{ShowLabels}{logical} -\item{Width}{= NULL,} +\item{Title.YAxis}{character} + +\item{Title.XAxis}{character} \item{EchartsTheme}{"auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland"} @@ -82,10 +92,15 @@ Plots.ModelEvaluation( \item{TextColor}{hex} +\item{FontSize}{numeric} + \item{NumberBins}{numeric} \item{Debug}{Debugging purposes} } +\value{ +plot +} \description{ Plot helper for model evaluation plot types } diff --git a/man/UpdateDocs.Rd b/man/UpdateDocs.Rd deleted file mode 100644 index e07ca98..0000000 --- a/man/UpdateDocs.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{UpdateDocs} -\alias{UpdateDocs} -\title{UpdateDocs} -\usage{ -UpdateDocs(BuildVignette = FALSE, Root = NULL) -} -\description{ -Update helf files and reference manual -} -\seealso{ -Other Utilities: -\code{\link{BuildBinary}()}, -\code{\link{Install}()} -} -\author{ -Adrian Antico -} -\concept{Utilities} diff --git a/vignette/AutoPlots_1.0.0.pdf b/vignette/AutoPlots_1.0.0.pdf deleted file mode 100644 index ca9bb2e..0000000 Binary files a/vignette/AutoPlots_1.0.0.pdf and /dev/null differ