Articles

Affichage des articles du juin, 2020

openssl packages

brew reinstall openssl@1.1 wget https://cran.r-project.org/src/contrib/openssl_1.4.2.tar.gz R CMD INSTALL --configure-vars='INCLUDE_DIR=/usr/local/opt/openssl@1.1/include LIB_DIR=/usr/local/opt/openssl@1.1/lib' openssl_1.4.2.tar.gz

install rgdal and gdal in MacosX: remove previous installation

I had an error when I tried to update rgdal. It said that gdal 2.1.4 was installed whereas brew installed version 3.1 The 2.1.4 version was installed previously manually in : /Library/Frameworks I remove the gdal folder, installed gdal using brew and all is ok now: brew install gdal and in R: install.packages("rgdal") Note that rgdal should be replaced by terra in future

Setup R 4.0 library to be used in RStudio

echo $USER will show your login name; for example myname Then do: sudo chmod -R 777 /Users/myname/Library/R/4.0/library/ and you will be able to install packages within RStudio

Install Ubuntu 20.04 lts and R 4.0.1 and Rstudio 1.3

# Install Ubuntu 20.04 lts # 2 hours sudo apt install update-manager-core sudo apt update sudo apt upgrade sudo apt dist-upgrade sudo apt autoremove sudo reboot sudo do-release-upgrade -d # Remove old R installation # If you want install again your packages, follow this trick #  https://biostatsr.blogspot.com/2019/05/reinstall-packages-after-updating-r.html sudo vi /etc/apt/sources.list # Remove all lines with CRAN or r-project # In vi, use / to search # Remove files shown using: ls /etc/apt/sources.list.d # For example: sudo rm /etc/apt/sources.list.d/marutter-ubuntu-rrutter3_5-xenial.list sudo rm /etc/apt/sources.list.d/marutter-ubuntu-rrutter3_5-xenial.list.distUpgrade sudo rm /etc/apt/sources.list.d/marutter-ubuntu-rrutter3_5-xenial.list.save # I am not sure that reboot is necessary, but better to do! sudo reboot sudo apt-get purge r-base* r-recommended r-cran-* sudo apt autoremove sudo apt update # Packages are located in .libPaths() read from

Install package imager in ubuntu or MacOSX (with imagemagick library)

In terminal: sudo apt-get update -y sudo apt-get install -y fftw3 In R install.packages("imager") More infos here: http://dahtah.github.io/imager/ In MacOSX:  brew install imagemagick ffmpeg Note: imagemagick@6 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have imagemagick@6 first in your PATH, run:   echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.zshrc For compilers to find imagemagick@6 you may need to set:   export LDFLAGS="-L/usr/local/opt/imagemagick@6/lib"   export CPPFLAGS="-I/usr/local/opt/imagemagick@6/include" For pkg-config to find imagemagick@6 you may need to set:   export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"

Non-ASCII character in your package

Sometimes it is not possible to use only ASCII character and it prevents to pass the CRAN check. For example, if you need to use "−"; clearly it will generate an error in the CRAN check. The solution is to use the chr() and asc() functions of my HelpersMG package available in CRAN: Do: > asc("−") [1] 195 162 203 134 226 128 153 And replace "−" in your code by: > chr(c(195, 162, 203, 134, 226, 128, 153)) [1] "−" You will have the magic message: Status: OK after your check for CRAN! https://cran.r-project.org/web/packages/HelpersMG/index.html

GLMM with binomial

df <- data.frame(Fibro=sample(x=c("Oui", "Non"), 1000, replace=TRUE),                  year=floor(runif(1000, min=2004, max=2010))-2000,                  ID=sample(x=1:100, 1000, replace=TRUE)) df2 <- cbind(df, FibroNum=as.numeric(df$Fibro=="Oui"), NonFibroNum=1-as.numeric(df$Fibro=="Oui")) df2$year <- df2$year + df2$FibroNum df2$Fibro <- as.factor(df2$Fibro) df2$ID <- as.factor(df2$ID) head(df2) library(lme4) These solutions are equivalent g1 <- glmer(formula = Fibro ~ year + (1 | ID), data=df2, family=binomial(link="logit")) g2 <- glmer(formula = FibroNum ~ year + (1 | ID), data=df2, family=binomial(link="logit")) g3 <- glmer(formula = cbind(FibroNum, NonFibroNum) ~ year + (1 | ID),             data=df2, family=binomial(link="logit")) library(cAIC4) cAIC(g1) cAIC(g2) cAIC(g3)