Articles

Affichage des articles du juin, 2016

Convert longitude/latitude formats from DMS to D.dec or DM.dec

Test of different packages to convert lo ng/lat data Package sp Several packages can do the job.  First, let use sp package. The orignal data can be in character string or in numbers. > library("sp") > essai <- char2dms(from="01d33'01.6\"N", chd="d", chm="'") > as.numeric(essai) [1] 1.550444 > essai <- char2dms(from="01°33'01.6\"N", chd="°", chm="'") Take care, the " character cannot be omitted: > essai <- char2dms(from="01°33'01.6N", chd="°", chm="'") > essai [1] 1d33'N > as.numeric(essai) [1] 1.55 Numeric data can be used directly using: > essai <- new(Class = "DMS", WS=FALSE, deg=1, min=33, sec=1.6, NS=TRUE) > essai [1] 1d33'1.6"N > as.numeric(essai) [1] 1.550444 And such DMS class object can be obtained from D.dec format using:

Install RnetCDF or ncdf4 on Ubuntu 14.04 64 bits

First install these libraries: sudo apt-get install libapparmor1 libcurl4-openssl-dev netcdf-bin libnetcdf-dev udunits-bin libudunits2-dev Then you can install ncdf4 or RnetCDF packages using the normal install commands within R

Fitting an ARIMA model with lme() (package nlme)

Image
An ARIMA model is one way to model time-series with two components, autoregressive and mobile average. See this post  Modèle ARMA et ARIMA . Let create a time series using both AR1 and MA1: set.seed(101) d <- data.frame(y=10,x=1:300) epsilon <- arima.sim(model = list(ar=0.9, ma=+0.2279), n = 300) d$y <- d$y + epsilon layout(matrix(1)) plot(d$x, d$y, bty="n", las=1, pch=19, cex=0.5)