[R] package FD

Jim Lemon drjimlemon at gmail.com
Sat Mar 5 10:38:46 CET 2016


Hi Fabio,
What has probably happened is that ft$trait3 looks like numbers but
when it was read in at least one value could not be read as a number.
The default behavior in R is to transform the variable into a factor:

testcase<-read.table(text="1 2 3 4
 1 2 3 4
 1 2 B 4")
> testcase
 V1 V2 V3 V4
1  1  2  3  4
2  1  2  3  4
3  1  2  B  4
> sapply(testcase,class)
      V1        V2        V3        V4
"integer" "integer"  "factor" "integer"

So testcase$V3 was read in as a factor. There are a couple of things
you can do. First, try to convert the factor to numeric and live with
the NA values that will be generated:

as.numeric(as.character(testcase$V3))
[1]  3  3 NA
Warning message:
NAs introduced by coercion

If the number of non0numeric values in the original data is small and
you can find them:

testcase$V3[3]<-3
as.numeric(as.character(testcase$V3))
[1] 3 3 3

correct the original data and read it in again. I don't really know
enough to answer your second question.

JIm


On Sat, Mar 5, 2016 at 2:58 AM, Fabio Monteiro
<fabio.monteiro1992 at gmail.com> wrote:
> I still have another question. apart from that one
>
> in the dbFD function in FD package there is one option which is if FRic
> should be standardized or not. What does that mean? Why should our shouldn't
> I have the FRic Standardized?
>
> Thank you Jim
>
> 2016-03-04 14:52 GMT+00:00 Fabio Monteiro <fabio.monteiro1992 at gmail.com>:
>>
>> class(ft$trait3)
>> [1] "factor
>>
>>
>> Yes is a factor. And now?
>>
>> Thank you
>>
>> Kind Regards
>> Fábio
>>
>> 2016-03-04 7:15 GMT+00:00 Jim Lemon <drjimlemon at gmail.com>:
>>>
>>> Hi Fabio,
>>> You should write:
>>>
>>> class(...)
>>>
>>> where ... is the same as what you would type to have the variable
>>> displayed on the console. Looking at your earlier message, it might
>>> be:
>>>
>>> x$trait3
>>>
>>> so try:
>>>
>>> class(x$trait3)
>>>
>>> Jim
>>>
>>>
>>> On Fri, Mar 4, 2016 at 11:30 AM, Fabio Monteiro
>>> <fabio.monteiro1992 at gmail.com> wrote:
>>> > i just called trait3 to my variable.
>>> >
>>> > Is this what i'm suppose to wright? class(trait3), or class
>>> > (my_trait3_variable?
>>> >
>>> > both give error
>>> >
>>> > 2016-03-03 23:42 GMT+00:00 Jim Lemon <drjimlemon at gmail.com>:
>>> >>
>>> >> Hi Fabio,
>>> >> It is possible that your remaining "numeric" variable is a factor.
>>> >> What
>>> >> does:
>>> >>
>>> >> class(my_numeric_variable)
>>> >>
>>> >> say? (where you substitute the name of your "numeric" variable)
>>> >>
>>> >> Jim
>>> >>
>>> >>
>>> >> On Fri, Mar 4, 2016 at 2:25 AM, Fabio Monteiro
>>> >> <fabio.monteiro1992 at gmail.com> wrote:
>>> >> > Hello, my name is Fábio and I'm a Marine Ecology student in
>>> >> > Portugal.
>>> >> >
>>> >> > I'm currently using the FD package for my work and yesterday one
>>> >> > message
>>> >> > appeared that I wasn't expecting and I really need your help to try
>>> >> > to
>>> >> > figure out what's happening.
>>> >> > I'm using the dbFD function and the following message appeared:
>>> >> >
>>> >> > FRic: Only categorical and/or ordinal trait(s) present in 'x'. FRic
>>> >> > was
>>> >> >  measured as the number of unique trait combinations, NOT as the
>>> >> > convex
>>> >> > hull volume.
>>> >> > FDiv: Cannot be computed when only categorical and/or ordinal
>>> >> > trait(s)
>>> >> > present in 'x'.
>>> >> >
>>> >> > My data:
>>> >> > x is a matrix with species vs functional traits
>>> >> > a is a matrix with species vs sampling (in abundances)
>>> >> >
>>> >> > Previously I used the dbFD function and was working just fine.
>>> >> > Yesterday
>>> >> > I
>>> >> > removed 2 traits and this message appeared.
>>> >> >
>>> >> > My traits now are 3 categorical traits and 1 numeric. The 2 trais
>>> >> > that I
>>> >> > removed were numeric traits as well. I really need to remove those
>>> >> > trait,
>>> >> > but I still need the FDiv to be calculated. Can you explain to me
>>> >> > why is
>>> >> > this error occurring? I need to know how the dbFD is measuring the
>>> >> > indexes
>>> >> > so I can understanding the error and if I can or can't continue to
>>> >> > use
>>> >> > this
>>> >> > package (if it applies or not to my goals)
>>> >> >
>>> >> > Kind regards
>>> >> >
>>> >> > Fábio Monteiro
>>> >> >
>>> >> >         [[alternative HTML version deleted]]
>>> >> >
>>> >> > ______________________________________________
>>> >> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> >> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> >> > PLEASE do read the posting guide
>>> >> > http://www.R-project.org/posting-guide.html
>>> >> > and provide commented, minimal, self-contained, reproducible code.
>>> >
>>> >
>>
>>
>



More information about the R-help mailing list