Blog Archives

Sustainability of water use in agriculture

March 9, 2014
By
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

Read more »

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

March 11, 2012
By

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.      Make orgmode export to latex using xetex rather than

Read more »

ave

February 8, 2009
By

I discovered a new, very useful, R function yesterday: ave. This is what it does: “Subsets of ‘x‘ are averaged, where each subset consist of those observations with the same factor levels.” But interestingly, you can use any function other than average. The output of that function is set against each observation. I wanted

Read more »

Heteroscedasticity

April 6, 2008
By

If a model is estimated using the following code: lm(y~x1+x2)->p 1. bptest(p) does the Breuch Pagan test to formally check presence of heteroscedasticity. To use bptest, you will have to call lmtest library. 2. If the test is positive (low p value), you should see if any transformation of the dependent variable helps you eliminate

Read more »

Find type of variables in a data frame

February 20, 2008
By

sapply(a,class) gives type of field (character, numeric, or factor) for each variable in the data frame a.

Read more »

Moving average/median

January 7, 2008
By

?rollmean (package=zoo)?rollmedian (package=zoo)?runmed (package=stats)

Read more »

“relevel” factors when using them to create dummy variables

June 28, 2007
By

?relevel : The levels of a factor are re-ordered so that the level specified by ‘ref’ is first and the others are moved down. This is useful for ‘contr.treatment’ contrasts which take the first level as the reference.

Read more »

Working with ggplot, version 2

June 6, 2007
By

In my previous post on this issue, I had presented a code that made weighted boxplots and annotated them with boxplot statistics and the mean values. The problem with that code was that it printed these annotations right on the vertical axes of the boxplots. Also, a relatively minor problem was that, when the values

Read more »

Reading large tables into R

April 8, 2007
By

Here are some useful tips on the issue. V.

Read more »

Reading data from microsoft access files in linux

March 28, 2007
By

Some of the Census 2001 data are in microsoft access files (having filename extensions .mdb). A microsoft access file can have several tables inside, each of which contains data. There is a software called mdbtools that can be used to read access files. The command mdb-tables can be used to see the names of tables

Read more »