Thursday, April 21, 2011

How to load csv data with quantmod in R

In this article I'm going to describe how to load data in an xts object, which is the preferred object to handle time series quantmod from a CSV file. This article is really for beginner (like myself), hopefully those can be helpful to others.

Let's imagine you have some csv data that look like:

First thing you need to make sure is that you column headers have names that contain  Open, High, Low and Close. This will make you life much easier. Secondly, your csv file should only contain dates, and numerical data, otherwise it's kind of a hassle and you have to go and manually convert data afterwards. So  what your data should really look like is:


Personnally I "massaged" the data in R, but you could very well do that in Excel, Perl, Python, or whatever tool you fancy (or simply correct the data at the source ;) ) but for the sake of example this is how I did it:


Now that you have the correct data, it's pretty simple to load :



You're now the proud owner of an xts object that you can start abusing in all the ways you'd like ;)



Hope this helps

Monday, April 18, 2011

How to extract a DEB file

DEB files are ar archives, which contain three files:
  • debian-binary
  • control.tar.gz
  • data.tar.gz
The actual data is contained into data.tar.gz. You can extract it with the following command:
ar p yourfile.deb data.tar.gz | tar xz

Sunday, April 17, 2011

Compiling a linux kernel on a Debian "like" distribution

I recently had to re-compile a kernel, and there's a few preliminaries. You need to install a bunch of packages :

sudo apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge
sudo apt-get install kernel-package

After that you can follow the excellent guide here:

One point which I had missed though is where are the packages once you've finished compiling (although it's written in the guide). So if like they recommend in the you've extracted the kernel source under ~/src/linux-source-2.6.35 for instance, then the deb packages will be in ~/src.


Enjoy.

Sunday, April 10, 2011

Edit Formula: Alternative to F2 for Excel Mac


One of the most used keyboard shortcut is F2, which allows to edit the formula in a cell without using the mouse. Unfortunately that shortcut is different between Office for Mac and Office Windows.

This shortcut was F2 in a PC, but in Excel for Mac it turns into Ctrl + U.  Unfortunately not the most effective shortcut, as it's rather difficult to press Ctrl + U with one hand on most keyboards.


Windows Shortcut: F2

Mac Shortcut: Ctrl + U

Excel Mac: Cell Reference Lock - F4 Alternative


One of the first major problem that I faced when I first began using Excel on a Mac, was the appropriate shortcut replacement for F4, which adds $ signs to cell references to lock cell/range references from moving if dragged to another cell. After a great deal of frustration, and after trawling a number of excel forums I eventually found the solution which is shown below.

Windows ShortcutF4

Mac Shortcut : Cmd + T