A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

Using Emacs, Org-mode and R for Research Writing

This guide presents a toolkit for writing research papers and monographs using Emacs, Org-mode and R.

Org-mode allows embedding statistical code in the document to generate results that can be revised and reproduced, integration of bibliographic references with a database, and consistent formatting without any manual tweaking using excellent support for creation of pdf, odt, docx, html and many other types of files.


Grab a PDF version here.

Scheduled operations on Gmail

This is very useful for dealing with mass emails that you only want to retain temporarily in your Gmail inbox.

Create time-based Gmail filters with Google Apps Script | johnedayjohneday.

Sustainability of water use in agriculture

AQUASTAT, developed and maintained by the Food and Agriculture Organization of the UN, is the global database that gives quantitative information on water resources and withdrawal of water for different uses.

Agricultural water withdrawal is defined as follows:

Annual quantity of self-supplied water withdrawn for irrigation, livestock and aquaculture purposes. It includes water from primary renewable and secondary freshwater resources, as well as water from over-abstraction of renewable groundwater or withdrawal of fossil groundwater, direct use of agricultural drainage water and (treated) wastewater, and desalinated water. Water for the dairy and meat industries and industrial processing of harvested agricultural products is included under industrial water withdrawal.

Total water withdrawal is defined as follows:

Annual quantity of water withdrawn for agricultural, industrial and municipal purposes. It includes renewable freshwater resources as well as potential over-abstraction of renewable groundwater or withdrawal of fossil groundwater and potential use of desalinated water or treated wastewater. It does not include in stream uses, which are characterized by a very low net consumption rate, such as recreation, navigation, hydropower, inland capture fisheries, etc.

The following map shows water withdrawal for agriculture as a percentage of total water withdrawal in different countries. The indicator needs to be interpreted with care. It reflects relative importance of agriculture in a country, importance of irrigation in the agro-climatic environment, and extent of developent of irrigation.

Agricultural water withdrawal as a percentage of total water withdrawal, by country, latest years

Agricultural water withdrawal as a percentage of total water withdrawal, by country, latest years

The second map below shows total water withdrawal as a percentage of total actual renewable water resources of a country. Total actual renewable water resources are defined as follows:

The sum of internal renewable water resources (IRWR) and external actual renewable water resources (ERWR_actual). It corresponds to the maximum theoretical yearly amount of water actually available for a country at a given moment.

Further details on concepts and methodology of estimation of water resources are provided in this document.

It is usually believed that it is sustainable for a country to use up to 60-75 per cent of renewable water resources for human needs; and leave the rest for the environment. As the map below shows, AQUASTAT has no data on amount of renewable water resources for most countries. As a result, it is difficult to say very much on the basis of AQUASTAT.

Total water withdrawal as a percentage of renewable water resources, by country, latest data

Total water withdrawal as a percentage of renewable water resources, by country, latest data


(Acknowledgements: Maps made with R and ggplot2. World map from cshapes. Data on water from AQUASTAT)

Romania’s peasants: standing in the way of foreign investors making a lot of money | Luke Dale-Harris

Romania’s peasants: standing in the way of foreign investors making a lot of money | Luke Dale-Harris.

The peasant farming economy has long been eroding under the open-market policies pushed by the European Union and the Romanian state. Squeezed out of the market by the agri-investment giants who take the bulk of the EU’s common agricultural policy subsidies, small farmers are facing a difficult choice: sell up and move west to look for work, or hold tight and navigate a life of increasing rural poverty.

Millennium development goals: big ideas, broken promises? – interactive | Global development | theguardian.com

Millennium development goals: big ideas, broken promises? – interactive | Global development | theguardian.com.

Very well presented.

Freeing the world from hunger


The Bali ministerial conference in December presents a crucial opportunity to bring about changes in WTO rules, by which developing countries can support small farmers and move towards eliminating hunger.

Guidelines for soil description

Guidelines for soil description

An excellent book from FAO on different aspects of soils and their classifications.

Changes in the Distribution of Operational Landholdings in Rural India

This paper, in the Review of Agrarian Studies, analyses National Sample survey data on changes in the distribution of operational holdings of land, using data from NSS surveys on employment and unemployment. The paper discusses the limitations of these statistics in some detail. Four main points emerge from the analysis: there has been a sharp rise in landlessness in rural India; caste disparities in access to land have persisted over time; there has been a rise in inequality in distribution of land cultivated by households; and there has been a decline in the proportion of manual labour households that combined wage labour with cultivation of small holdings. Finally, statistics on land distribution at the State level reveal some puzzling features – some of which point to possible errors in data collection.

Statistics on Indian Economy and Society


A lot of statistics on Indian economy and society are available online. These are scattered across various websites and are mostly provided without any information on the sources, data definitions and limitations of these statistics.

This website was conceived as a platform to host statistics on different aspects of the economy and society. The website aims to differentiate itself from other sources on following counts:

  • indianstatistics.org will combine dissemination of data with documentation about the data and critical analysis of problems related to the use of these statistics. The website will provide references, and where possible, online links, to scholarly analyses about these data and analyses based on these data.
  • indianstatistics.org will build an archive of documents related to the statistical system of India.
  • indianstatistics.org will also build an archive of important non-official data and documents related to Indian economy and society.
  • indianstatistics.org will acknowledge accurately all original sources of data and documents hosted on the website.
  • indianstatistics.org will only host data and documents that are publicly available, or data and documents for which the provider has specifically authorised indianstatistics.org to disseminate data.
  • indianstatistics.org will provide all data and documents free of cost.
  • indianstatistics.org will also provide links to external sources of data. However, in such cases, the accuracy of data, the format in which these data are provided and the issues of copyright are not a responsibility of indianstatistics.org

Customising the look of beamer presentations created using orgmode

Some examples of how to customise the look of beamer presentations created using orgmode.

1. Changing the colors.

#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw} \usecolortheme{beaver} \usefonttheme{serif} \setbeamertemplate{caption}[numbered] \useinnertheme{circles}
#+BEAMER_HEADER_EXTRA: \setbeamercolor{title}{fg=green!40!black}
#+BEAMER_HEADER_EXTRA: \useoutertheme{split}
#+BEAMER_HEADER_EXTRA: \setbeamercolor{section in head/foot}{fg=green!50!black}
#+BEAMER_HEADER_EXTRA: \setbeamercolor{subsection in head/foot}{fg=green!50!black}
#+BEAMER_HEADER_EXTRA: \setbeamercolor{item}{fg=green!50!black}

2. Adding logo on the title frame. (Replace unilogo with name of the file containing your logo. The extension is not necessary.)

#+LATEX_HEADER: \titlegraphic{\includegraphics[width=1cm,height=1cm]{unilogo}}

3. Adding logo on the top right of each frame (adapted from the solution provided here).

#+LATEX_HEADER: \usepackage[absolute,overlay]{textpos}
#+LATEX_HEADER:\setlength{\TPHorizModule}{1mm} \setlength{\TPVertModule}{1mm}
#+LATEX_HEADER: \newcommand{\MyLogo}{\begin{textblock}{14}(0.8,0.8) \includegraphics[width=0.8cm]{unilogo} end{textblock}}

The last line defines a command MyLogo which inserts the logo. Once again, replace unilogo with name of the file containing your logo. The extension is not necessary.

To run this command on every frame, I add the following to every frame.

#+LATEX: {\MyLogo}

Hindi/Devanagari presentations using orgmode, R, latex and beamer

I recently had to prepare a beamer presentation in hindi/devanagari. I usually use emacs-orgmode  with a lot of R source code embedded in it to prepare my beamer presentations. To adapt the entire setup to work with devanagari, this is what I needed to do.


  1. Make orgmode export to latex using xetex rather than pdflatex.Instructions on how to make orgmode export through xetex are here.
  2. I have following in my .emacs (taken straight from the website mentioned above)

    (require 'org-latex)
    (setq org-export-latex-listings t)
    ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
    ;; but adapted to use latexmk 4.20 or higher.
    (defun my-auto-tex-cmd ()
      "When exporting from .org with latex, automatically run latex,
         pdflatex, or xelatex as appropriate, using latexmk."
      (let ((texcmd)))
      ;; default command: oldstyle latex via dvi
      (setq texcmd "latexmk -dvi -pdfps -quiet %f")
      ;; pdflatex -> .pdf
      (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
          (setq texcmd "latexmk -pdf -quiet %f"))
      ;; xelatex -> .pdf
      (if (string-match "LATEX_CMD: xelatex" (buffer-string))
          (setq texcmd "latexmk -pdflatex=xelatex -pdf -quiet %f"))
      ;; LaTeX compilation command
      (setq org-latex-to-pdf-process (list texcmd)))
    (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
    ;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
    (setq org-export-latex-packages-alist
          '(("" "graphicx" t)
                ("" "longtable" nil)
                ("" "float" nil)))
    (defun my-auto-tex-parameters ()
          "Automatically select the tex packages to include."
          ;; default packages for ordinary latex or pdflatex export
          (setq org-export-latex-default-packages-alist
                '(("AUTO" "inputenc" t)
                  ("T1"   "fontenc"   t)
                  (""     "fixltx2e"  nil)
                  (""     "wrapfig"   nil)
                  (""     "soul"      t)
                  (""     "textcomp"  t)
                  (""     "marvosym"  t)
                  (""     "wasysym"   t)
                  (""     "latexsym"  t)
                  (""     "amssymb"   t)
                  (""     "hyperref"  nil)))
          ;; Packages to include when xelatex is used
          (if (string-match "LATEX_CMD: xelatex" (buffer-string))
              (setq org-export-latex-default-packages-alist
                    '(("" "fontspec" t)
                      ("" "xunicode" t)
                      ("" "url" t)
                      ("" "rotating" t)
                      ("american" "babel" t)
                      ("babel" "csquotes" t)
                      ("" "soul" t)
                      ("xetex" "hyperref" nil)
          (if (string-match "LATEX_CMD: xelatex" (buffer-string))
              (setq org-export-latex-classes
                    (cons '("article"
                            ("\\section{%s}" . "\\section*{%s}")
                            ("\\subsection{%s}" . "\\subsection*{%s}")
                            ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                            ("\\paragraph{%s}" . "\\paragraph*{%s}")
                            ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
    (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
    (setq org-latex-to-pdf-process
          '("xelatex -interaction nonstopmode -output-directory %o %f"
           "xelatex -interaction nonstopmode -output-directory %o %f"
           "xelatex -interaction nonstopmode -output-directory %o %f"))

    Having done this, I need the following line in my org file header to tell org that it should use xetex instead of pdflatex.

    #+LATEX_CMD: xelatex
  3. xetex can use ttf fonts. We need to specify a font that has devanagari characters. On debian, ‘apt-get install ttf-devanagati-fonts’ installs several devanagari fonts. I could use them but my problem was that I could not find a font of which I liked both the devanagari and the roman characters. I wanted to use different fonts for devanagari and roman letters and, thus, needed a way of telling xetex to use different fonts for roman and devanagari characters. The solution for this, provided by Zdenek Wagner on the xetex mailing list, lies in installing and using ucharclasses.
  4. After ucharclasses was installed, this was achieved by adding following lines to the header of the org file.

    #+LATEX_HEADER: \usepackage{fontspec};
    ## The following lines allow me to use Garamond for roman letters and Sarai for devanagari letters.
    #+LATEX_HEADER: \usepackage[Devanagari]{ucharclasses}
    #+LATEX_HEADER: \setmainfont{Garamond}
    #+LATEX_HEADER: \setTransitionTo{Devanagari}{\fontspec[Script=Devanagari]{Sarai}}
  5. Type devanagari in emacs. Emacs has fantastic support for this.
  6. C-x C-m C-\ devanagari- TAB (pick whatever, I like devanagari-itrans)
    C-h C-\ (gives you the keymap)
    C-\ (to switch to English again)
    C-\ (to switch to devanagari)

    (thanks Jambunathan K. and Suvayu Ali for pointing this out on orgmode mailing list)

  7. Modify my R src codes to produce text in devanagari rather than in english. In most cases, I only had to rename factor levels and variables names in the final tables, so that output tables had text in devanagari. orgmode and xetex handled the rest.
  8. The following line in file header replaces “Table” in Table caption numbering with तालिका

    #+LATEX_HEADER: \renewcommand{\tablename}{तालिका}
  9. For graphs to have text in devanagari, I had to use the tikz device in R rather than the standard pdf device to create the pdfs. tikz device produces code that can be understood by the TikZ graphics language. All text in a graphic output with the tikz() function can be typeset by LaTeX and therefore will match whatever fonts are currently used in the document. The output of tikz device is a tex file that, using xetex and tikz, produces the desired graphic. I include that tex file into the beamer presentation.
  10. Here is sample code that achieves this:

    #+CAPTION: ग्राफ का नमूना
    #+Latex: {\footnotesize
    #+LATEX: }
    #+BEGIN_SRC R :results output silent
          tikz(file="lorcurve.tex",width=6,height=3,engine="xetex",standAlone = FALSE)

Unison Makes Two-Way File Sync Simple | Wazi

Unison Makes Two-Way File Sync Simple | Wazi.

“Unison is a powerful file and directory synchronization tool that, unlike popular tools like rsync, can perform two-way synchronization. With Unison, you can sync files between your work computer and home desktop, and any changes done at one machine will be reflected at the other.”

Pipes in Unix Based Operating Systems

LXer Linux News

Pipes in Unix Based Operating Systems.

Gnome, xfce….

Debian finally has gnome3 in its unstable repository. Given that there has been a lot of adverse commentary on gnome3, I am not sure if I am going to like it. At the same time, I have been very curious and wanted to try it.

This is what I did.

  1. Shifted to xfce about a week ago. That was fairly smooth. I liked xfce.
  2. Installed gnome3 from unstable repositories yesterday. With apt-pinning, I mix and match packages from testing and unstable. It just took:
    apt-get update && apt-get -t unstable install gnome-session

I could not, however, login to gnome and had to use gnome-fallback.

With my intel graphics card, I still need to login to gnome-fallback. Open a terminal, and do “export GNOMESHELLDISABLE_TFP=1″. Then, alt-f2 and do “gnome-shell –replace”.

With this, I have gnome-shell.

Needed to fix extensions, install gnome-tweak-tool and several things like that. But I do, finally, have gnome3 on my computer.

Like it? Don’t know yet.

Problems that remain:

  1. Mouse is sluggish. Freezes for a few moments and I have to bang the touchpad to wake it up.

  2. Can’t turn off sounds of events. Does not respect ‘mute’ in settings.


For the record: I shifted to xfce on the third day and have been a happy user of it since then.

Interesting stuff on how to use SSH effectively