@@ -0,0 +1,11 @@ | |||
/target | |||
/classes | |||
/checkouts | |||
pom.xml | |||
pom.xml.asc | |||
*.jar | |||
*.class | |||
/.lein-* | |||
/.nrepl-port | |||
.hgignore | |||
.hg/ |
@@ -0,0 +1,24 @@ | |||
# Change Log | |||
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). | |||
## [Unreleased] | |||
### Changed | |||
- Add a new arity to `make-widget-async` to provide a different widget shape. | |||
## [0.1.1] - 2021-05-27 | |||
### Changed | |||
- Documentation on how to make the widgets. | |||
### Removed | |||
- `make-widget-sync` - we're all async, all the time. | |||
### Fixed | |||
- Fixed widget maker to keep working when daylight savings switches over. | |||
## 0.1.0 - 2021-05-27 | |||
### Added | |||
- Files from the new template. | |||
- Widget maker public API - `make-widget-sync`. | |||
[Unreleased]: https://github.com/your-name/corrplot/compare/0.1.1...HEAD | |||
[0.1.1]: https://github.com/your-name/corrplot/compare/0.1.0...0.1.1 |
@@ -0,0 +1,277 @@ | |||
Eclipse Public License - v 2.0 | |||
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE | |||
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION | |||
OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. | |||
1. DEFINITIONS | |||
"Contribution" means: | |||
a) in the case of the initial Contributor, the initial content | |||
Distributed under this Agreement, and | |||
b) in the case of each subsequent Contributor: | |||
i) changes to the Program, and | |||
ii) additions to the Program; | |||
where such changes and/or additions to the Program originate from | |||
and are Distributed by that particular Contributor. A Contribution | |||
"originates" from a Contributor if it was added to the Program by | |||
such Contributor itself or anyone acting on such Contributor's behalf. | |||
Contributions do not include changes or additions to the Program that | |||
are not Modified Works. | |||
"Contributor" means any person or entity that Distributes the Program. | |||
"Licensed Patents" mean patent claims licensable by a Contributor which | |||
are necessarily infringed by the use or sale of its Contribution alone | |||
or when combined with the Program. | |||
"Program" means the Contributions Distributed in accordance with this | |||
Agreement. | |||
"Recipient" means anyone who receives the Program under this Agreement | |||
or any Secondary License (as applicable), including Contributors. | |||
"Derivative Works" shall mean any work, whether in Source Code or other | |||
form, that is based on (or derived from) the Program and for which the | |||
editorial revisions, annotations, elaborations, or other modifications | |||
represent, as a whole, an original work of authorship. | |||
"Modified Works" shall mean any work in Source Code or other form that | |||
results from an addition to, deletion from, or modification of the | |||
contents of the Program, including, for purposes of clarity any new file | |||
in Source Code form that contains any contents of the Program. Modified | |||
Works shall not include works that contain only declarations, | |||
interfaces, types, classes, structures, or files of the Program solely | |||
in each case in order to link to, bind by name, or subclass the Program | |||
or Modified Works thereof. | |||
"Distribute" means the acts of a) distributing or b) making available | |||
in any manner that enables the transfer of a copy. | |||
"Source Code" means the form of a Program preferred for making | |||
modifications, including but not limited to software source code, | |||
documentation source, and configuration files. | |||
"Secondary License" means either the GNU General Public License, | |||
Version 2.0, or any later versions of that license, including any | |||
exceptions or additional permissions as identified by the initial | |||
Contributor. | |||
2. GRANT OF RIGHTS | |||
a) Subject to the terms of this Agreement, each Contributor hereby | |||
grants Recipient a non-exclusive, worldwide, royalty-free copyright | |||
license to reproduce, prepare Derivative Works of, publicly display, | |||
publicly perform, Distribute and sublicense the Contribution of such | |||
Contributor, if any, and such Derivative Works. | |||
b) Subject to the terms of this Agreement, each Contributor hereby | |||
grants Recipient a non-exclusive, worldwide, royalty-free patent | |||
license under Licensed Patents to make, use, sell, offer to sell, | |||
import and otherwise transfer the Contribution of such Contributor, | |||
if any, in Source Code or other form. This patent license shall | |||
apply to the combination of the Contribution and the Program if, at | |||
the time the Contribution is added by the Contributor, such addition | |||
of the Contribution causes such combination to be covered by the | |||
Licensed Patents. The patent license shall not apply to any other | |||
combinations which include the Contribution. No hardware per se is | |||
licensed hereunder. | |||
c) Recipient understands that although each Contributor grants the | |||
licenses to its Contributions set forth herein, no assurances are | |||
provided by any Contributor that the Program does not infringe the | |||
patent or other intellectual property rights of any other entity. | |||
Each Contributor disclaims any liability to Recipient for claims | |||
brought by any other entity based on infringement of intellectual | |||
property rights or otherwise. As a condition to exercising the | |||
rights and licenses granted hereunder, each Recipient hereby | |||
assumes sole responsibility to secure any other intellectual | |||
property rights needed, if any. For example, if a third party | |||
patent license is required to allow Recipient to Distribute the | |||
Program, it is Recipient's responsibility to acquire that license | |||
before distributing the Program. | |||
d) Each Contributor represents that to its knowledge it has | |||
sufficient copyright rights in its Contribution, if any, to grant | |||
the copyright license set forth in this Agreement. | |||
e) Notwithstanding the terms of any Secondary License, no | |||
Contributor makes additional grants to any Recipient (other than | |||
those set forth in this Agreement) as a result of such Recipient's | |||
receipt of the Program under the terms of a Secondary License | |||
(if permitted under the terms of Section 3). | |||
3. REQUIREMENTS | |||
3.1 If a Contributor Distributes the Program in any form, then: | |||
a) the Program must also be made available as Source Code, in | |||
accordance with section 3.2, and the Contributor must accompany | |||
the Program with a statement that the Source Code for the Program | |||
is available under this Agreement, and informs Recipients how to | |||
obtain it in a reasonable manner on or through a medium customarily | |||
used for software exchange; and | |||
b) the Contributor may Distribute the Program under a license | |||
different than this Agreement, provided that such license: | |||
i) effectively disclaims on behalf of all other Contributors all | |||
warranties and conditions, express and implied, including | |||
warranties or conditions of title and non-infringement, and | |||
implied warranties or conditions of merchantability and fitness | |||
for a particular purpose; | |||
ii) effectively excludes on behalf of all other Contributors all | |||
liability for damages, including direct, indirect, special, | |||
incidental and consequential damages, such as lost profits; | |||
iii) does not attempt to limit or alter the recipients' rights | |||
in the Source Code under section 3.2; and | |||
iv) requires any subsequent distribution of the Program by any | |||
party to be under a license that satisfies the requirements | |||
of this section 3. | |||
3.2 When the Program is Distributed as Source Code: | |||
a) it must be made available under this Agreement, or if the | |||
Program (i) is combined with other material in a separate file or | |||
files made available under a Secondary License, and (ii) the initial | |||
Contributor attached to the Source Code the notice described in | |||
Exhibit A of this Agreement, then the Program may be made available | |||
under the terms of such Secondary Licenses, and | |||
b) a copy of this Agreement must be included with each copy of | |||
the Program. | |||
3.3 Contributors may not remove or alter any copyright, patent, | |||
trademark, attribution notices, disclaimers of warranty, or limitations | |||
of liability ("notices") contained within the Program from any copy of | |||
the Program which they Distribute, provided that Contributors may add | |||
their own appropriate notices. | |||
4. COMMERCIAL DISTRIBUTION | |||
Commercial distributors of software may accept certain responsibilities | |||
with respect to end users, business partners and the like. While this | |||
license is intended to facilitate the commercial use of the Program, | |||
the Contributor who includes the Program in a commercial product | |||
offering should do so in a manner which does not create potential | |||
liability for other Contributors. Therefore, if a Contributor includes | |||
the Program in a commercial product offering, such Contributor | |||
("Commercial Contributor") hereby agrees to defend and indemnify every | |||
other Contributor ("Indemnified Contributor") against any losses, | |||
damages and costs (collectively "Losses") arising from claims, lawsuits | |||
and other legal actions brought by a third party against the Indemnified | |||
Contributor to the extent caused by the acts or omissions of such | |||
Commercial Contributor in connection with its distribution of the Program | |||
in a commercial product offering. The obligations in this section do not | |||
apply to any claims or Losses relating to any actual or alleged | |||
intellectual property infringement. In order to qualify, an Indemnified | |||
Contributor must: a) promptly notify the Commercial Contributor in | |||
writing of such claim, and b) allow the Commercial Contributor to control, | |||
and cooperate with the Commercial Contributor in, the defense and any | |||
related settlement negotiations. The Indemnified Contributor may | |||
participate in any such claim at its own expense. | |||
For example, a Contributor might include the Program in a commercial | |||
product offering, Product X. That Contributor is then a Commercial | |||
Contributor. If that Commercial Contributor then makes performance | |||
claims, or offers warranties related to Product X, those performance | |||
claims and warranties are such Commercial Contributor's responsibility | |||
alone. Under this section, the Commercial Contributor would have to | |||
defend claims against the other Contributors related to those performance | |||
claims and warranties, and if a court requires any other Contributor to | |||
pay any damages as a result, the Commercial Contributor must pay | |||
those damages. | |||
5. NO WARRANTY | |||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT | |||
PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" | |||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR | |||
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF | |||
TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR | |||
PURPOSE. Each Recipient is solely responsible for determining the | |||
appropriateness of using and distributing the Program and assumes all | |||
risks associated with its exercise of rights under this Agreement, | |||
including but not limited to the risks and costs of program errors, | |||
compliance with applicable laws, damage to or loss of data, programs | |||
or equipment, and unavailability or interruption of operations. | |||
6. DISCLAIMER OF LIABILITY | |||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT | |||
PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS | |||
SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST | |||
PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE | |||
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE | |||
POSSIBILITY OF SUCH DAMAGES. | |||
7. GENERAL | |||
If any provision of this Agreement is invalid or unenforceable under | |||
applicable law, it shall not affect the validity or enforceability of | |||
the remainder of the terms of this Agreement, and without further | |||
action by the parties hereto, such provision shall be reformed to the | |||
minimum extent necessary to make such provision valid and enforceable. | |||
If Recipient institutes patent litigation against any entity | |||
(including a cross-claim or counterclaim in a lawsuit) alleging that the | |||
Program itself (excluding combinations of the Program with other software | |||
or hardware) infringes such Recipient's patent(s), then such Recipient's | |||
rights granted under Section 2(b) shall terminate as of the date such | |||
litigation is filed. | |||
All Recipient's rights under this Agreement shall terminate if it | |||
fails to comply with any of the material terms or conditions of this | |||
Agreement and does not cure such failure in a reasonable period of | |||
time after becoming aware of such noncompliance. If all Recipient's | |||
rights under this Agreement terminate, Recipient agrees to cease use | |||
and distribution of the Program as soon as reasonably practicable. | |||
However, Recipient's obligations under this Agreement and any licenses | |||
granted by Recipient relating to the Program shall continue and survive. | |||
Everyone is permitted to copy and distribute copies of this Agreement, | |||
but in order to avoid inconsistency the Agreement is copyrighted and | |||
may only be modified in the following manner. The Agreement Steward | |||
reserves the right to publish new versions (including revisions) of | |||
this Agreement from time to time. No one other than the Agreement | |||
Steward has the right to modify this Agreement. The Eclipse Foundation | |||
is the initial Agreement Steward. The Eclipse Foundation may assign the | |||
responsibility to serve as the Agreement Steward to a suitable separate | |||
entity. Each new version of the Agreement will be given a distinguishing | |||
version number. The Program (including Contributions) may always be | |||
Distributed subject to the version of the Agreement under which it was | |||
received. In addition, after a new version of the Agreement is published, | |||
Contributor may elect to Distribute the Program (including its | |||
Contributions) under the new version. | |||
Except as expressly stated in Sections 2(a) and 2(b) above, Recipient | |||
receives no rights or licenses to the intellectual property of any | |||
Contributor under this Agreement, whether expressly, by implication, | |||
estoppel or otherwise. All rights in the Program not expressly granted | |||
under this Agreement are reserved. Nothing in this Agreement is intended | |||
to be enforceable by any entity that is not a Contributor or Recipient. | |||
No third-party beneficiary rights are created under this Agreement. | |||
Exhibit A - Form of Secondary Licenses Notice | |||
"This Source Code may also be made available under the following | |||
Secondary Licenses when the conditions for such availability set forth | |||
in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), | |||
version(s), and exceptions or additional permissions here}." | |||
Simply including a copy of this Agreement, including this Exhibit A | |||
is not sufficient to license the Source Code under Secondary Licenses. | |||
If it is not possible or desirable to put the notice in a particular | |||
file, then You may include the notice in a location (such as a LICENSE | |||
file in a relevant directory) where a recipient would be likely to | |||
look for such a notice. | |||
You may add additional accurate notices of copyright ownership. |
@@ -0,0 +1,42 @@ | |||
# corrplot | |||
FIXME: description | |||
## Installation | |||
Download from http://example.com/FIXME. | |||
## Usage | |||
FIXME: explanation | |||
## Options | |||
FIXME: listing of options this app accepts. | |||
## Examples | |||
... | |||
### Bugs | |||
... | |||
### Any Other Sections | |||
### That You Think | |||
### Might be Useful | |||
## License | |||
Copyright © 2021 FIXME | |||
This program and the accompanying materials are made available under the | |||
terms of the Eclipse Public License 2.0 which is available at | |||
http://www.eclipse.org/legal/epl-2.0. | |||
This Source Code may also be made available under the following Secondary | |||
Licenses when the conditions for such availability set forth in the Eclipse | |||
Public License, v. 2.0 are satisfied: GNU General Public License as published by | |||
the Free Software Foundation, either version 2 of the License, or (at your | |||
option) any later version, with the GNU Classpath Exception which is available | |||
at https://www.gnu.org/software/classpath/license.html. |
@@ -0,0 +1,3 @@ | |||
# Introduction to corrplot | |||
TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) |
@@ -0,0 +1,26 @@ | |||
(defproject tservice-plugins/corrplot "v0.1.0" | |||
:description "FIXME: write description" | |||
:url "https://github.com/tservice-plugins/corrplot" | |||
:license {:name "Eclipse Public License" | |||
:url "http://www.eclipse.org/legal/epl-v10.html"} | |||
:min-lein-version "2.5.0" | |||
:deployable false | |||
:dependencies | |||
[[org.clojure/tools.logging "1.1.0"] | |||
[selmer "1.12.27"]] | |||
:profiles | |||
{:provided | |||
{:dependencies | |||
[[org.clojure/clojure "1.10.1"] | |||
[org.clojars.yjcyxky/tservice "0.6.0"]]} | |||
:uberjar | |||
{:auto-clean true | |||
:aot :all | |||
:omit-source true | |||
:javac-options ["-target" "1.8", "-source" "1.8"] | |||
:target-path "target/%s" | |||
:resource-paths ["resources"] | |||
:uberjar-name "corrplot.tservice-plugin.jar"}}) |
@@ -0,0 +1 @@ | |||
source("renv/activate.R") |
@@ -0,0 +1,74 @@ | |||
#!/usr/bin/env Rscript | |||
# For more information, please see https://plot.ly/r/shinyapp-explore-diamonds/ | |||
library(configr) | |||
library(ggplot2) | |||
library(plotly) | |||
library(dplyr) | |||
library(ggcorrplot) | |||
library(RColorBrewer) | |||
read_json <- function(jsonfile) { | |||
return(read.config(jsonfile)) | |||
} | |||
getColors <- function(n, dataType = "seq") { | |||
allChoices <- brewer.pal.info | |||
availableChoices <- allChoices[allChoices$maxcolors > n & allChoices$category == dataType,] | |||
if (dim(availableChoices)[1] != 0) { | |||
colorPal <- sample(rownames(availableChoices), size = 1) | |||
if (n <= 3) { | |||
options <- brewer.pal(3, colorPal) | |||
return(options[1:n]) | |||
} else { | |||
return(brewer.pal(n, colorPal)) | |||
} | |||
} else { | |||
return(NULL) | |||
} | |||
} | |||
getLen <- function(x) { | |||
return(length(unique(x))) | |||
} | |||
make_corrplot <- function(args_json) { | |||
input <- read_json(args_json) | |||
data <- read.csv(input$datafile) | |||
colors <- getColors(3, "div") | |||
result <- cor(data[, input$corr_vars]) | |||
# build graph with ggplot syntax | |||
p <- ggcorrplot(result, method = input$method, type = input$corr_type, | |||
show.diag = TRUE, colors = colors, | |||
outline.col = "white", hc.order = input$hc_order, | |||
hc.method = input$hc_method, lab = TRUE, | |||
lab_col = "black", lab_size = 4, p.mat = NULL, | |||
sig.level = input$sig_level, title = input$title, | |||
show.legend = TRUE, legend.title = "", insig = "pch", | |||
ggtheme = ggplot2::theme_gray, pch = 4, pch.col = "black") + | |||
theme(axis.text.x = element_text(angle = 0, hjust = 1, margin = margin(-3, 0, 0, 0), | |||
size = 11), | |||
axis.text.y = element_text(size = 11, | |||
margin = margin(0, -3, 0, 0)), | |||
text = element_text(size = input$corrplot_title_size), | |||
legend.text = element_text(size = 11), | |||
legend.title = element_blank(), | |||
panel.background = element_blank(), | |||
panel.grid.major = element_blank(), | |||
axis.line = element_line(colour = "black")) | |||
return(ggplotly(p)) | |||
} | |||
write_json <- function(plotly_object, output_file) { | |||
json <- plotly::plotly_json(plotly_object, FALSE) | |||
write(json, output_file) | |||
} | |||
corrplot <- function(args_json, output_file) { | |||
plotly_object <- make_corrplot(args_json) | |||
write_json(plotly_object, output_file) | |||
} |
@@ -0,0 +1,99 @@ | |||
#!/usr/bin/env bash | |||
# A wrapper for corrplot r function | |||
# | |||
# Author: Jingcheng Yang | |||
# Email: yjcyxky@163.com | |||
# | |||
# License: MIT | |||
# Exit on error. Append "|| true" if you expect an error. | |||
# set -o errexit | |||
# Exit on error inside any functions or subshells. | |||
# set -o errtrace | |||
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR | |||
set -o nounset | |||
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip` | |||
set -o pipefail | |||
# Turn on traces, useful while debugging but commented out by default | |||
# set -o xtrace | |||
show_help() { | |||
cat <<EOF | |||
usage: $(echo $0) [-d <INPUT_FILE>] [-o <OUTPUT_FILE>] | |||
-i INPUT_FILE An argument json file. | |||
-o OUTPUT_FILE A plotly json file. | |||
EOF | |||
} | |||
while getopts ":hi:o:" arg; do | |||
case "$arg" in | |||
"i") | |||
INPUT_FILE="$OPTARG" | |||
;; | |||
"o") | |||
OUTPUT_FILE="$OPTARG" | |||
;; | |||
"?") | |||
echo "Unkown option: $OPTARG" | |||
exit 1 | |||
;; | |||
":") | |||
echo "No argument value for option $OPTARG" | |||
;; | |||
h) | |||
show_help | |||
exit 0 | |||
;; | |||
*) | |||
echo "Unknown error while processing options" | |||
show_help | |||
exit 1 | |||
;; | |||
esac | |||
done | |||
if [ -z "$INPUT_FILE" ]; then | |||
echo "-i argument is not specified." | |||
exit 1 | |||
elif [ ! -f "$INPUT_FILE" ]; then | |||
echo "$INPUT_FILE is not a valid file." | |||
exit 1 | |||
else | |||
INPUT_FILE=$(realpath $INPUT_FILE) | |||
fi | |||
if [ -z "$OUTPUT_FILE" ]; then | |||
echo "-o argument is not specified." | |||
exit 1 | |||
elif [ ! -f "$OUTPUT_FILE" ]; then | |||
echo "$OUTPUT_FILE is not a valid file." | |||
exit 1 | |||
else | |||
OUTPUT_FILE=$(realpath $OUTPUT_FILE) | |||
fi | |||
TEMP=$(mktemp) | |||
echo "Run script: $TEMP" | |||
SCRIPT_DIR=`realpath $(dirname $0)` | |||
cat <<EOF >"$TEMP" | |||
#!/usr/bin/env Rscript | |||
run <- function() { | |||
# Print traceback message | |||
on.exit(traceback()) | |||
source("${SCRIPT_DIR}/corrplot.R") | |||
corrplot("${INPUT_FILE}", "${OUTPUT_FILE}") | |||
} | |||
run() | |||
EOF | |||
printf "\n---------------------\n" | |||
cat "$TEMP" | |||
echo "---------------------" | |||
Rscript $TEMP |
@@ -0,0 +1,22 @@ | |||
{ | |||
"datafile": "./examples/data.csv", | |||
"corr_vars": [ | |||
"mpg", | |||
"cyl", | |||
"disp", | |||
"hp", | |||
"drat", | |||
"wt", | |||
"qsec", | |||
"vs", | |||
"am", | |||
"gear", | |||
"carb" | |||
], | |||
"method": "square", | |||
"corr_type": "full", | |||
"hc_method": "complete", | |||
"hc_order": true, | |||
"sig_level": 0.05, | |||
"title": "This is a test." | |||
} |
@@ -0,0 +1,33 @@ | |||
name,mpg,cyl,disp,hp,drat,wt,qsec,vs,am,gear,carb | |||
Mazda RX4,21,6,160,110,3.9,2.62,16.46,0,1,4,4 | |||
Mazda RX4 Wag,21,6,160,110,3.9,2.875,17.02,0,1,4,4 | |||
Datsun 710,22.8,4,108,93,3.85,2.32,18.61,1,1,4,1 | |||
Hornet 4 Drive,21.4,6,258,110,3.08,3.215,19.44,1,0,3,1 | |||
Hornet Sportabout,18.7,8,360,175,3.15,3.44,17.02,0,0,3,2 | |||
Valiant,18.1,6,225,105,2.76,3.46,20.22,1,0,3,1 | |||
Duster 360,14.3,8,360,245,3.21,3.57,15.84,0,0,3,4 | |||
Merc 240D,24.4,4,146.7,62,3.69,3.19,20,1,0,4,2 | |||
Merc 230,22.8,4,140.8,95,3.92,3.15,22.9,1,0,4,2 | |||
Merc 280,19.2,6,167.6,123,3.92,3.44,18.3,1,0,4,4 | |||
Merc 280C,17.8,6,167.6,123,3.92,3.44,18.9,1,0,4,4 | |||
Merc 450SE,16.4,8,275.8,180,3.07,4.07,17.4,0,0,3,3 | |||
Merc 450SL,17.3,8,275.8,180,3.07,3.73,17.6,0,0,3,3 | |||
Merc 450SLC,15.2,8,275.8,180,3.07,3.78,18,0,0,3,3 | |||
Cadillac Fleetwood,10.4,8,472,205,2.93,5.25,17.98,0,0,3,4 | |||
Lincoln Continental,10.4,8,460,215,3,5.424,17.82,0,0,3,4 | |||
Chrysler Imperial,14.7,8,440,230,3.23,5.345,17.42,0,0,3,4 | |||
Fiat 128,32.4,4,78.7,66,4.08,2.2,19.47,1,1,4,1 | |||
Honda Civic,30.4,4,75.7,52,4.93,1.615,18.52,1,1,4,2 | |||
Toyota Corolla,33.9,4,71.1,65,4.22,1.835,19.9,1,1,4,1 | |||
Toyota Corona,21.5,4,120.1,97,3.7,2.465,20.01,1,0,3,1 | |||
Dodge Challenger,15.5,8,318,150,2.76,3.52,16.87,0,0,3,2 | |||
AMC Javelin,15.2,8,304,150,3.15,3.435,17.3,0,0,3,2 | |||
Camaro Z28,13.3,8,350,245,3.73,3.84,15.41,0,0,3,4 | |||
Pontiac Firebird,19.2,8,400,175,3.08,3.845,17.05,0,0,3,2 | |||
Fiat X1-9,27.3,4,79,66,4.08,1.935,18.9,1,1,4,1 | |||
Porsche 914-2,26,4,120.3,91,4.43,2.14,16.7,0,1,5,2 | |||
Lotus Europa,30.4,4,95.1,113,3.77,1.513,16.9,1,1,5,2 | |||
Ford Pantera L,15.8,8,351,264,4.22,3.17,14.5,0,1,5,4 | |||
Ferrari Dino,19.7,6,145,175,3.62,2.77,15.5,0,1,5,6 | |||
Maserati Bora,15,8,301,335,3.54,3.57,14.6,0,1,5,8 | |||
Volvo 142E,21.4,4,121,109,4.11,2.78,18.6,1,1,4,2 |
@@ -0,0 +1,468 @@ | |||
{ | |||
"R": { | |||
"Version": "3.6.3", | |||
"Repositories": [ | |||
{ | |||
"Name": "CRAN", | |||
"URL": "https://cloud.r-project.org" | |||
} | |||
] | |||
}, | |||
"Packages": { | |||
"MASS": { | |||
"Package": "MASS", | |||
"Version": "7.3-51.5", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "9efe80472b21189ebab1b74169808c26" | |||
}, | |||
"Matrix": { | |||
"Package": "Matrix", | |||
"Version": "1.2-18", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "08588806cba69f04797dab50627428ed" | |||
}, | |||
"R6": { | |||
"Package": "R6", | |||
"Version": "2.5.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "470851b6d5d0ac559e9d01bb352b4021" | |||
}, | |||
"RColorBrewer": { | |||
"Package": "RColorBrewer", | |||
"Version": "1.1-2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "e031418365a7f7a766181ab5a41a5716" | |||
}, | |||
"Rcpp": { | |||
"Package": "Rcpp", | |||
"Version": "1.0.7", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "dab19adae4440ae55aa8a9d238b246bb" | |||
}, | |||
"RcppTOML": { | |||
"Package": "RcppTOML", | |||
"Version": "0.1.7", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "f8a578aa91321ecec1292f1e2ffadeda" | |||
}, | |||
"askpass": { | |||
"Package": "askpass", | |||
"Version": "1.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "e8a22846fff485f0be3770c2da758713" | |||
}, | |||
"base64enc": { | |||
"Package": "base64enc", | |||
"Version": "0.1-3", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "543776ae6848fde2f48ff3816d0628bc" | |||
}, | |||
"cli": { | |||
"Package": "cli", | |||
"Version": "3.0.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "e3ae5d68dea0c55a12ea12a9fda02e61" | |||
}, | |||
"colorspace": { | |||
"Package": "colorspace", | |||
"Version": "2.0-2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "6baccb763ee83c0bd313460fdb8b8a84" | |||
}, | |||
"configr": { | |||
"Package": "configr", | |||
"Version": "0.3.5", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "27bf543086066d25a38ed9fe26fa2ad8" | |||
}, | |||
"cpp11": { | |||
"Package": "cpp11", | |||
"Version": "0.4.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "40ba3fd26c8f61d8d14d334bc7761df9" | |||
}, | |||
"crayon": { | |||
"Package": "crayon", | |||
"Version": "1.4.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "e75525c55c70e5f4f78c9960a4b402e9" | |||
}, | |||
"crosstalk": { | |||
"Package": "crosstalk", | |||
"Version": "1.1.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "2b06f9e415a62b6762e4b8098d2aecbc" | |||
}, | |||
"curl": { | |||
"Package": "curl", | |||
"Version": "4.3.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "022c42d49c28e95d69ca60446dbabf88" | |||
}, | |||
"data.table": { | |||
"Package": "data.table", | |||
"Version": "1.14.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "36b67b5adf57b292923f5659f5f0c853" | |||
}, | |||
"digest": { | |||
"Package": "digest", | |||
"Version": "0.6.28", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "49b5c6e230bfec487b8917d5a0c77cca" | |||
}, | |||
"dplyr": { | |||
"Package": "dplyr", | |||
"Version": "1.0.7", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "36f1ae62f026c8ba9f9b5c9a08c03297" | |||
}, | |||
"ellipsis": { | |||
"Package": "ellipsis", | |||
"Version": "0.3.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" | |||
}, | |||
"fansi": { | |||
"Package": "fansi", | |||
"Version": "0.5.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "d447b40982c576a72b779f0a3b3da227" | |||
}, | |||
"farver": { | |||
"Package": "farver", | |||
"Version": "2.1.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "c98eb5133d9cb9e1622b8691487f11bb" | |||
}, | |||
"fastmap": { | |||
"Package": "fastmap", | |||
"Version": "1.1.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "77bd60a6157420d4ffa93b27cf6a58b8" | |||
}, | |||
"generics": { | |||
"Package": "generics", | |||
"Version": "0.1.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "4d243a9c10b00589889fe32314ffd902" | |||
}, | |||
"ggcorrplot": { | |||
"Package": "ggcorrplot", | |||
"Version": "0.1.3", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "5d6f67b947e0962cf93208f139acd475" | |||
}, | |||
"ggplot2": { | |||
"Package": "ggplot2", | |||
"Version": "3.3.5", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "d7566c471c7b17e095dd023b9ef155ad" | |||
}, | |||
"glue": { | |||
"Package": "glue", | |||
"Version": "1.4.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "6efd734b14c6471cfe443345f3e35e29" | |||
}, | |||
"gtable": { | |||
"Package": "gtable", | |||
"Version": "0.3.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "ac5c6baf7822ce8732b343f14c072c4d" | |||
}, | |||
"htmltools": { | |||
"Package": "htmltools", | |||
"Version": "0.5.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "526c484233f42522278ab06fb185cb26" | |||
}, | |||
"htmlwidgets": { | |||
"Package": "htmlwidgets", | |||
"Version": "1.5.4", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "76147821cd3fcd8c4b04e1ef0498e7fb" | |||
}, | |||
"httr": { | |||
"Package": "httr", | |||
"Version": "1.4.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "a525aba14184fec243f9eaec62fbed43" | |||
}, | |||
"ini": { | |||
"Package": "ini", | |||
"Version": "0.3.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "6154ec2223172bce8162d4153cda21f7" | |||
}, | |||
"isoband": { | |||
"Package": "isoband", | |||
"Version": "0.2.5", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "7ab57a6de7f48a8dc84910d1eca42883" | |||
}, | |||
"jsonlite": { | |||
"Package": "jsonlite", | |||
"Version": "1.7.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "98138e0994d41508c7a6b84a0600cfcb" | |||
}, | |||
"labeling": { | |||
"Package": "labeling", | |||
"Version": "0.4.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "3d5108641f47470611a32d0bdf357a72" | |||
}, | |||
"later": { | |||
"Package": "later", | |||
"Version": "1.2.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "b61890ae77fea19fc8acadd25db70aa4" | |||
}, | |||
"lattice": { | |||
"Package": "lattice", | |||
"Version": "0.20-38", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "848f8c593fd1050371042d18d152e3d7" | |||
}, | |||
"lazyeval": { | |||
"Package": "lazyeval", | |||
"Version": "0.2.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "d908914ae53b04d4c0c0fd72ecc35370" | |||
}, | |||
"lifecycle": { | |||
"Package": "lifecycle", | |||
"Version": "1.0.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "a6b6d352e3ed897373ab19d8395c98d0" | |||
}, | |||
"magrittr": { | |||
"Package": "magrittr", | |||
"Version": "2.0.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "41287f1ac7d28a92f0a286ed507928d3" | |||
}, | |||
"mgcv": { | |||
"Package": "mgcv", | |||
"Version": "1.8-31", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "4bb7e0c4f3557583e1e8d3c9ffb8ba5c" | |||
}, | |||
"mime": { | |||
"Package": "mime", | |||
"Version": "0.11", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "8974a907200fc9948d636fe7d85ca9fb" | |||
}, | |||
"munsell": { | |||
"Package": "munsell", | |||
"Version": "0.5.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "6dfe8bf774944bd5595785e3229d8771" | |||
}, | |||
"nlme": { | |||
"Package": "nlme", | |||
"Version": "3.1-144", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "e80d41932d3cc235ccbbbb9732ae162e" | |||
}, | |||
"openssl": { | |||
"Package": "openssl", | |||
"Version": "1.4.5", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "5406fd37ef0bf9b88c8a4f264d6ec220" | |||
}, | |||
"pillar": { | |||
"Package": "pillar", | |||
"Version": "1.6.3", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "3323bc1a0988d63b5c65771ba0d3935d" | |||
}, | |||
"pkgconfig": { | |||
"Package": "pkgconfig", | |||
"Version": "2.0.3", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "01f28d4278f15c76cddbea05899c5d6f" | |||
}, | |||
"plotly": { | |||
"Package": "plotly", | |||
"Version": "4.9.4.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "af4b92cb3828aa30002e2f945c49c2d7" | |||
}, | |||
"plyr": { | |||
"Package": "plyr", | |||
"Version": "1.8.6", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "ec0e5ab4e5f851f6ef32cd1d1984957f" | |||
}, | |||
"promises": { | |||
"Package": "promises", | |||
"Version": "1.2.0.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "4ab2c43adb4d4699cf3690acd378d75d" | |||
}, | |||
"purrr": { | |||
"Package": "purrr", | |||
"Version": "0.3.4", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "97def703420c8ab10d8f0e6c72101e02" | |||
}, | |||
"renv": { | |||
"Package": "renv", | |||
"Version": "0.13.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "9f10d9db5b50400c348920c5c603385e" | |||
}, | |||
"reshape2": { | |||
"Package": "reshape2", | |||
"Version": "1.4.4", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "bb5996d0bd962d214a11140d77589917" | |||
}, | |||
"rlang": { | |||
"Package": "rlang", | |||
"Version": "0.4.11", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "515f341d3affe0de9e4a7f762efb0456" | |||
}, | |||
"scales": { | |||
"Package": "scales", | |||
"Version": "1.1.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "6f76f71042411426ec8df6c54f34e6dd" | |||
}, | |||
"stringi": { | |||
"Package": "stringi", | |||
"Version": "1.7.4", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "ebaccb577da50829a3bb1b8296f318a5" | |||
}, | |||
"stringr": { | |||
"Package": "stringr", | |||
"Version": "1.4.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "0759e6b6c0957edb1311028a49a35e76" | |||
}, | |||
"sys": { | |||
"Package": "sys", | |||
"Version": "3.4", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "b227d13e29222b4574486cfcbde077fa" | |||
}, | |||
"tibble": { | |||
"Package": "tibble", | |||
"Version": "3.1.4", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "5e8ad5621e5c94b24ec07b88eee13df8" | |||
}, | |||
"tidyr": { | |||
"Package": "tidyr", | |||
"Version": "1.1.4", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "c8fbdbd9fcac223d6c6fe8e406f368e1" | |||
}, | |||
"tidyselect": { | |||
"Package": "tidyselect", | |||
"Version": "1.1.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "7243004a708d06d4716717fa1ff5b2fe" | |||
}, | |||
"utf8": { | |||
"Package": "utf8", | |||
"Version": "1.2.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "c9c462b759a5cc844ae25b5942654d13" | |||
}, | |||
"vctrs": { | |||
"Package": "vctrs", | |||
"Version": "0.3.8", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "ecf749a1b39ea72bd9b51b76292261f1" | |||
}, | |||
"viridisLite": { | |||
"Package": "viridisLite", | |||
"Version": "0.4.0", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "55e157e2aa88161bdb0754218470d204" | |||
}, | |||
"withr": { | |||
"Package": "withr", | |||
"Version": "2.4.2", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "ad03909b44677f930fa156d47d7a3aeb" | |||
}, | |||
"yaml": { | |||
"Package": "yaml", | |||
"Version": "2.2.1", | |||
"Source": "Repository", | |||
"Repository": "CRAN", | |||
"Hash": "2826c5d9efb0a88f657c7a679c7106db" | |||
} | |||
} | |||
} |
@@ -0,0 +1,5 @@ | |||
library/ | |||
local/ | |||
lock/ | |||
python/ | |||
staging/ |
@@ -0,0 +1,653 @@ | |||
local({ | |||
# the requested version of renv | |||
version <- "0.13.0" | |||
# the project directory | |||
project <- getwd() | |||
# avoid recursion | |||
if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) | |||
return(invisible(TRUE)) | |||
# signal that we're loading renv during R startup | |||
Sys.setenv("RENV_R_INITIALIZING" = "true") | |||
on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE) | |||
# signal that we've consented to use renv | |||
options(renv.consent = TRUE) | |||
# load the 'utils' package eagerly -- this ensures that renv shims, which | |||
# mask 'utils' packages, will come first on the search path | |||
library(utils, lib.loc = .Library) | |||
# check to see if renv has already been loaded | |||
if ("renv" %in% loadedNamespaces()) { | |||
# if renv has already been loaded, and it's the requested version of renv, | |||
# nothing to do | |||
spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") | |||
if (identical(spec[["version"]], version)) | |||
return(invisible(TRUE)) | |||
# otherwise, unload and attempt to load the correct version of renv | |||
unloadNamespace("renv") | |||
} | |||
# load bootstrap tools | |||
bootstrap <- function(version, library) { | |||
# attempt to download renv | |||
tarball <- tryCatch(renv_bootstrap_download(version), error = identity) | |||
if (inherits(tarball, "error")) | |||
stop("failed to download renv ", version) | |||
# now attempt to install | |||
status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) | |||
if (inherits(status, "error")) | |||
stop("failed to install renv ", version) | |||
} | |||
renv_bootstrap_tests_running <- function() { | |||
getOption("renv.tests.running", default = FALSE) | |||
} | |||
renv_bootstrap_repos <- function() { | |||
# check for repos override | |||
repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) | |||
if (!is.na(repos)) | |||
return(repos) | |||
# if we're testing, re-use the test repositories | |||
if (renv_bootstrap_tests_running()) | |||
return(getOption("renv.tests.repos")) | |||
# retrieve current repos | |||
repos <- getOption("repos") | |||
# ensure @CRAN@ entries are resolved | |||
repos[repos == "@CRAN@"] <- "https://cloud.r-project.org" | |||
# add in renv.bootstrap.repos if set | |||
default <- c(FALLBACK = "https://cloud.r-project.org") | |||
extra <- getOption("renv.bootstrap.repos", default = default) | |||
repos <- c(repos, extra) | |||
# remove duplicates that might've snuck in | |||
dupes <- duplicated(repos) | duplicated(names(repos)) | |||
repos[!dupes] | |||
} | |||
renv_bootstrap_download <- function(version) { | |||
# if the renv version number has 4 components, assume it must | |||
# be retrieved via github | |||
nv <- numeric_version(version) | |||
components <- unclass(nv)[[1]] | |||
methods <- if (length(components) == 4L) { | |||
list( | |||
renv_bootstrap_download_github | |||
) | |||
} else { | |||
list( | |||
renv_bootstrap_download_cran_latest, | |||
renv_bootstrap_download_cran_archive | |||
) | |||
} | |||
for (method in methods) { | |||
path <- tryCatch(method(version), error = identity) | |||
if (is.character(path) && file.exists(path)) | |||
return(path) | |||
} | |||
stop("failed to download renv ", version) | |||
} | |||
renv_bootstrap_download_impl <- function(url, destfile) { | |||
mode <- "wb" | |||
# https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 | |||
fixup <- | |||
Sys.info()[["sysname"]] == "Windows" && | |||
substring(url, 1L, 5L) == "file:" | |||
if (fixup) | |||
mode <- "w+b" | |||
utils::download.file( | |||
url = url, | |||
destfile = destfile, | |||
mode = mode, | |||
quiet = TRUE | |||
) | |||
} | |||
renv_bootstrap_download_cran_latest <- function(version) { | |||
repos <- renv_bootstrap_download_cran_latest_find(version) | |||
message("* Downloading renv ", version, " ... ", appendLF = FALSE) | |||
downloader <- function(type) { | |||
tryCatch( | |||
utils::download.packages( | |||
pkgs = "renv", | |||
destdir = tempdir(), | |||
repos = repos, | |||
type = type, | |||
quiet = TRUE | |||
), | |||
condition = identity | |||
) | |||
} | |||
# first, try downloading a binary on Windows + macOS if appropriate | |||
binary <- | |||
!identical(.Platform$pkgType, "source") && | |||
!identical(getOption("pkgType"), "source") && | |||
Sys.info()[["sysname"]] %in% c("Darwin", "Windows") | |||
if (binary) { | |||
info <- downloader(type = "binary") | |||
if (!inherits(info, "condition")) { | |||
message("OK (downloaded binary)") | |||
return(info[1, 2]) | |||
} | |||
} | |||
# otherwise, try downloading a source tarball | |||
info <- downloader(type = "source") | |||
if (inherits(info, "condition")) { | |||
message("FAILED") | |||
return(FALSE) | |||
} | |||
# report success and return | |||
message("OK (downloaded source)") | |||
info[1, 2] | |||
} | |||
renv_bootstrap_download_cran_latest_find <- function(version) { | |||
all <- renv_bootstrap_repos() | |||
for (repos in all) { | |||
db <- tryCatch( | |||
as.data.frame( | |||
x = utils::available.packages(repos = repos), | |||
stringsAsFactors = FALSE | |||
), | |||
error = identity | |||
) | |||
if (inherits(db, "error")) | |||
next | |||
entry <- db[db$Package %in% "renv" & db$Version %in% version, ] | |||
if (nrow(entry) == 0) | |||
next | |||
return(repos) | |||
} | |||
fmt <- "renv %s is not available from your declared package repositories" | |||
stop(sprintf(fmt, version)) | |||
} | |||
renv_bootstrap_download_cran_archive <- function(version) { | |||
name <- sprintf("renv_%s.tar.gz", version) | |||
repos <- renv_bootstrap_repos() | |||
urls <- file.path(repos, "src/contrib/Archive/renv", name) | |||
destfile <- file.path(tempdir(), name) | |||
message("* Downloading renv ", version, " ... ", appendLF = FALSE) | |||
for (url in urls) { | |||
status <- tryCatch( | |||
renv_bootstrap_download_impl(url, destfile), | |||
condition = identity | |||
) | |||
if (identical(status, 0L)) { | |||
message("OK") | |||
return(destfile) | |||
} | |||
} | |||
message("FAILED") | |||
return(FALSE) | |||
} | |||
renv_bootstrap_download_github <- function(version) { | |||
enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") | |||
if (!identical(enabled, "TRUE")) | |||
return(FALSE) | |||
# prepare download options | |||
pat <- Sys.getenv("GITHUB_PAT") | |||
if (nzchar(Sys.which("curl")) && nzchar(pat)) { | |||
fmt <- "--location --fail --header \"Authorization: token %s\"" | |||
extra <- sprintf(fmt, pat) | |||
saved <- options("download.file.method", "download.file.extra") | |||
options(download.file.method = "curl", download.file.extra = extra) | |||
on.exit(do.call(base::options, saved), add = TRUE) | |||
} else if (nzchar(Sys.which("wget")) && nzchar(pat)) { | |||
fmt <- "--header=\"Authorization: token %s\"" | |||
extra <- sprintf(fmt, pat) | |||
saved <- options("download.file.method", "download.file.extra") | |||
options(download.file.method = "wget", download.file.extra = extra) | |||
on.exit(do.call(base::options, saved), add = TRUE) | |||
} | |||
message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) | |||
url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) | |||
name <- sprintf("renv_%s.tar.gz", version) | |||
destfile <- file.path(tempdir(), name) | |||
status <- tryCatch( | |||
renv_bootstrap_download_impl(url, destfile), | |||
condition = identity | |||
) | |||
if (!identical(status, 0L)) { | |||
message("FAILED") | |||
return(FALSE) | |||
} | |||
message("OK") | |||
return(destfile) | |||
} | |||
renv_bootstrap_install <- function(version, tarball, library) { | |||
# attempt to install it into project library | |||
message("* Installing renv ", version, " ... ", appendLF = FALSE) | |||
dir.create(library, showWarnings = FALSE, recursive = TRUE) | |||
# invoke using system2 so we can capture and report output | |||
bin <- R.home("bin") | |||
exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" | |||
r <- file.path(bin, exe) | |||
args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) | |||
output <- system2(r, args, stdout = TRUE, stderr = TRUE) | |||
message("Done!") | |||
# check for successful install | |||
status <- attr(output, "status") | |||
if (is.numeric(status) && !identical(status, 0L)) { | |||
header <- "Error installing renv:" | |||
lines <- paste(rep.int("=", nchar(header)), collapse = "") | |||
text <- c(header, lines, output) | |||
writeLines(text, con = stderr()) | |||
} | |||
status | |||
} | |||
renv_bootstrap_platform_prefix <- function() { | |||
# construct version prefix | |||
version <- paste(R.version$major, R.version$minor, sep = ".") | |||
prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") | |||
# include SVN revision for development versions of R | |||
# (to avoid sharing platform-specific artefacts with released versions of R) | |||
devel <- | |||
identical(R.version[["status"]], "Under development (unstable)") || | |||
identical(R.version[["nickname"]], "Unsuffered Consequences") | |||
if (devel) | |||
prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") | |||
# build list of path components | |||
components <- c(prefix, R.version$platform) | |||
# include prefix if provided by user | |||
prefix <- renv_bootstrap_platform_prefix_impl() | |||
if (!is.na(prefix) && nzchar(prefix)) | |||
components <- c(prefix, components) | |||
# build prefix | |||
paste(components, collapse = "/") | |||
} | |||
renv_bootstrap_platform_prefix_impl <- function() { | |||
# if an explicit prefix has been supplied, use it | |||
prefix <- Sys.getenv("RENV_PATHS_PREFIX", unset = NA) | |||
if (!is.na(prefix)) | |||
return(prefix) | |||
# if the user has requested an automatic prefix, generate it | |||
auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) | |||
if (auto %in% c("TRUE", "True", "true", "1")) | |||
return(renv_bootstrap_platform_prefix_auto()) | |||
# empty string on failure | |||
"" | |||
} | |||
renv_bootstrap_platform_prefix_auto <- function() { | |||
prefix <- tryCatch(renv_bootstrap_platform_os(), error = identity) | |||
if (inherits(prefix, "error") || prefix %in% "unknown") { | |||
msg <- paste( | |||
"failed to infer current operating system", | |||
"please file a bug report at https://github.com/rstudio/renv/issues", | |||
sep = "; " | |||
) | |||
warning(msg) | |||
} | |||
prefix | |||
} | |||
renv_bootstrap_platform_os <- function() { | |||
sysinfo <- Sys.info() | |||
sysname <- sysinfo[["sysname"]] | |||
# handle Windows + macOS up front | |||
if (sysname == "Windows") | |||
return("windows") | |||
else if (sysname == "Darwin") | |||
return("macos") | |||
# check for os-release files | |||
for (file in c("/etc/os-release", "/usr/lib/os-release")) | |||
if (file.exists(file)) | |||
return(renv_bootstrap_platform_os_via_os_release(file, sysinfo)) | |||
# check for redhat-release files | |||
if (file.exists("/etc/redhat-release")) | |||
return(renv_bootstrap_platform_os_via_redhat_release()) | |||
"unknown" | |||
} | |||
renv_bootstrap_platform_os_via_os_release <- function(file, sysinfo) { | |||
# read /etc/os-release | |||
release <- utils::read.table( | |||
file = file, | |||
sep = "=", | |||
quote = c("\"", "'"), | |||
col.names = c("Key", "Value"), | |||
comment.char = "#", | |||
stringsAsFactors = FALSE | |||
) | |||
vars <- as.list(release$Value) | |||
names(vars) <- release$Key | |||
# get os name | |||
os <- tolower(sysinfo[["sysname"]]) | |||
# read id | |||
id <- "unknown" | |||
for (field in c("ID", "ID_LIKE")) { | |||
if (field %in% names(vars) && nzchar(vars[[field]])) { | |||
id <- vars[[field]] | |||
break | |||
} | |||
} | |||
# read version | |||
version <- "unknown" | |||
for (field in c("UBUNTU_CODENAME", "VERSION_CODENAME", "VERSION_ID", "BUILD_ID")) { | |||
if (field %in% names(vars) && nzchar(vars[[field]])) { | |||
version <- vars[[field]] | |||
break | |||
} | |||
} | |||
# join together | |||
paste(c(os, id, version), collapse = "-") | |||
} | |||
renv_bootstrap_platform_os_via_redhat_release <- function() { | |||
# read /etc/redhat-release | |||
contents <- readLines("/etc/redhat-release", warn = FALSE) | |||
# infer id | |||
id <- if (grepl("centos", contents, ignore.case = TRUE)) | |||
"centos" | |||
else if (grepl("redhat", contents, ignore.case = TRUE)) | |||
"redhat" | |||
else | |||
"unknown" | |||
# try to find a version component (very hacky) | |||
version <- "unknown" | |||
parts <- strsplit(contents, "[[:space:]]")[[1L]] | |||
for (part in parts) { | |||
nv <- tryCatch(numeric_version(part), error = identity) | |||
if (inherits(nv, "error")) | |||
next | |||
version <- nv[1, 1] | |||
break | |||
} | |||
paste(c("linux", id, version), collapse = "-") | |||
} | |||
renv_bootstrap_library_root_name <- function(project) { | |||
# use project name as-is if requested | |||
asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") | |||
if (asis) | |||
return(basename(project)) | |||
# otherwise, disambiguate based on project's path | |||
id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) | |||
paste(basename(project), id, sep = "-") | |||
} | |||
renv_bootstrap_library_root <- function(project) { | |||
path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) | |||
if (!is.na(path)) | |||
return(path) | |||
path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) | |||
if (!is.na(path)) { | |||
name <- renv_bootstrap_library_root_name(project) | |||
return(file.path(path, name)) | |||
} | |||
prefix <- renv_bootstrap_profile_prefix() | |||
paste(c(project, prefix, "renv/library"), collapse = "/") | |||
} | |||
renv_bootstrap_validate_version <- function(version) { | |||
loadedversion <- utils::packageDescription("renv", fields = "Version") | |||
if (version == loadedversion) | |||
return(TRUE) | |||
# assume four-component versions are from GitHub; three-component | |||
# versions are from CRAN | |||
components <- strsplit(loadedversion, "[.-]")[[1]] | |||
remote <- if (length(components) == 4L) | |||
paste("rstudio/renv", loadedversion, sep = "@") | |||
else | |||
paste("renv", loadedversion, sep = "@") | |||
fmt <- paste( | |||
"renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", | |||
"Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", | |||
"Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", | |||
sep = "\n" | |||
) | |||
msg <- sprintf(fmt, loadedversion, version, remote) | |||
warning(msg, call. = FALSE) | |||
FALSE | |||
} | |||
renv_bootstrap_hash_text <- function(text) { | |||
hashfile <- tempfile("renv-hash-") | |||
on.exit(unlink(hashfile), add = TRUE) | |||
writeLines(text, con = hashfile) | |||
tools::md5sum(hashfile) | |||
} | |||
renv_bootstrap_load <- function(project, libpath, version) { | |||
# try to load renv from the project library | |||
if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) | |||
return(FALSE) | |||
# warn if the version of renv loaded does not match | |||
renv_bootstrap_validate_version(version) | |||
# load the project | |||
renv::load(project) | |||
TRUE | |||
} | |||
renv_bootstrap_profile_load <- function(project) { | |||
# if RENV_PROFILE is already set, just use that | |||
profile <- Sys.getenv("RENV_PROFILE", unset = NA) | |||
if (!is.na(profile) && nzchar(profile)) | |||
return(profile) | |||
# check for a profile file (nothing to do if it doesn't exist) | |||
path <- file.path(project, "renv/local/profile") | |||
if (!file.exists(path)) | |||
return(NULL) | |||
# read the profile, and set it if it exists | |||
contents <- readLines(path, warn = FALSE) | |||
if (length(contents) == 0L) | |||
return(NULL) | |||
# set RENV_PROFILE | |||
profile <- contents[[1L]] | |||
if (nzchar(profile)) | |||
Sys.setenv(RENV_PROFILE = profile) | |||
profile | |||
} | |||
renv_bootstrap_profile_prefix <- function() { | |||
profile <- renv_bootstrap_profile_get() | |||
if (!is.null(profile)) | |||
return(file.path("renv/profiles", profile)) | |||
} | |||
renv_bootstrap_profile_get <- function() { | |||
profile <- Sys.getenv("RENV_PROFILE", unset = "") | |||
renv_bootstrap_profile_normalize(profile) | |||
} | |||
renv_bootstrap_profile_set <- function(profile) { | |||
profile <- renv_bootstrap_profile_normalize(profile) | |||
if (is.null(profile)) | |||
Sys.unsetenv("RENV_PROFILE") | |||
else | |||
Sys.setenv(RENV_PROFILE = profile) | |||
} | |||
renv_bootstrap_profile_normalize <- function(profile) { | |||
if (is.null(profile) || profile %in% c("", "default")) | |||
return(NULL) | |||
profile | |||
} | |||
# load the renv profile, if any | |||
renv_bootstrap_profile_load(project) | |||
# construct path to library root | |||
root <- renv_bootstrap_library_root(project) | |||
# construct library prefix for platform | |||
prefix <- renv_bootstrap_platform_prefix() | |||
# construct full libpath | |||
libpath <- file.path(root, prefix) | |||
# attempt to load | |||
if (renv_bootstrap_load(project, libpath, version)) | |||
return(TRUE) | |||
# load failed; inform user we're about to bootstrap | |||
prefix <- paste("# Bootstrapping renv", version) | |||
postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") | |||
header <- paste(prefix, postfix) | |||
message(header) | |||
# perform bootstrap | |||
bootstrap(version, libpath) | |||
# exit early if we're just testing bootstrap | |||
if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) | |||
return(TRUE) | |||
# try again to load | |||
if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { | |||
message("* Successfully installed and loaded renv ", version, ".") | |||
return(renv::load()) | |||
} | |||
# failed to download or load renv; warn the user | |||
msg <- c( | |||
"Failed to find an renv installation: the project will not be loaded.", | |||
"Use `renv::activate()` to re-initialize the project." | |||
) | |||
warning(paste(msg, collapse = "\n"), call. = FALSE) | |||
}) |
@@ -0,0 +1,7 @@ | |||
external.libraries: | |||
ignored.packages: | |||
package.dependency.fields: Imports, Depends, LinkingTo | |||
r.version: | |||
snapshot.type: implicit | |||
use.cache: TRUE | |||
vcs.ignore.library: TRUE |
@@ -0,0 +1,10 @@ | |||
{ | |||
"datafile": "{{ datafile }}", | |||
"corr_vars": {{ corr_vars }}, | |||
"method": "{{ method | default: "square" }}", | |||
"corr_type": "{{ corr_type | default: "full" }}", | |||
"hc_method": "{{ hc_method | default: "complete" }}", | |||
"hc_order": {{ hc_order }}, | |||
"sig_level": {{ sig_level | default: 0.05 }}, | |||
"title": "{{ title | default: "This is a correlation plot" }}" | |||
} |
@@ -0,0 +1,33 @@ | |||
info: | |||
name: Correlation Plot | |||
version: v0.1.0 | |||
description: It is used to investigate the dependence between multiple variables at the same time and to highlight the most correlated variables in a data table. | |||
category: Chart | |||
home: https://github.com/tservice-plugins/corrplot | |||
source: PGx | |||
short_name: corrplot | |||
icons: | |||
- src: "" | |||
type: image/png | |||
sizes: 192x192 | |||
author: Jingcheng Yang | |||
plugin: | |||
name: corrplot | |||
display-name: Correlation Plot | |||
lazy-load: false | |||
init: | |||
- step: unpack-env | |||
envname: corrplot | |||
envtype: environment | |||
- step: unpack-env | |||
envname: templates | |||
envtype: configuration | |||
- step: unpack-env | |||
envname: examples | |||
envtype: data | |||
- step: load-namespace | |||
namespace: tservice.plugins.corrplot | |||
- step: register-plugin | |||
entrypoint: tservice.plugins.corrplot/metadata | |||
- step: init-event | |||
entrypoint: tservice.plugins.corrplot/events-init |
@@ -0,0 +1,142 @@ | |||
(ns tservice.plugins.corrplot | |||
(:require [clojure.data.json :as json] | |||
[clojure.spec.alpha :as s] | |||
[clojure.tools.logging :as log] | |||
[spec-tools.core :as st] | |||
[tservice.util :as u] | |||
[tservice.lib.files :as ff] | |||
[tservice.lib.fs :as fs-lib] | |||
[tservice.plugins.corrplot.common :as corrplot] | |||
[tservice.api.task :refer [publish-event! make-plugin-metadata make-events-init create-task! update-process!]])) | |||
;;; ------------------------------------------------ Event Specs ------------------------------------------------ | |||
(s/def ::datafile | |||
(st/spec | |||
{:spec string? | |||
:type :string | |||
:description "A path for data file." | |||
:swagger/default "" | |||
:reason "The datafile must be string."})) | |||
(s/def ::corr_vars | |||
(st/spec | |||
{:spec vector? | |||
:type :vector | |||
:description "Variables." | |||
:swagger/default [] | |||
:reason "The corr_vars must be a vector."})) | |||
(s/def ::method | |||
(st/spec | |||
{:spec #{"square" "circle"} | |||
:type :string | |||
:description "The visualization method of correlation matrix to be used. Allowed values are square (default), circle." | |||
:swagger/default "square" | |||
:reason "The corr_vars must be a vector."})) | |||
(s/def ::corr_type | |||
(st/spec | |||
{:spec #{"full" "lower" "upper"} | |||
:type :string | |||
:description "full (default), lower or upper display." | |||
:swagger/default "full" | |||
:reason "The corr_type must be one of full, lower, upper."})) | |||
(s/def ::hc_method | |||
(st/spec | |||
{:spec #{"ward.D" "ward.D2" "single" "complete" "average" "mcquitty" "median" "centroid"} | |||
:type :string | |||
:description "The agglomeration method to be used in hclust (see ?hclust)." | |||
:swagger/default "complete" | |||
:reason "The hc_method must be (an unambiguous abbreviation of) one of ward.D, ward.D2, | |||
single, complete, average, mcquitty, median or centroid."})) | |||
(s/def ::hc_order | |||
(st/spec | |||
{:spec #{true false} | |||
:type :boolean | |||
:description "Logical value. If TRUE, correlation matrix will be hc.ordered using hclust function." | |||
:swagger/default true | |||
:reason "The hc_order must be one of true, false."})) | |||
(s/def ::sig_level | |||
(st/spec | |||
{:spec #(and (>= % 0) (<= % 1)) | |||
:type :float | |||
:description "Logical value. If TRUE, correlation matrix will be hc.ordered using hclust function." | |||
:swagger/default 0.05 | |||
:reason "The hc_order must be one of true, false."})) | |||
(def corrplot-params-body | |||
"A spec for the body parameters." | |||
(s/keys :req-un [::datafile ::corr_vars] | |||
:opt-un [::sig_level ::hc_order ::hc_method ::corr_type ::method])) | |||
;;; ------------------------------------------------ Event Metadata ------------------------------------------------ | |||
(def metadata | |||
(make-plugin-metadata | |||
{:name "corrplot" | |||
:summary "It is used to investigate the dependence between multiple variables at the same time and to highlight the most correlated variables in a data table." | |||
:params-schema corrplot-params-body | |||
:handler (fn [{:keys [datafile corr_vars sig_level hc_order hc_method corr_type method plugin-env] | |||
:or {sig_level 0.05 | |||
hc_order true | |||
hc_method "complete" | |||
corr_type "full" | |||
method "square"} | |||
:as payload}] | |||
(log/info "Make a correlation plot with %s" payload) | |||
(let [workdir (ff/get-workdir) | |||
log-path (fs-lib/join-paths workdir "log") | |||
response {:files [(fs-lib/join-paths workdir "plotly.json") | |||
(fs-lib/join-paths workdir "result.md")] | |||
:log log-path | |||
:response-type :data2files} | |||
task-id (create-task! {:name (str "corrplot" (u/datetime)) | |||
:description "Make a correlation plot." | |||
:payload payload | |||
:plugin-name (:plugin-name plugin-env) | |||
:plugin-type (:plugin-type plugin-env) | |||
:plugin-version (:plugin-version plugin-env) | |||
:response response})] | |||
(fs-lib/create-directories! workdir) | |||
(spit log-path (json/write-str {:status "Running" :msg ""})) | |||
(update-process! task-id 0) | |||
(publish-event! "corrplot" | |||
{:context {:datafile datafile | |||
:corr_vars corr_vars | |||
:sig_level sig_level | |||
:hc_order hc_order | |||
:hc_method hc_method | |||
:corr_type corr_type | |||
:method method | |||
:title "Correlation Plot"} | |||
:template-dir (fs-lib/join-paths (:config-dir plugin-env) "templates") | |||
:env-dir (:env-dir plugin-env) | |||
:dest-dir workdir | |||
:task-id task-id}) | |||
response)) | |||
:plugin-type :ChartPlugin | |||
:response-type :data2files})) | |||
;;; ------------------------------------------------ Event Processing ------------------------------------------------ | |||
(defn- corrplot! | |||
"Make a correlation plot" | |||
[{:keys [context dest-dir template-dir env-dir task-id]}] | |||
(let [log-path (fs-lib/join-paths dest-dir "log") | |||
args-json (fs-lib/join-paths dest-dir "arguments.json") | |||
args-template (fs-lib/join-paths template-dir "args.json.template") | |||
output-file (fs-lib/join-paths dest-dir "plotly.json")] | |||
(corrplot/make-args-json! args-template context args-json) | |||
(log/info "Make an argument json file: %s" args-json) | |||
(update-process! task-id 30) | |||
(let [result (corrplot/call-corrplot! args-json output-file env-dir) | |||
status (:status result)] | |||
(spit log-path (json/write-str result)) | |||
(log/info "The task is finished, result file is %s" output-file) | |||
(update-process! task-id (if (= status "Success") 100 -1))))) | |||
;;; --------------------------------------------------- Lifecycle ---------------------------------------------------- | |||
(def events-init | |||
"Automatically called during startup; start event listener for corrplot events." | |||
(make-events-init "corrplot" corrplot!)) |
@@ -0,0 +1,34 @@ | |||
(ns tservice.plugins.corrplot.common | |||
(:require [selmer.parser :as parser] | |||
[tservice.lib.files :refer [get-path-variable]] | |||
[clojure.java.shell :as shell :refer [sh]] | |||
[tservice.lib.fs :as fs-lib] | |||
[clojure.data.json :as json] | |||
[clojure.tools.logging :as log])) | |||
(defn add-env-to-path | |||
[plugin-env-dir] | |||
(let [env-bin-path (fs-lib/join-paths plugin-env-dir "bin") | |||
path (get-path-variable)] | |||
(str env-bin-path ":" path))) | |||
(defn make-args-json! | |||
"Render arguments json file." | |||
[template-file context output-file] | |||
(log/info (format "Render Template (%s) with Environment Context: %s" template-file context)) | |||
(let [template (slurp template-file) | |||
args-json (parser/render template context)] | |||
(spit output-file (json/write-str args-json)))) | |||
(defn call-corrplot! | |||
[input-file output-file plugin-env-dir] | |||
(shell/with-sh-env {:PATH (add-env-to-path plugin-env-dir) | |||
:R_PROFILE_USER (fs-lib/join-paths plugin-env-dir "Rprofile") | |||
:LC_ALL "en_US.utf-8" | |||
:LANG "en_US.utf-8"} | |||
(let [command ["bash" "-c" (format "corrplot.sh -i %s -o %s" input-file output-file)] | |||
result (apply sh command) | |||
status (if (= (:exit result) 0) "Success" "Error") | |||
msg (str (:out result) "\n" (:err result))] | |||
{:status status | |||
:msg msg}))) |
@@ -0,0 +1,7 @@ | |||
(ns tservice.plugins.corrplot-test | |||
(:require [clojure.test :refer :all] | |||
[tservice.plugins.corrplot :refer :all])) | |||
(deftest a-test | |||
(testing "FIXME, I fail." | |||
(is (= 0 1)))) |