Archive

Posts Tagged ‘primer’

Installing ESS (Emacs Speaks Statistics)

20 April 2011 Leave a comment

Problem

You have a non-standard directory under which you install software. You have installed Emacs under this directory. Now you want to install ESS under this directory as well so that Emacs could interact with R.

Solution

Suppose your non-standard directory is

/scratch/username/usr

where username is your actual username. I assume that you have installed both Emacs and R under this directory. Download ESS and extract the downloaded tarball to

/scratch/username/usr/share/emacs/site-lisp

Edit your /home/username/.emacs by inserting the following lines:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;     
;; ESS: Emacs Speaks Statistics, mainly for R
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;     

(load "/scratch/username/usr/share/emacs/site-lisp/ess-x.y.z/lisp/ess-site")
(setq inferior-R-program-name "/scratch/username/usr/bin/R")

Remember to replace “x.y.z” with the actual version number of ESS that you use. Now load Emacs and to use R from Emacs, enter the command

M-x R

This should bring up an R session from within Emacs. Here’s a screenshot for your viewing pleasure:

Typeset trees using TikZ/PGF

31 March 2011 Leave a comment

Some combinatorial trees typeset using TikZ/PGF. The Linux filesystem hierarchy:

The Linux filesystem hierarchy.

\begin{tikzpicture}
[-,thick]
\footnotesize
\node {\texttt{/}} [edge from parent fork down]
  child {node {\texttt{bin}}}
  child {node {\texttt{etc}}}
  child {node {\texttt{home}}
    child {node {\texttt{anne}}}
    child {node {\texttt{sam}}}
    child {node {$\dots$}}
  }
  child {node {\texttt{lib}}}
  child {node {\texttt{opt}}}
  child {node {\texttt{proc}}}
  child {node {\texttt{tmp}}}
  child {node {\texttt{usr}}
    child {node {\texttt{bin}}
      child {node {\texttt{acyclic}}}
      child {node {\texttt{diff}}}
      child {node {\texttt{dot}}}
      child {node {\texttt{gc}}}
      child {node {\texttt{neato}}}
      child {node {$\dots$}}
    }
    child {node {\texttt{include}}}
    child {node {\texttt{local}}}
    child {node {\texttt{share}}}
    child {node {\texttt{src}}}
    child {node {$\dots$}}
  }
  child {node {$\dots$}};
\end{tikzpicture}

Classification tree of organisms:
Classification tree of organisms.

\begin{tikzpicture}
[sibling distance=6cm,-,thick]
\footnotesize
\node {organism}
  child {node {plant}
    [sibling distance=2cm]
    child {node {tree}
      child {node {deciduous}}
      child {node {evergreen}}
    }
    child {node {flower}}
  }
  child {node {animal}
    [sibling distance=2.5cm]
    child {node {invertebrate}}
    child {node {vetebrate}
      [sibling distance=4.7cm]
      child {node {bird}
        [sibling distance=1.5cm]
        child {node {finch}}
        child {node {rosella}}
        child {node {sparrow}}
      }
      child {node {mammal}
        [sibling distance=1.5cm]
        child {node {dolphin}}
        child {node {human}}
        child {node {whale}}
      }
    }
  };
\end{tikzpicture}

The Bernoulli family tree of mathematicians:
Bernoulli family tree of mathematicians.

\begin{tikzpicture}
[-,thick,%
  every node/.style={shape=rectangle,inner sep=3pt,draw,thick}]
\footnotesize
\node {Nikolaus senior} [edge from parent fork down]
  [sibling distance=4cm]
  child {node {Jacob}}
  child {node {Nicolaus}
    child {node {Nicolaus I}}
  }
  child {node {Johann}
    [sibling distance=2cm]
    child {node {Nicolaus II}}
    child {node {Daniel}}
    child {node {Johann II}
      child {node {Johann III}}
      child {node {Daniel II}}
      child {node {Jakob II}}
    }
  };
\end{tikzpicture}

An expression tree:

Expression tree for the perfect square identity.

\begin{tikzpicture}
[-,thick]
\node {$+$}
  [sibling distance=2.5cm]
  child {node {$\times$}
    [sibling distance=1cm]
    child {node {$a$}}
    child {node {$a$}}
  }
  child {node {$\times$}
    [sibling distance=1cm]
    child {node {$2$}}
    child {node {$a$}}
    child {node {$b$}}
  }
  child {node {$\times$}
    [sibling distance=1cm]
    child {node {$b$}}
    child {node {$b$}}
  };
\end{tikzpicture}

Simple graphs, bridges of Konigsberg and directed graphs

26 March 2011 Leave a comment

Some combinatorial graphs drawn using TikZ/PGF. The seven bridges of Konigsberg:

Seven bridges of Konigsberg

\begin{tikzpicture}
[lineDecorate/.style={-,thick},%                                                
  nodeDecorate/.style={shape=circle,inner sep=2pt,draw,thick}]
%% nodes or vertices                                                            
\foreach \nodename/\x/\y/\direction/\navigate in {
  a/0/0/left/west, b/0/2/left/west, c/0/4/left/west, d/4/2/right/east}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {};
  \node [\direction] at (\nodename.\navigate) {\footnotesize$\nodename$};
}
%% edges or lines                                                               
\path
\foreach \startnode/\endnode in {a/d, b/d, c/d}
{
  (\startnode) edge[lineDecorate] node {} (\endnode)
}
\foreach \startnode/\endnode in {a/b, b/c, c/b, b/a}
{
  (\startnode) edge[lineDecorate,bend left] node {} (\endnode)
};
\end{tikzpicture}

A house graph:

House graph

\begin{tikzpicture}
[lineDecorate/.style={-,thick},%                                                
  nodeDecorate/.style={shape=circle,inner sep=2pt,draw,thick}]
%% nodes or vertices                                                            
\foreach \nodename/\x/\y/\direction/\navigate in {
  a/0/5/above/north, b/2/3/right/east, e/-2/3/left/west,
  c/2/0/right/east, d/-2/0/left/west}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {};
  \node [\direction] at (\nodename.\navigate) {\footnotesize$\nodename$};
}
%% edges or lines                                                               
\path
\foreach \startnode/\endnode in {a/b, b/c, b/e, c/d, d/e, e/a}
{
  (\startnode) edge[lineDecorate] node {} (\endnode)
};
\end{tikzpicture}

A weighted multigraph:
Weighted multigraph

\begin{tikzpicture}
[nodeDecorate/.style={shape=circle,inner sep=1pt,draw,thick}]
%% nodes or vertices                                                            
\foreach \nodename/\x/\y in {v_1/4/0, v_2/0/0, v_3/0/3, v_4/4/3, v_5/7/1.5}
{
  \node (\nodename) at (\x,\y) [nodeDecorate] {\scriptsize$\nodename$};
}
%% edges or lines                                                               
\tikzstyle{EdgeStyle}=[->,>=stealth,thick]
\tikzstyle{LabelStyle}=[fill=white]
\foreach \startnode/\endnode/\bend/\weight in {
  v_1/v_2/bend left/1, v_1/v_3/bend left/3, v_2/v_3/bend left/1,
  v_2/v_4/bend left/3, v_3/v_1/bend left/1, v_3/v_2/bend left=0/2,
  v_3/v_4/bend left/1, v_4/v_1/bend left=0/3, v_4/v_5/bend left/2,
  v_5/v_1/bend left=0/3, v_5/v_1/bend left/6, v_5/v_4/bend left/1}
{
  \scriptsize
  \Edge[label=$\weight$,style=\bend](\startnode)(\endnode)
}
\end{tikzpicture}
Follow

Get every new post delivered to your Inbox.