Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MCQR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PAPPSO
MCQR
Commits
7f8af77c
Commit
7f8af77c
authored
9 months ago
by
thierry Balliau
Browse files
Options
Downloads
Patches
Plain Diff
ajout script install v0.6.15 test dockerfile ok
parent
883143f1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tools/R/script_install_41_0.6.15.R
+135
-0
135 additions, 0 deletions
Tools/R/script_install_41_0.6.15.R
with
135 additions
and
0 deletions
Tools/R/script_install_41_0.6.15.R
0 → 100644
+
135
−
0
View file @
7f8af77c
### Script d'installation de MCQR
## internal variable to modify depending on R version and current mcqr version
Rminrequirement
<-
"3.6.0"
packagesForOldVersion
<-
list
()
packagesForOldVersion
$
R36
<-
list
()
packagesForOldVersion
$
R36
=
list
(
c
(
"name"
=
"caTools"
,
"version"
=
"1.17.1.4"
),
c
(
"name"
=
"quantreg"
,
"version"
=
"5.85"
))
packages
=
c
(
"car"
,
"cpp11"
,
"stringr"
,
"readODS"
,
"VIM"
,
"ade4"
,
"gplots"
,
"clValid"
,
"agricolae"
,
"ggplot2"
,
"RColorBrewer"
,
"plotly"
,
"plyr"
,
"dplyr"
,
"data.table"
,
"nlme"
,
"ggVennDiagram"
,
"dataverse"
)
## internal function to ask for valdiation
## inspired from https://stackoverflow.com/questions/27112370/make-readline-wait-for-input-in-r
askValid
<-
function
(){
raw
<-
"this is not a valid answer"
if
(
interactive
()){
while
(
!
(
raw
%in%
c
(
"n"
,
"y"
,
""
))){
raw
<-
readline
(
"continue? (y/n (default y): "
)
}
}
else
{
# non-interactive
while
(
!
(
raw
%in%
c
(
"n"
,
"y"
,
""
))){
cat
(
"continue? (y/n (default y): "
);
raw
<-
readLines
(
"stdin"
,
n
=
1
);
}
}
if
(
raw
==
"n"
){
validation
<-
F
}
else
{
validation
<-
T
}
return
(
validation
)
}
checkLibrary
<-
function
(
libraries
){
result
=
TRUE
installedPackages
<-
rownames
(
installed.packages
())
for
(
mylib
in
libraries
){
if
(
!
(
mylib
%in%
installedPackages
)){
result
=
FALSE
}
}
return
(
result
)
}
checkLibraryAndInstallIt
<-
function
(
libraries
){
result
=
TRUE
installedPackages
<-
rownames
(
installed.packages
())
for
(
mylib
in
libraries
){
if
(
!
(
mylib
%in%
installedPackages
)){
install_version
(
mylib
[
'name'
],
mylib
[
'version'
])
}
}
return
(
result
)
}
checkPackageAndInstallIt
<-
function
(
libraries
,
osName
){
result
=
TRUE
installedPackages
<-
rownames
(
installed.packages
())
for
(
mylib
in
libraries
){
if
(
!
(
mylib
%in%
installedPackages
)){
cat
(
paste0
(
"installing "
,
mylib
,
" Package\n"
))
if
(
osName
==
"windows"
){
install.packages
(
mylib
,
type
=
"binary"
,
quiet
=
TRUE
)
}
else
{
install.packages
(
mylib
,
quiet
=
TRUE
)
}
## test if library can be loaded
tryCatch
({
suppressPackageStartupMessages
(
library
(
mylib
,
character.only
=
TRUE
))
},
error
=
function
(
e
)
{
cat
(
paste0
(
"Error library "
,
mylib
,
" can't be installed\n"
))
result
=
FALSE
},
finally
=
{
detach
(
paste0
(
"package:"
,
mylib
),
unload
=
TRUE
,
character.only
=
TRUE
)
cat
(
paste0
(
"library "
,
mylib
,
" Successfully installed\n"
))
})
}
else
{
cat
(
paste0
(
mylib
,
" Package is already installed, skip it\n"
))
}
}
return
(
result
)
}
install_MCQR
<-
function
(
prepare
=
FALSE
){
# Check environnment
os
<-
Sys.info
()
cat
(
"Operating System\n"
)
cat
(
paste0
(
os
[
'sysname'
],
" "
,
os
[
'release'
],
" "
,
os
[
'version'
],
"\n"
))
cat
(
paste0
(
"Machine type : "
,
os
[
'machine'
],
"\n"
))
### checking R version for listing of necessary packages
RVersion
<-
R.Version
()
cat
(
paste0
(
RVersion
$
version.string
,
"\n"
))
## specific installation depending on R version
if
(
as.integer
(
RVersion
$
major
)
<
4
){
if
(
as.integer
(
RVersion
$
major
)
<
3
){
stop
(
cat
(
paste0
(
"Sorry your R version is too old for the MCQR Package, the minimum requirement is R version"
,
Rminrequirement
,
"\n"
)))
}
else
{
if
(
as.double
(
RVersion
$
minor
<
0.6
)){
stop
(
cat
(
paste0
(
"Sorry your R version is too old for the MCQR Package, the minimum requirement is R version"
,
Rminrequirement
,
"\n"
)))
}
else
{
## check if dependancies can be loaded
if
(
suppressWarnings
(
!
checkLibrary
(
packagesForOldVersion
$
R36
))){
cat
(
"need some old version of package\n"
)
cat
(
"installing remote package to get package from cran archive and load it\n"
)
install.packages
(
"remotes"
)
library
(
remotes
)
suppressWarnings
(
checkLibraryAndInstallIt
(
packagesForOldVersion
$
R36
))
detach
(
"package:remotes"
,
unload
=
TRUE
)
}
else
{
cat
(
"no need special install\n"
)
}
}
}
}
else
{
cat
(
"no need special install\n"
)
}
## check and install needed packages
cat
(
"for windows install prefer binary install instead of source install\n"
)
test
=
checkPackageAndInstallIt
(
packages
,
os
[
"sysname"
])
if
(
!
prepare
){
#Install MCQR
if
(
"MCQR"
%in%
rownames
(
installed.packages
())){
cat
(
"MCQR was already installed. Removing it\n"
)
remove.packages
(
"MCQR"
)
}
cat
(
"Installing latest version of MCQR\n"
)
install.packages
(
'https://forgemia.inra.fr/pappso/mcqr/uploads/215fb1480c4f47375f3fd1366354ef5b/MCQR_0.6.15.tar.gz'
,
repos
=
NULL
,
type
=
'source'
)
}
}
install_MCQR
(
FALSE
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment