Skip to content

Commit

Permalink
Update to use XeLaTeX and add copyright notice. Make Git repository p…
Browse files Browse the repository at this point in the history
…ublic.
  • Loading branch information
aphalo committed May 22, 2016
1 parent ba71cde commit 22cc953
Show file tree
Hide file tree
Showing 14 changed files with 118,173 additions and 70,715 deletions.
6 changes: 3 additions & 3 deletions abbrev.sty
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
% Version 1.06 14 May 2014 (\wattnm and \molnm added)
% Version 1.07 27 November 2014 (\joulemol added)
% Version 1.08 1 June 2015 (several units added for r4photobiology)

% Vesrion 1.09 22 May 2016 define \Celsius
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{abbrev}[2014/05/17]

Expand Down Expand Up @@ -192,7 +192,7 @@
\newcommand{\rdDW}{\ADW[dark]}
\newcommand{\DeltaC}{\ensuremath{\Delta ^{13}\Chem{C}}\xspace}
\newcommand{\deltaC}{\ensuremath{\delta ^{13}\Chem{C}}\xspace}
\newcommand{\C}{\ensuremath{\mathrm{^{\circ}C}}\xspace}
\newcommand{\Celsius}{\ensuremath{\mathrm{^{\circ}C}}\xspace}
\newcommand{\Dw}{\ensuremath{\mathbf{D}^{\mathrm{w}}}\xspace}
\newcommand{\wpot}[1][]{\ensuremath{\psi_{\mathrm{#1}}}\xspace}
\newcommand{\Wpot}[1][]{\ensuremath{\Psi_{\mathrm{#1}}}\xspace}
Expand Down Expand Up @@ -243,5 +243,5 @@
\newcommand{\temperature}[1][]{\ensuremath{T_{\mathrm{#1}}}\xspace}
\newcommand{\Coscor}{\ensuremath{\varphi}\xspace}

\newcommand{\LAI}{\ensuremath{\mathrm{LAI}}}
\newcommand{\LAI}{\ensuremath{\mathrm{LAI}}\xspace}
%\newcommand{\degree}{\ensuremath{^\circ}}
36 changes: 17 additions & 19 deletions appendixes.prj
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
25 Patch Control
22 Patch Control

0
1
1

23
8
0
24
10
1

using-r.main.Rnw
TeX:RNW:UTF-8
286273531 0 -1 10484 -1 10488 208 208 1568 731 0 1 464 731 -1 -1 0 0 86 -1 -1 86 1 0 10488 -1 0 -1 0
17838075 0 -1 10484 -1 10488 208 208 1568 731 0 1 464 384 -1 -1 0 0 86 -1 -1 86 1 0 10488 -1 0 -1 0
:\aphalo\Documents\Own_editor_tasks\UV4Plant_Bulletin-2016-1\typeset\uv4p_2016-1_main.tex
TeX
269496315 8 -1 27750 -1 27678 78 78 1058 359 0 1 41 192 -1 -1 0 0 94 -1 -1 94 1 0 27678 -1 0 -1 0
:\aphalo\Documents\Own_editor_tasks\UV4Plant_Bulletin-2016-1\typeset\robson.tex
TeX
1060859 0 -1 10916 -1 10741 52 52 1032 333 0 1 509 112 -1 -1 0 0 46 -1 -1 46 1 0 10741 -1 0 -1 0
R.intro.Rnw
TeX:RNW
17838075 0 -1 102 -1 107 182 182 1542 705 0 1 770 34 -1 -1 0 0 -1 -1 -1 -1 1 0 107 -1 0 -1 0
17838075 0 -1 102 -1 107 182 182 1542 705 0 1 770 32 -1 -1 0 0 22 -1 -1 22 1 0 107 -1 0 -1 0
R.as.calculator.Rnw
TeX:RNW
1060859 0 -1 220 -1 132 26 26 1386 549 0 1 50 85 -1 -1 0 0 31 -1 -1 31 1 0 132 -1 0 -1 0
1060859 0 -1 220 -1 132 26 26 1386 549 0 1 50 80 -1 -1 0 0 31 -1 -1 31 1 0 132 -1 0 -1 0
R.scripts.Rnw
TeX:RNW
17838075 0 -1 12071 -1 11313 78 78 1438 601 1 1 304 748 -1 -1 0 0 31 -1 -1 31 1 0 11313 -1 0 -1 0
17838075 0 -1 12071 -1 11313 78 78 1438 601 1 1 283 368 -1 -1 0 0 31 -1 -1 31 1 0 11313 -1 0 -1 0
R.scripts.tex
TeX
1060859 0 -1 0 -1 0 52 52 1412 575 0 1 41 0 -1 -1 0 0 -1 -1 -1 -1 1 0 0 -1 0 -1 0
1060859 0 -1 0 -1 0 52 52 1412 575 0 1 41 0 -1 -1 0 0 43 -1 -1 43 1 0 0 -1 0 -1 0
R.functions.Rnw
TeX:RNW
17838075 0 -1 5632 -1 3071 130 130 1490 653 0 1 311 238 -1 -1 0 0 -1 -1 -1 -1 1 0 3071 -1 0 -1 0
17838075 0 -1 5632 -1 3071 130 130 1490 653 0 1 842 224 -1 -1 0 0 30 -1 -1 30 1 0 3071 -1 0 -1 0
R.functions.tex
TeX
1060859 0 -1 0 -1 0 208 208 1568 731 0 1 41 0 -1 -1 0 0 30 -1 -1 30 1 0 0 -1 0 -1 0
R.plotting.Rnw
TeX:RNW
1060859 0 -1 36675 -1 36607 130 130 1516 559 0 1 500 153 -1 -1 0 0 31 -1 -1 31 1 0 36607 -1 0 -1 0
using-r.main.tex
TeX:UTF-8
286273531 7 -1 10115 -1 10131 234 234 1594 757 0 1 932 442 -1 -1 0 0 104 -1 -1 104 1 0 10131 -1 0 -1 0
1060859 0 -1 36675 -1 36607 130 130 1516 559 0 1 455 144 -1 -1 0 0 31 -1 -1 31 1 0 36607 -1 0 -1 0
R.intro.tex
TeX
269496315 0 -1 0 -1 0 182 182 1542 705 0 1 41 0 -1 -1 0 0 22 -1 -1 22 1 0 0 -1 0 -1 0
Expand Down Expand Up @@ -78,8 +81,3 @@ TeX:UNIX
DATA
273678578 0 0 1 13 6 25 25 1741 444 1 0 122 208 -1 -1 0 0 -1 -1 -1 -1 1 0 6 13 0 0 0

*using-r.main.tex
>
*rbooks.bib
*references.bib
<
252 changes: 252 additions & 0 deletions using-r-main.Rnw
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
\documentclass[paper=a4,headsepline,BCOR=12mm,twoside,open=right,%
titlepage,headings=small,fontsize=10pt,index=totoc,bibliography=totoc,%
captions=tableheading,captions=nooneline]{scrbook}

%\usepackage[utf8]{inputenc}
\usepackage{color}

\usepackage{amsmath,amssymb,amsthm}
\usepackage{unicode-math}

% We set the Lucida OTF fonts as default
%\usepackage{luatextra}
\usepackage{fontspec}
\setmainfont{Lucida Bright OT}
\setsansfont{Lucida Sans OT}
\setmonofont{Lucida Console DK}

\newfontfamily\wingdingsfont{Wingdings}
\newcommand\wingdings[1]{{\wingdingsfont\symbol{#1}}}

\newfontfamily\wingdingsfontdos{Wingdings2}
\newcommand\wingdingsdos[1]{{\wingdingsfontdos\symbol{#1}}}

\newfontfamily\wingdingsfonttres{Wingdings3}
\newcommand\wingdingstres[1]{{\wingdingsfonttres\symbol{#1}}}

\usepackage{polyglossia}
\setdefaultlanguage[variant = british, ordinalmonthday = false]{english}

%% using Lucida bright using now free package from PC TeX
%\usepackage[lucidasmallscale,nofontinfo,seriftt=true,math-style=iso]{lucimatx}
%% replace option altbullet
%\renewcommand{\labelitemi}{%
%{\UseTextSymbol{OMS}\textbullet}}
%% needed for Lucida
%\linespread{1.04}

\usepackage{gitinfo2} % remember to setup Git hooks

\usepackage{hologo}

%\usepackage[british]{babel}
\usepackage{csquotes}

\usepackage{graphicx}
\DeclareGraphicsExtensions{.jpg,.pdf,.png}

\usepackage{microtype}
\usepackage[style=authoryear-comp,giveninits,sortcites,maxcitenames=2,%
mincitenames=1,maxbibnames=10,minbibnames=10,backref,uniquename=mininit,%
uniquelist=minyear,sortgiveninits=true,backend=biber]{biblatex}%,refsection=chapter

\usepackage[unicode,hyperindex,bookmarks,pdfview=FitB,%backref,
pdftitle={Notes on using R},%
pdfkeywords={R, statistics, data analysis, plotting},%
pdfsubject={R},%
pdfauthor={Pedro J. Aphalo}%
]{hyperref}

\usepackage{framed}
%\renewenvironment{shaded}{%
% \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
% \MakeFramed{\advance\hsize-\width \FrameRestore\FrameRestore}}%
% {\endMakeFramed}
%\definecolor{shadecolor}{gray}{0.80}

\usepackage{abbrev}
\usepackage{usingr}
%\usepackage{breakurl}
%\usepackage{imakeidx}

\addbibresource{rbooks.bib}
\addbibresource{references.bib}

%\makeindex


\begin{document}

% customize chapter format:
%\KOMAoption{headings}{twolinechapter}
\renewcommand*\chapterformat{\thechapter\autodot\hspace{1em}}

% customize dictum format:
\setkomafont{dictumtext}{\itshape\small}
\setkomafont{dictumauthor}{\normalfont}
\renewcommand*\dictumwidth{0.7\linewidth}
\renewcommand*\dictumauthorformat[1]{--- #1}
%\renewcommand*\dictumrule{}

\extratitle{\vspace*{4\baselineskip}%
{\Huge\textsf{\textbf{Learning R}\\ \textsl{\ldots as you learnt your mother tongue}}}}

\subject{\textsf{Department of Biosciences, University of Helsinki}}

\title{\Huge{\fontseries{ub}\sffamily Learning R\\{\large\ldots as you learnt your mother tongue}}}

\subtitle{Git hash: \gitAbbrevHash; Git tag: \gitVtagn}

\author{Pedro J. Aphalo}

\date{\gitAuthorIsoDate}

\publishers{Unpublished}

\uppertitleback{\copyright\ 2001--2016 by Pedro J. Aphalo\\
Licensed under the \href{http://creativecommons.org/licenses/}{Creative Commons licenses} indicated for each individual article, or when not explicitly indicated, under the \href{http://creativecommons.org/licenses/by-sa/4.0/}{CC BY-SA 4.0 license}.}

\lowertitleback{Typeset with \href{http://www.latex-project.org/}{\XeLaTeX}\ in Lucida Bright and \textsf{Lucida Sans} using the KOMA-Script book class.\\
The manuscript was written using \href{http://www.r-project.org/}{R} with package knitr. The manuscript was edited in \href{http://www.winedt.com/}{WinEdt} and \href{http://www.rstudio.com/}{RStudio}.
The source files for the whole book are available at \url{https://bitbucket.org/aphalo/using-r}.}

\frontmatter

% knitr setup

<<setup, include=FALSE, cache=FALSE>>=
opts_knit$set(child.command = 'include')
opts_knit$set(self.contained=FALSE)
opts_chunk$set(fig.path='figure/pos-', fig.align='center', fig.show='hold', size="footnotesize", dev='cairo_pdf', cache=FALSE)
opts_chunk$set(tidy=FALSE)
options(replace.assign=TRUE,width=50)
@

<<fig-setup, include=FALSE, cache=FALSE>>=
opts_fig_wide <- list(fig.width=9, fig.height=6, out.width='.95\\textwidth')
opts_fig_wide_square <- list(fig.width=6, fig.height=6, out.width='.63\\textwidth')
opts_fig_narrow <- list(fig.width=6, fig.height=4, out.width='.63\\textwidth')
opts_fig_very_narrow <- opts_fig_narrow
opts_fig_medium <- opts_fig_narrow
opts_chunk$set(opts_fig_narrow)
@

<<own-set-up, echo=FALSE, include=FALSE, cache=FALSE>>=
eval_diag <- FALSE
@

<<eval=eval_diag, include=eval_diag, echo=eval_diag, cache=FALSE>>=
opts_knit$get()
search()
getwd()
@


% \thispagestyle{empty}
% \titleLL
% \clearpage

\maketitle

%\frontmatter
%\begin{titlingpage}
% \maketitle
%\titleLL
%\end{titlingpage}

\tableofcontents

%\listoftables

%\listoffigures

%\mainmatter

\chapter*{Preface}

\dictum[Learning like a child]{Do not struggle, just play! If going gets difficult and frustrating, take a break! If you get a new insight, take a break to enjoy the victory!}\vskip2ex

% Such pauses are not a miss use of our time. To learn a natural language we need to interact with other speakers, we need feedback. In the case of R, we can get feedback both from the outcomes from our utterances to the computer, and from other R users.}

This series of Notes covers different aspects of the use of \R. They are meant to be used as a complement to a course or book, as explanations
are rather short and terse. We do not discuss here statistics, just \R as a tool and language for data manipulation and display. The idea is for you to learn the \R language like children learn a language: they work-out what the rules are simply by listening to people speak and trying to utter what they want to tell their parents. I do give some explanations and comments, but the idea of these notes is mainly for you to use the numerous examples to find-out by yourself the overall patterns and coding philosophy behind the \R language. Instead of parents being the sound board for your first utterances in \R, the computer will play this role. You should look and try to repeat the examples, and then try your own hand and see how the computer responds, does it understand you or not?

I recommend you to use as an editor or IDE (integrated development environment) \RStudio. \RStudio is user friendly, actively maintained, and available both in desktop and server versions. The desktop version runs on Windows, Linux, and OS X and other Unixes. In addition it is available for free! \R itself also runs under all these operating systems and a few more. Being \R a command line application in its simplest incarnation, it can be made to work on relatively low computing resources like a personal computer of a couple of decades ago. Nowadays \R can be made to run even on the Raspberry Pi, a Linux micro-controller board with the processing power of a modest smartphone. At the other end of the spectrum on really powerful servers it can be used for the analysis of big data sets with millions of observations.

Do not expect to ever know everything about \R! \R in a broad sense is vast because its capabilities can be expanded with independently developed packages. Currently there are thousands of packages publicly available for free. You just need to learn what you need. Being very popular there is nowadays lots of information available, plus a helpful and open minded on-line community willing to help with those difficult problems for which Goggle will not be of help.

I have been using \R since around 1998 or 1999, but I am still learning new things all the time. With time it has replaced in my work as a researcher and teacher several other pieces of software: \textsf{SPSS}, \textsf{Systat}, \textsf{Origin}, \textsf{Excel}, and it has become a central piece of the tool set I use for producing lecture slides, notes, books and even web pages. This is to say that it is the most useful piece of software and programming language I have ever learnt to use. Of course, in time it will be replaced by something better, but at the moment it is the ``hot'' thing to learn for anybody with a need to analyse and present data.

I hope you find these notes useful, but they are not meant to be read passively. The idea is that you will run all the code examples and try as many other variations as needed until you are sure to understand the rules of the \R language and how each function or command works. In \R for each function, data set, etc. there is a help page available. In addition, if you use \RStudio, auto-completion is available as well as balloon help on the arguments accepted by functions. For scripts, there is syntax checking of the source code before its execution: \emph{possible} mistakes and even formatting style problems are highlighted in the editor window. Error messages tend to be terse in \R, and may require some lateral thinking and/or `experimentation' to understand the real cause behind problems. When you are not sure to understand how some command works, it is useful in many cases to try simple examples for which you know the correct answer and see if you can reproduce them in \R.

Do not expect to find a single answer or approach consistently recommended. Many computations can be done in \R, as in any language, in several different ways, still obtaining the same result. The different approaches may differ mainly in two aspects: 1) how readable to humans are the instructions given to the computer as part of a script or program, and 2) how fast the code will run. Unless performance is an important bottleneck in your work, just concentrate on writing code that is easy to understand to you and to others, and consequently easy to check and reuse. Of course do always check any code you write for mistakes, preferably using actual numerical test cases for any complex calculation. When writing code, as for any other text intended for humans to read, consistent writing style and formatting go a long way in making your intentions clear.

These notes are work-in-progress. I will appreciate suggestions for further examples, notification of errors and unclear sections and also any larger contributions. Many of the examples here have been collected from diverse sources over many years and because of this not all sources are acknowledged. If you recognize any example as yours or someone else's please let me know so that I can add a proper acknowledgement. I warmly thank the students that over the years have asked the questions and posed the problems that have helped me write this text and correct the mistakes and voids of previous versions. I have also received help on on-line forums and in person from numerous people, learnt from archived e-mail list messages, blog posts, books, articles, tutorials, webinars, and by struggling to solve some new problems on my own. In many ways this text owes much more to people who are not authors than to myself. However, as I am the one who has written this version and decided what to include and exclude, as author, I take full responsibility for any errors and inaccuracies.

%\chapter*{Learning like a child}
\mainmatter

<<child-r-intro, child='R.intro.Rnw', eval=TRUE>>=
@

<<child-r-calc, child='R.as.calculator.Rnw', eval=TRUE>>=
@

<<child-r-scripts, child='R.scripts.Rnw', eval=TRUE>>=
@

<<child-r-functions, child='R.functions.Rnw', eval=TRUE>>=
@

<<child-r-data, child='R.data.Rnw', eval=TRUE>>=
@

<<child-r-plotting, child='R.plotting.Rnw', eval=TRUE>>=
@

<<child-r-more-plotting, child='R.more.plotting.Rnw', eval=FALSE>>=
@

<<child-r-maps, child='R.maps.Rnw', eval=FALSE>>=
@

\chapter{Further reading about R}\label{chap:R:readings}

\section{Introductory texts}

\cite{Dalgaard2008,Zuur2009,Teetor2011}

\section{Texts on specific aspects}

\cite{Chang2013,Fox2002,Fox2010,Faraway2004,Faraway2006,Everitt2011}

\section{Advanced texts}

\cite{Xie2013,wickham2015,wickham2014advanced,Pinheiro2000,Murrell2011,Matloff2011,Ihaka1996}

\backmatter

\printbibliography


\end{document}

\appendix

\chapter{Build information}

<<>>=
Sys.info()
@

<<eval=FALSE, echo=FALSE>>=
R.Version()
@

<<>>=
sessionInfo()
@

%

\end{document}
Binary file added using-r-main.pdf
Binary file not shown.
Loading

0 comments on commit 22cc953

Please sign in to comment.