Articles

Managing class and their order

# result is of class character; it prints correctly result <- "Je suis donc je pense" class(result) print(result) # I add a new class but I keep character class. All is ok # The order of classes is not important because there is no print() function for class ECFOCF class(result) <- unique(append(class(result),"ECFOCF"))) class(result) print(result) result <- "Je suis donc je pense" class(result) <- unique(append("ECFOCF", class(result))) class(result) print(result) # I create a new function for class ECFOCF # This function is used in priority whatever the ordre of classes print.ECFOCF <- function(x) {cat("print.ECFOCF ", x)} result <- "Je suis donc je pense" print(result) class(result) <- unique(append(class(result),"ECFOCF"))) class(result) print(result) result <- "Je suis donc je pense" class(result) <- unique(append("ECFOCF", class(result))) class(result) print(result...

GoogleEarth and R

 Introduction to Google Earth Engine with R language https://www.youtube.com/watch?v=SHXuIpjU3YE Deep Learning for Remote Sensing images with R language https://www.youtube.com/watch?v=N3CHgRlRqOA

Credible interval for median of Weibull distribution

Image
Alternative proposed by Varin Sacha using the package weibulltools  with delta method (a little bit modified to present only the median and the CI): library(weibulltools) x <- rweibull(100000, 2, 2) data <- reliability_data(x = x, status = 1)  ml <- ml_estimation(x = data, distribution = "weibull") conf <- confint_fisher(x = ml, b_lives = 0.5, direction = "x")  The results are: > as.numeric(conf[conf$prob == 0.5, c(4, 1, 5)]) [1] 1.657227 1.663275 1.669346 The true median was : > 2*log(2)^(1/2) [1] 1.665109 Let try if the average estimate by Fisher method for 1,000 samples is biased or not: library(weibulltools) library(pbmcapply) k <- pbmclapply(1:1000, FUN=function(i) { x <- rweibull(100000, 2, 2) data <- reliability_data(x = x, status = 1)  ml <- ml_estimation(x = data, distribution = "weibull") conf <- confint_fisher(x = ml, b_lives = 0.5, direction = "x")  return(as.numeric(conf[conf$prob == 0.5, 1])) }, mc.c...

Information to compile packages

From a discussion in   I am attempting to build my package using devtools::build I have verified that both Rcpp and RcppArmadillo are working properly. However, when I build, I get the following error message  Error: package or namespace load failed for ‘HACSim’ in dyn.load(file, DLLpath = DLLpath, ...):     unable to load shared object '/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/00LOCK-HACSim/00new/HACSim/libs/HACSim.so':  dlopen(/private/var/folders/wv/4_z4h7ns57g7qvd600qgd__w0000gn/T/RtmpGe2Cqt/Rinst118e1e9f13a0/00LOCK-HACSim/00new/HACSim/libs/HACSim.so, 6): Symbol not found: ___addtf3      Referenced from: /usr/local/lib/libquadmath.0.dylib      Expected in: /usr/local/lib/libgcc_s_x86_64.1.dylib     in /usr/local/lib/libquadmath.0.dylib    Error: loading failed    Execution halted    ERROR: loading failed ─  removing ‘/private/var/folde...

Configure Rstudio server

 sudo vi /etc/rstudio/rserver.conf # Server Configuration File #  www-port=8080 rsession-which-r=usr/bin/R auth-timeout-minutes=0 auth-stay-signed-in-days=3000 Note that the option session-timeout-minutes=0 Does not work. Perhaps it is only for the pro version

Install broom and spdep from source in MacOSX 12.2

I'm having trouble with : install.packages("broom", type = "source") and install.packages("spdep", type = "source") in R 4.12 in MacOSX 12.2 The error message is: Erreur dans dyn.load(file, DLLpath = DLLpath, ...) :    impossible de charger l'objet partagé '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/glue/libs/glue.so':   dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/glue/libs/glue.so, 0x0006): Library not loaded: /usr/local/opt/gsl/lib/libgsl.25.dylib   Referenced from: /Library/Frameworks/R.framework/Versions/4.1/Resources/library/glue/libs/glue.so   Reason: tried: '/usr/local/opt/gsl/lib/libgsl.25.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libgsl.25.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/server/libgsl.25.dylib' (no such file), '/usr/local/Cellar/gsl/2.7.1/lib/libgsl.25.dylib...

Install mixcat package in MacOSX and Ubuntu

 In ubuntu 20.04: sudo apt-get install libgsl0-dev install.packages("mixcat") In MacOSX: brew install gsl   Create a directory ~/.R/ if it does not exist and a file Makervars with PKG_LIBS=-L/usr/local/opt/gettext/lib CFLAGS=-I/usr/local/opt/gsl/include LDFLAGS=-L/usr/local/opt/gsl/lib -lgsl -lgslcblas Then in R: install.packages("mixcat") After the installation, remove the Makervars file or it will create interference with other installation, for example nloptr. Thanks to aymeric.stamm at math.cnrs.fr to have found this solution to install the nloptr package !