Re: [R-sig-eco] Sites names with spaces in ordiplot
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(). What happened if I have a txt file like this: siteAbarema adenophoraAbarema macradenia Abatia parvifloraAbelmoschus esculentusAbelmoschus moschatus General Viejo 1 11 11 Rio Pacuar0 00 00 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Ãnolamspinol...@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/ [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Sites names with spaces in ordiplot
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: siteAbarema adenophoraAbarema macradenia Abatia parvifloraAbelmoschus esculentusAbelmoschus moschatus General Viejo 1 1 1 11 Rio Pacuar 0 0 0 00 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ínolamspinol...@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 ___
Re: [R-sig-eco] Sites names with spaces in ordiplot
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: siteAbarema adenophoraAbarema macradenia Abatia parvifloraAbelmoschus esculentusAbelmoschus moschatus General Viejo 1 1 1 11 Rio Pacuar 0 0 0 00 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Ãnolamspinol...@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
[R-sig-eco] Sites names with spaces in ordiplot
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? Best, Manuel -- *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
Re: [R-sig-eco] Sites names with spaces in ordiplot
On Fri, 2011-04-01 at 00:46 +0100, Gavin Simpson wrote: On Thu, 2011-03-31 at 14:18 -0600, Manuel Spínola 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? Did you even try it? It works - we and R don't give two hoots what the labels are, just make sure the row and col names of the dataframe/matrix are what you want to appear on the plot. OK, the usual constraints on row and column names for matrices and data frames apply, but other than that, we and R don't give two hoots. G Here is an (not exactly inspiring) example: require(vegan) set.seed(1) dat - data.frame(matrix(runif(100), ncol = 10)) names(dat) - paste(Spp, 1:10, sep = ) rownames(dat) - paste(Site, 1:10) head(dat) mod - metaMDS(dat) plot(mod, type = text) HTH G Best, Manuel ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Sites names with spaces in ordiplot
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. R only wants to protect you from trouble. 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