[R-sig-eco] Using the mra package in R...

Adam Fawcett adam.fawcett at mq.edu.au
Mon Aug 26 08:01:04 CEST 2013


Hi Sarah and all

Thanks for those couple of tips. They did help to show that the data
imported alright but that there was a distinct difference between my data
set and the example data set for used to demonstrate the mra package.

I have attached subset of my data as suggested. Its formatted as a
tab-delimited text file with row names included (bird band numbers). I have
tried importing with and without row names but this doesn't appear to make
any difference.

To import to R, I have been using the following process.

brtb <- read.table (file="filepath\\brtb.txt", header = TRUE, row.names =
1, sep = "", colClasses="numeric")

Inspecting the data using str(brtb) provides the following

'data.frame':	65 obs. of  19 variables:
 $ C1 : num  0 0 0 0 0 0 0 0 1 1 ...
 $ C2 : num  1 1 0 0 0 0 0 0 0 0 ...
 $ C3 : num  1 0 1 1 1 1 1 1 0 0 ...
 $ C4 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C5 : num  0 0 0 0 1 0 0 0 0 0 ...
 $ C6 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C7 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C8 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C9 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C10: num  0 0 0 0 0 0 0 0 1 0 ...
 $ C11: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C12: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C13: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C14: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C15: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C16: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C17: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C18: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C19: num  0 0 0 0 0 0 0 0 0 0 ...

The comparative example I am looking at from the mra package is the
dipper.histories data. Inspecting this with str(dipper.histories) provides
the following

 num [1:294, 1:7] 1 1 1 1 1 1 1 1 1 1 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:294] "1" "2" "3" "4" ...
  ..$ : chr [1:7] "h1" "h2" "h3" "h4" ...

There is an obvious difference in the returned output from the str()
function. Inspection of both data frames shows they are formatted in a
similar way, or at least appear to be.

With respect to the function I am attempting to run in mra, I have run the
examples routines as described in the mra manual using the supplied data.
Results as described. In attempting this on any of my own data as attached
I get an error message. The function I am trying to run is as follows

brtb.cjs = F.cjs.estim(
~x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17+x18,
~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17, brtb)


Each time I get the following error

Error in F.cjs.estim(~x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 +  :
  Capture histories must consist of 0's, 1's, and 2's only.

I have checked thru the data-set to make sure the data matches these
requirements, that there are no additional characters in the data-set, etc.
and keep getting the same error. Have tried a different subsets of the
data, different import options, etc. but still no success.

Am assuming the error lies with the format of the data imported to R but
cannot work out where or how to adjust to match the example.

Any suggestions or advice on this one would be greatly appreciated.

Cheers

Adam...


On 25 August 2013 23:33, Sarah Goslee <sarah.goslee at gmail.com> wrote:

> Hi,
>
> The first thing to do is str(yourdata) to double-check that your data
> import worked as expected. Particularly check that your data column isn't
> actually of mode factor.
>
> If that doesn't give you a lead on solving the problem, posting a
> reproducible example here with a subset of your data provided using dput()
> and the actual code you used will get you concrete answers, rather than
> random guesses.
>
> Sarah
>
>
> On Sunday, August 25, 2013, Adam Fawcett wrote:
>
>> Have been trying to analyse life history data collected from a long term
>> mark-recapture study of birds using the package mra. While the analysis
>> works fine on the supplied example dataset, I keep getting error messages
>> when running my data thru the F.cjs.estim function. Error message states
>> that the data for this analysis must be either 1, 2 or0's. Have triple
>> checked my data and its all 1 & 0's as required.
>>
>> Problems is likely to be an issue with either the read.table function to
>> import my data (all correctly formatted and transformed ready for the
>> analysis, possibly adding a character I have been able to remove, or with
>> the mra package itself.
>>
>> Does anyone have experience using mra that could lend some advice.
>> Alternatively, has anyone struck this sort of problem before that could
>> suggest how to correct the problem.
>>
>> -
>>
>
>
> --
> Sarah Goslee
> http://www.stringpage.com
> http://www.sarahgoslee.com
> http://www.functionaldiversity.org
>



-- 

*Adam Fawcett
**Lecturer (GSE854 and GSE856)
*Department of Environment and Geography
Macquarie University
NSW 2109 Australia

M: + 61 427 929 554
 <http://mq.edu.au>mq.edu.au


CRICOS Provider Number 00002J

Please consider the environment before printing this email.
 This email (including all attachments) is confidential. It may be subject
to legal professional privilege and/or protected by copyright. If you
receive it in error do not use it or disclose it, notify the sender
immediately, delete it from your system and destroy any copies. The
University does not guarantee that any email or attachment is secure or
free from viruses or other defects. The University is not responsible for
emails that are personal or unrelated to the University’s functions.
-------------- next part --------------
	C1	C2	C3	C4	C5	C6	C7	C8	C9	C10	C11	C12	C13	C14	C15	C16	C17	C18	C19
1845902	0	1	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1845935	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1845937	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1845970	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1845984	0	0	1	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1845986	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1845993	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1845997	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1933305	1	0	0	0	0	0	0	0	0	1	0	0	0	0	0	0	0	0	0
1933307	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1933309	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1933312	1	0	1	0	0	0	0	0	0	1	0	0	0	0	0	0	0	0	0
1933321	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1933333	1	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1933360	1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	0	1
1942632	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	1
1942859	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	1	0


More information about the R-sig-ecology mailing list