Articles

Affichage des articles du mars, 2021

Install plumber server

This is intended for a Ubuntu 20.04 server: sudo apt-get install git-core libssl-dev libcurl4-gnutls-dev curl libsodium-dev libxml2-dev sudo R install.packages("plumber") q("no") mkdir plumberapp cd plumberapp vi plumber.R ## Copy these lines # plumber.R #* Echo back the input #* @param msg The message to echo #* @get /echo function(msg="") {   list(msg = paste0("The message is: '", msg, "'")) } ## End vi myapi.R ## Copy these lines r <- plumber::plumb("/home/mgirond/plumberapp/plumber.R") r$run(host="0.0.0.0", port=8000) ## End vi my-api.service ## Copy these lines [Unit] Description=plumber service [Service] ExecStart=/usr/bin/Rscript /home/mgirond/plumberapp/myapi.R [Install] WantedBy=multi-user.target ## End sudo ufw allow 8000/tcp cp my-api.service /etc/systemd/system/my-api.service systemctl start my-api systemctl enable my-api sudo reboot Then it is possible to test the API: curl "http://localh

open the working directory as a window in finder

Simply enter: system(command=sprintf('open %s', shQuote(getwd()))) It has been introduced in HepersMG package > 4.5-1 as the function openwd() https://CRAN.R-project.org/package=HelpersMG   install.packages("https://hebergement.universite-paris-saclay.fr/marcgirondot/CRAN/HelpersMG.tar.gz", repos=NULL, type="source") library(HelpersMG) openwd() It should work also for windows with  shell.exec(getwd())

Reset "par" with defaut values

Enter in R or Rstudio and do: dput(par(no.readonly = TRUE)) Copy the list() that is shown, for example for me: list(xlog = FALSE, ylog = FALSE, adj = 0.5, ann = TRUE, ask = FALSE,     bg = "white", bty = "o", cex = 1, cex.axis = 1, cex.lab = 1,     cex.main = 1.2, cex.sub = 1, col = "black", col.axis = "black",     col.lab = "black", col.main = "black", col.sub = "black",     crt = 0, err = 0L, family = "", fg = "black", fig = c(0,     1, 0, 1), fin = c(9.47674418604651, 8.72093023255814), font = 1L,     font.axis = 1L, font.lab = 1L, font.main = 2L, font.sub = 1L,     lab = c(5L, 5L, 7L), las = 0L, lend = "round", lheight = 1,     ljoin = "round", lmitre = 10, lty = "solid", lwd = 1, mai = c(1.02,     0.82, 0.82, 0.42), mar = c(5.1, 4.1, 4.1, 2.1), mex = 1,     mfcol = c(1L, 1L), mfg = c(1L, 1L, 1L, 1L), mfrow = c(1L,     1L), mgp = c(3, 1, 0), mkh = 0.001, new = FAL