[R] debugging R code and dealing with dependencies
mbmiller+l at gmail.com
Fri Dec 26 04:16:17 CET 2014
On Thu, 25 Dec 2014, David Winsemius wrote:
>> On Dec 25, 2014, at 1:04 AM, Mike Miller <mbmiller+l at gmail.com> wrote:
>> I just wanted to put this out there. It's just some of my observations
>> about things that happen with R, or happened in this particular
>> investigation. There were definitely some lessons for me in this, and
>> maybe that will be true of someone else. The main thing I picked up is
>> that it is good to put plenty of checks into our code -- if we expect
>> input of a certain type or class, then I should either coerce input
>> into that structure or test the input and throw an error. If the
>> function works very differently for different kinds of input, this
>> should be documented. The more people are doing this, the better
>> things will go for everyone.
>> I was working with a CRAN package called RFGLS...
>> ...and I was getting an error. After a few rounds of testing I
>> realized that the error was caused by a FAMID variable that was of
>> character type.
> But The Details section of the help page does say that the accepted
> FTYPES are all integers between 1 and 6 and the INDIV variables are
> integers in range 1:4.
But FAMID and FTYPE are different variables, both required.
>> The problem seemed to be that gls.batch() expected FAMID to be
>> integers, but the default ought to be character type because family and
>> individual IDs in nearly all genetic-analysis software are character
>> strings (they might even be people's names).
> You are making up rules that were not in accord with the documentation.
I think you are confusing FTYPE with FAMID.
>> This was the error:
>> Error in sum(blocksize) : invalid 'type' (character) of argument
>> Calls: gls.batch -> bdsmatrix
>> To figure out more about it, I spent a bunch of time to go from CMD
>> BATCH mode to an interactive session so that I could look at
> Generally the first thing to check is the help page. And if there is a
> worked example to look at its data:
>> data(pedigree, package="RFGLS")
> 'data.frame': 4050 obs. of 5 variables:
> $ FAMID: int 10 10 10 10 20 20 20 20 30 30 ...
> $ ID : int 11 12 13 14 21 22 23 24 31 32 ...
> $ PID : int 14 14 0 0 24 24 0 0 34 34 ...
> $ MID : int 13 13 0 0 23 23 0 0 33 33 ...
> $ SEX : num 1 1 2 1 2 2 2 1 2 2 …
Thanks for your efforts, but you are mistaken. Before I wrote anything
here I had already worked through this with Rob Kirkpatrick, we had run
the data() examples, confirmed the error there, and more.
I was a coauthor of the Human Heredity paper that introduced this software
and it was based on other work I had done. I'm pretty sure I'm the #1
user of this package.
FTYPE != FAMID
Everything I said was correct.
More information about the R-help