Thank you very much Gavin.

I understand now.

Best,

Manuel

On 01/04/2011 05:29 a.m., Gavin Simpson wrote:
> On Fri, 2011-04-01 at 05:14 -0600, Manuel Spínola wrote:
>> Gavin and Jari, thank you very much.
>>
>> Actually, I am interested in both, sites and species.  I have 3000
>> species (tropical forest trees) and I am trying to read the txt file
>> with read.table.  I tried also read.delim, but I don't know how to
>> bring
>> the sites names in the plot.  I guess now I have the answer, using
>> text().
> I mentioned this in my last email - the one you are replying to. The
> issue is that R will check the species (variable) names on input and
> remove spaces, replacing them with a `.`. But you *can* control whether
> it does this or not using check.names = FALSE.
>
> For example. Here is a simple CSV file:
>
> ,"Spp 1","Spp 2","Spp 3"
> "Site 1",1,4,7
> "Site 2",2,5,8
> "Site 3",3,6,9
>
> with spaces in both the species and site names.
>
> We read it in via:
>
> dat<- read.csv("spp.csv", row.names = 1, check.names = FALSE)
> dat
>
> And it gives us:
>
>         Spp 1 Spp 2 Spp 3
> Site 1     1     4     7
> Site 2     2     5     8
> Site 3     3     6     9
>
> So it *has* preserved the spaces in the species names and it hasn't
> touched the row names.
>
> We can ordinate this with out any problems:
>
> require(vegan)
> mod<- metaMDS(dat)
> plot(mod, type = "text")
>
> Ok, that is a pretty pointless plot but it works.
>
> Does that help?
>
> G
>
>> What happened if I have a txt file like this:
>>
>> site                        Abarema adenophora    Abarema
>> macradenia
>> Abatia parviflora    Abelmoschus esculentus    Abelmoschus moschatus
>> General Viejo
>> 1
>> 1
>> 1
>> 1                                                    1
>> Rio Pacuar
>> 0
>>     0
>> 0
>>       0                                                    0
>> Las Brisas
>> 0
>> 0
>> 0
>> 1
>>              1
>> San Pedro
>> 0
>> 0
>> 0
>> 1                                                     1
>> Rio Convento                           0
>> 0
>>
>> 0
>> 1                                                     1
>>
>> What will be the way to keep blank spaces for sites and species.  I
>> know
>> that species will be unnecessary in this case  because I have too
>> many
>> and I cannot show them in the plot, but just to learn for another
>> time.
>>
>> Best,
>>
>> Manuel
>>
>>
>> On 01/04/2011 03:16 a.m., Gavin Simpson wrote:
>>> On Fri, 2011-04-01 at 07:01 +0300, Jari Oksanen wrote:
>>>> On 31/03/11 23:18 PM, "Manuel Spínola"<mspinol...@gmail.com>
>> wrote:
>>>>> Dear list members,
>>>>>
>>>>> I would like to include sites names with blank spaces in an
>> ordiplot for
>>>>> an nmds (in vegan).
>>>>> How I do that?
>>>>>
>>>> Manuel,
>>>>
>>>> Like Gav wrote, R indeed is a bit patronizing and doesn't let you
>> to use
>>>> dimension names with blank.
>>> It does. I made the species labels in my examples *not* have spaces
>> in
>>> them because Manuel said only his site names had spaces. The
>> following
>>> works just fine:
>>>
>>> require(vegan)
>>> set.seed(1)
>>> dat<- data.frame(matrix(runif(100), ncol = 10))
>>> names(dat)<- paste("Spp", 1:10)
>>> rownames(dat)<- paste("Site", 1:10)
>>> mod<- metaMDS(dat)
>>> plot(mod, type = "text")
>>>
>>>>    R only wants to protect you from trouble.
>>> Indeed - it is a pain to look at `Spp 1` now, for example, as
>> everything
>>> needs to be quoted:
>>>
>>> R>   dat$`Spp 1`
>>>    [1] 0.26550866 0.37212390 0.57285336 0.90820779 0.20168193
>> 0.89838968
>>>    [7] 0.94467527 0.66079779 0.62911404 0.06178627
>>>
>>> One issue that might catch people out is that R doesn't let you read
>>> data in with spaces in the colnames (unless read.table()'s
>> check.names =
>>> FALSE is set) - spaces get replaced with `.`.
>>>
>>> However, the only constraint on rownames is that they be non-missing
>> and
>>> non-duplicated. Both sets of names need to be syntactically valid
>> but
>>> spaces are fine.
>>>
>>> Hence one can always change the row/colnames to suit just before
>>> plotting so one doesn't need to resort to extra plotting calls to
>>> achieve the desired result. That said, one usually will need extra
>> calls
>>> to ordiplot functions as ordinations are complex beasts to plot so
>>> drawing the points with custom text labels is no real hardship
>> either.
>>> Either approach works.
>>>
>>> G
>>>
>>>> However, vegan lets you use any names in text() function for
>> metaMDS: just
>>>> list those names as a vector of quoted text in 'labels' argument to
>>>> text.metaMDS(). The names given in 'labels' can have blanks, or
>> even be al
>>>> blanks as long as they are quoted. The length of the 'labels' must
>> match the
>>>> number of items plotted.
>>>>
>>>> All vegan text() functions for ordination plots should have the
>> 'labels'
>>>> argument. I cannot guarantee that all of them have, but you can
>> always
>>>> report missing cases to us. The text() for metaMDS() certainly has
>> 'labels'
>>>> as you can see if you read the help page ?metaMDS (which may not be
>> a bad
>>>> idea).
>>>>
>>>> Cheers, Jari Oksanen
>>>>
>>>> _______________________________________________
>>>> R-sig-ecology mailing list
>>>> R-sig-ecology@r-project.org
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>
>> -- 
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspin...@una.ac.cr
>> mspinol...@gmail.com
>> Teléfono: (506) 2277-3598
>> Fax: (506) 2237-7036
>> Personal website: Lobito de río
>> <https://sites.google.com/site/lobitoderio/>
>> Institutional website: ICOMVIS<http://www.icomvis.una.ac.cr/>


-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.ac.cr
mspinol...@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río 
<https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to