Archive for August, 2011

August 30, 2011

Convert Date-Time in Excel to POSIXct

This is an one-liner to convert a (numeric) date-time column from Excel to POSIXct:

rdatetime <- as.POSIXct( exceldatetime*24*3600 + as.POSIXct("1899-12-30 00:00") )

August 24, 2011

A BibTex Style File for Statistics in Medicine

The journal Statistics in Medicine does not provide an official BibTex style file. I know people who just manually formatted each references inside the latex file. I found an unofficial style file here.

With the bst file, there are still a couple extra steps to get the references with the format required by the journal.

  1. Open the Statinmed.bst file, change Line 446 “{vv~}{ll}{, f{}}{, jj}” to “{vv~}{ll}{ f{}}{ jj}”. This will remove the comma between last name and initials.
  2. In the main latex file, add the following commands to the preamble:

    \usepackage[numbers, sort&compress]{natbib}
    \makeatletter % Reference list option change
    \renewcommand\@biblabel[1]{#1.} % from [1] to 1.
    \makeatother %

    That will use the numeric reference style and remove square brackets in the list of references. The trick for removing square brackets is from Ki-Joo Kim’s A BibTEX Guide via Examples.

P.S. Thanks to Servien for pointing out the sort&compress option for natbib.