<sec:sectionA>
Code is enclosed within #+begin_src/#+end_src
blocks.
x <- 1:10
## devtools::install_github('meteo', 'oscarperpinan') | |
library(meteo) | |
Sys.setenv(TZ='UTC') | |
st <- data.frame(name=c('Almeria','Granada','Huelva','Malaga','Caceres'), | |
elev=c(42, 702, 38, 29, 448)) | |
coordinates(st) <- cbind(c(-2.46, -3.60, -6.94, -4.42, -6.37), |
<sec:sectionA>
Code is enclosed within #+begin_src/#+end_src
blocks.
x <- 1:10
\part{My First Part} | |
\label{part:part1} | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nec | |
lacus nec dui semper aliquet sit amet in leo. Integer volutpat eu diam | |
sed iaculis. | |
\chapter{My First Chapter} | |
\label{cha:cha1} |
\section{Code blocks} | |
\label{sec-1} | |
\label{sec:sectionA} | |
Code is enclosed within \texttt{\#+begin\_src/\#+end\_src} | |
\href{http://orgmode.org/manual/Structure-of-code-blocks.html}{blocks}. | |
\lstset{language=R,numbers=none} | |
\begin{lstlisting} | |
x <- 1:10 | |
y <- 1:10 |
\documentclass[smallroyalvopaper]{memoir} | |
\settypeblocksize{6.5in}{4.5in}{*} | |
\setlrmargins{*}{*}{1} | |
\checkandfixthelayout | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%% Misc packages | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\usepackage[english]{babel} | |
\usepackage[usenames,dvipsnames]{xcolor} |
library(raster) | |
library(zoo) | |
## Indice temporal completo | |
tt <- seq(as.Date('2015-01-01'), as.Date('2015-12-31'), by = 'month') | |
tt <- as.yearmon(tt) | |
## Datos disponibles: indice temporal incompleto | |
tt1 <- tt[-c(5, 8, 9)] | |
f <- system.file("external/test.grd", package="raster") |
library(zoo) | |
library(rasterVis) | |
## DESCRIPTION: http://iridl.ldeo.columbia.edu/SOURCES/.CAC/.sst/ | |
setwd(tempdir()) | |
download.file('http://iridl.ldeo.columbia.edu/SOURCES/.CAC/.sst/data.nc', destfile = 'SST.nc') | |
SST <- stack('SST.nc') | |
idx <- seq(as.Date('1970-01-01'), as.Date('2003-03-01'), by='month') | |
tt <- as.yearmon(idx) | |
SST <- setZ(SST, tt) |
## Ejemplo para leer netCDF con R | |
library(raster) | |
library(zoo) | |
## Coodinates of point (lat,lon) | |
latitude=37 | |
longitude=-2 | |
z=500 | |
## lon ranges from 0 to 360, so correction for convention of lon <0 | |
if (longitude < 0) longitude <- longitude + 360 |
library(sp) | |
## Grabar tabla excel en formato CSV usando ; como separador | |
## Leemos saltando dos primeras líneas | |
pts <- read.csv2('/tmp/listado-longitud-latitud-municipios-espana.csv', skip = 2) | |
## Transformamos a SPDF usando columnas de longitud-latitud como coordenadas | |
munPts <- SpatialPointsDataFrame(pts[, c(5, 4)], pts[,-c(4, 5)], | |
proj4string = CRS('+proj=longlat +datum=WGS84')) | |
## Pintamos el resultado para comprobar | |
spplot(munPts["Altitud"]) |