jeudi 16 juillet 2015

Netcdf in R. Part 1: Installation in Linux debian based (ubuntu, linux mint)

Many scientific data (remoted sensed data, environmental, etc..) are distributed in NetCDF (nc format, .nc).
In R, the most used package to process these data is ncdf4 but it requires some other LINUX packages to be installed correctly in R.

The required packages are libnetcdf-dev, libnetcdfc++4, libnetcdfc7, libnetcdff5, libcf0, netcdf-bin

These required packages can be installed using apt-get install, Synaptic or Software Manager. If they aren't installed you can have errors such if you try to install ndcf4 in R

ERROR: configuration failed for package ‘ncdf4’ 

ncdf.c:3:20: fatal error: netcdf.h: No such file or directory
 #include <netcdf.h>
compilation terminated.
make: *** [ncdf.o] Error 1
ERROR: compilation failed for package ‘ncdf4’

After installing these requirements you can install now ncdf4 in R (install.packages('ncdf4')

In the next post, I'll give some useful tips to explore ncdf files in R.

samedi 24 janvier 2015

Revolution Analytics joins Microsoft: Microsoft prête à engager réellement le combat dans les "Big" Data Science?

David Smith, Chief Community Officer, says on this blog
"On behalf of the entire Revolution Analytics team I am excited to announce that Revolution Analytics is joining forces with Microsoft to bring R to even more enterprises. Microsoft announced today that it will acquire Revolution Analytics."


jeudi 31 juillet 2014

Matlab, eval: Dynamic variable naming with eval/Création dynamique de variables

The purpose is to dynamically name variables.  Example: I wish to store the value returned  by a function (func) in different variables according to a parameter i. /
[french] le but de la manoeuvre est de créer dynamiquement des variables (avec des noms dynamiques). Exemple, je souhaite stocker les valeurs retournées par une fonction dans différentes variables en fonction de la valeur d'un paramètre.[/french]
for i=1:10
      a=func(param1, param2,i); (exemple a=sin(i*pi));

Of course in this way a is always overwritten./ Dans cette solution la variable a  est toujours écrasé.

If I want to dynamically create variables and store the different returned values in these variables, I can us eval
[french]Si je veux créer dynamiquement les variables, j'utilise la fonction eval[/french]

for i=1:10
      a=func(param1, param2,i);(exemple a=sin(i*pi));

If this way, the 10 returned values will be stored in a1, a2, ....,a10

mercredi 21 mai 2014

Windows change directory to no system drive (cd another drive) using cmd, command line, prompt

We use cd to change directory but if the directory is not on the system partition, there is no change. To overcome just add /d after the cd.
If I want to change to a directory named folder1 in drive f using command line i do:
cd  /d  E:/folder1

vendredi 27 décembre 2013

elsarticle: psyr at 12.0pt not loadable: Metric (TFM) file not found for Ubuntu, Mint using Kile

I had this problem while compiling a latex document based on the Elsevier latex article class with kile-texlive

font u/psy/m/n/12=psyr at 12.0pt not loadable metric (tfm) file not found
I found a solution with lof of matters. I share it here! Type in a command windows

sudo apt-get install texlive-fonts-recommended

Hoping that would be helpful for someone.

mardi 26 février 2013

Matlab: plot, imagesc, graphical options don't work.

Graphical options (properties) such as fontsize, font weight and so are not considered, only default graphical properties are displayed in linux ubuntu 10.04+

How to solve this problem?
The solution I propposed here worked for me. 
Since 11.11  release (with update to 10.04 and ..) Ubuntu switch to OpenJDK replacing Oracle (Sun) JDK,JRE.
Since this changing graphical properties in Matlab don't work correctly (in my case). To solve this problem I replace my JDK, JRE from OpenJDK to Oracle JDK using the following 

Preparing your system
First you need to remove openjdk for this run the following command from your terminal
sudo apt-get purge openjdk*
If you installed java 7 from any other PPA and you are having problem with java then you have to do following steps before installing the PPA menctioned here
sudo rm /var/lib/dpkg/info/oracle-java7-installer*
sudo apt-get purge oracle-java7-installer*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update
Install oracle java 7 in ubuntu 12.04
Open the terminal and run the following commands
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
You can check the java version by searching java in dashboard

mercredi 21 novembre 2012

R  code  for listing directories/code R pour lister les repertoires

Here is a pretty R  code  for listing directories in a given directory
Voici un code R pour lister les repertoires d'un dossier donné
list.dirs <- function(path=".",recursive=FALSE) {
    get.list <- list.files(path)
    if (length(get.list) == 0) {return(NULL)} #no files or directories
    get.list.fixed <- paste(path,get.list,sep="/")
    whichonesaredir <-$isdir
    if (!any(whichonesaredir)) {return(NULL)} #no directories, only files
    dirlist <- get.list.fixed[whichonesaredir]
    finaldirlist <- dirlist
    if ((recursive & length(dirlist) > 0)) {
      for (i in 1:length(dirlist)) {
         finaldirlist <- c(finaldirlist,list.dirs(dirlist[i],recursive))
Save the code in a file (listDir.r for example) and in R console use the following commands  
source('listDir.r') #to source the file
list=list.dirs(path,rec)#path is the current path by default else the dir in path will be listed. 
#rec (TRUE or FALSE(defaulty)) indicates if the sub-directories will be listed or not

mercredi 26 septembre 2012

simple way to compute rmse root mean square error in R

calculer rmse ("racine" de l'erreur moyenne quadratique) avec R.

    diff=diff[!]  #to remove NA values
    return (sqrt(mean((diff)^2)))

save the commands above in a file named rmse.r
To call this function:
       considering that obs is the array of observed values, pred is the array of predicted values

rmsErr= rmse(obs,pred)

jeudi 23 août 2012

plot two histograms together in R

Considering two samples of datas A and B. To plot histograms together in the same window 
just run the following commands (in the R Console) 
hist(B, col="blue",add=T)
b=rnorm(2000, 6, 1)
a=rnorm(2000, 3, 1)
hist(b,col="blue",ylim=c(0,400),add=T)  # add=T is the key