help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handling strings


From: Mike Miller
Subject: Re: handling strings
Date: Tue, 13 Sep 2005 10:42:21 -0500 (CDT)

On Tue, 13 Sep 2005, Stefan van der Walt wrote:

To read in the data, you might want to take a look at 'textread' in octave-forge (recently, a C++ version was submitted).

It shouldn't be difficult to modify it to do your string comparisons as well.


Very nice! It does work well for me. I am actually using it to read in pedigree data for genetic analyses. When sex is designated by integers (usually 1=male, 2=female), this seems to always work very nicely:

[fam,indiv,father,mother,sex] = textread("file.ped", "%s %s %s %s %d%*[^\n]");

After that, a series of strcmp commands can be used to do the work of recoding fam, father and mother.

One oddity is that sex (the %d column) becomes a row vector instead of a column vector. That's OK now that I know about it, but I think it would make more sense for columnar data to be stored by default in column vectors.

Thanks again for a great tip!

Mike

--
Michael B. Miller, Ph.D.
Assistant Professor
Division of Epidemiology and Community Health
and Institute of Human Genetics
University of Minnesota
http://taxa.epi.umn.edu/~mbmiller/



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]