Larsson Emil
2017-Mar-23 12:43 UTC
[R] "Ordiellipse" in vegan package plot; how to plot sd for individual species
Hi R-Help, I have been looking for an answer to this question for some time without success, so now my hope is that you will distribute it to your email subscribers, or direct me to another forum where this question is not off-topic. I have a dataset with 224 rows (=sites), ca 20 environmental variables, and presence/absence data for ca 40 species. TI have done an RDA ordination using the vegan package and plotted all species. Now, I want to add standard deviation for each species as circles or ellipses. How can I do this? I tried using "ordiellipse", guided by this similar request from 2010 answered by Jari Oksanen: http://r-sig-ecology.471788.n2.nabble.com/Fwd-R-cca-standard-error-species-td4997341.html I am close but I cannot make it work. I have attached the dataset (V=variables, S= species) and an example sketch of how the final plot should look. Here is my script so far: # add environmental and species data separately: env<-read.delim("clipboard") attach(env) str(env) species<-read.delim("clipboard") attach(species)? str(species) # run RDA command and plot: mod<-rda(species,env,scale=TRUE) plot(mod, display = "species") ordiellipse(mod, groups = rep(1, 224), display="lc", kind ="sd", draw = "polygon", alpha = 127, label = FALSE, show.groups=TRUE, w = NULL, border = NULL, lty = NULL, lwd=NULL) Very grateful for any help. Best regards, Emil Larsson
David L Carlson
2017-Mar-23 16:47 UTC
[R] "Ordiellipse" in vegan package plot; how to plot sd for individual species
Most attachments (including your data and graph) get stripped from mail sent to the list. If the data are a plain text file, giving the file an extension of .txt will usually let it survive the trip (even if it is a .csv file). Graphics will survive if they are .png files. If the datasets are not large, use dput(env) and dput(species), and then paste the output of those commands into your email message. ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Larsson Emil Sent: Thursday, March 23, 2017 7:44 AM To: r-help at r-project.org Subject: [R] "Ordiellipse" in vegan package plot; how to plot sd for individual species Hi R-Help, I have been looking for an answer to this question for some time without success, so now my hope is that you will distribute it to your email subscribers, or direct me to another forum where this question is not off-topic. I have a dataset with 224 rows (=sites), ca 20 environmental variables, and presence/absence data for ca 40 species. TI have done an RDA ordination using the vegan package and plotted all species. Now, I want to add standard deviation for each species as circles or ellipses. How can I do this? I tried using "ordiellipse", guided by this similar request from 2010 answered by Jari Oksanen: http://r-sig-ecology.471788.n2.nabble.com/Fwd-R-cca-standard-error-species-td4997341.html I am close but I cannot make it work. I have attached the dataset (V=variables, S= species) and an example sketch of how the final plot should look. Here is my script so far: # add environmental and species data separately: env<-read.delim("clipboard") attach(env) str(env) species<-read.delim("clipboard") attach(species)? str(species) # run RDA command and plot: mod<-rda(species,env,scale=TRUE) plot(mod, display = "species") ordiellipse(mod, groups = rep(1, 224), display="lc", kind ="sd", draw = "polygon", alpha = 127, label = FALSE, show.groups=TRUE, w = NULL, border = NULL, lty = NULL, lwd=NULL) Very grateful for any help. Best regards, Emil Larsson ______________________________________________ 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.
David L Carlson
2017-Mar-24 16:37 UTC
[R] FW: "Ordiellipse" in vegan package plot; how to plot sd for individual species
I'm forwarding your response with attachments to the list. They all made it through this time. After reading the earlier query and Jari Oksanen's responses it seem that you want to insert a species in the w= argument, not NULL. Following his example with your data: attach(species) plot(mod, display = "species") ordiellipse(mod, rep(1, nrow(species)), show= TRUE, display="lc", kind="sd", scaling=2, w=S1, col=2) produces a large ellipse. But changing the species often fails with a warning message. For example S2 and S3 fail, but S4 works. It may be best to communicate directly with the package author:> maintainer("vegan")[1] "Jari Oksanen <jari.oksanen at oulu.fi>" ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: Larsson Emil [mailto:emil.larsson at lansstyrelsen.se] Sent: Friday, March 24, 2017 9:40 AM To: David L Carlson <dcarlson at tamu.edu> Subject: SV: [R] "Ordiellipse" in vegan package plot; how to plot sd for individual species Thanks David, I have converted the data to .txt (tab-delimited - hope that works) and graph to .png. Thanks. /Emil ________________________________________ Fr?n: David L Carlson <dcarlson at tamu.edu> Skickat: den 23 mars 2017 17:47 Till: Larsson Emil; r-help at r-project.org ?mne: RE: [R] "Ordiellipse" in vegan package plot; how to plot sd for individual species Most attachments (including your data and graph) get stripped from mail sent to the list. If the data are a plain text file, giving the file an extension of .txt will usually let it survive the trip (even if it is a .csv file). Graphics will survive if they are .png files. If the datasets are not large, use dput(env) and dput(species), and then paste the output of those commands into your email message. ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Larsson Emil Sent: Thursday, March 23, 2017 7:44 AM To: r-help at r-project.org Subject: [R] "Ordiellipse" in vegan package plot; how to plot sd for individual species Hi R-Help, I have been looking for an answer to this question for some time without success, so now my hope is that you will distribute it to your email subscribers, or direct me to another forum where this question is not off-topic. I have a dataset with 224 rows (=sites), ca 20 environmental variables, and presence/absence data for ca 40 species. TI have done an RDA ordination using the vegan package and plotted all species. Now, I want to add standard deviation for each species as circles or ellipses. How can I do this? I tried using "ordiellipse", guided by this similar request from 2010 answered by Jari Oksanen: http://r-sig-ecology.471788.n2.nabble.com/Fwd-R-cca-standard-error-species-td4997341.html I am close but I cannot make it work. I have attached the dataset (V=variables, S= species) and an example sketch of how the final plot should look. Here is my script so far: # add environmental and species data separately: env<-read.delim("clipboard") attach(env) str(env) species<-read.delim("clipboard") attach(species) str(species) # run RDA command and plot: mod<-rda(species,env,scale=TRUE) plot(mod, display = "species") ordiellipse(mod, groups = rep(1, 224), display="lc", kind ="sd", draw = "polygon", alpha = 127, label = FALSE, show.groups=TRUE, w = NULL, border = NULL, lty = NULL, lwd=NULL) Very grateful for any help. Best regards, Emil Larsson ______________________________________________ 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. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: env_data.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170324/3f52702b/attachment.txt> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: species_data.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170324/3f52702b/attachment-0001.txt> -------------- next part -------------- A non-text attachment was scrubbed... Name: ordination plot species.png Type: image/png Size: 40732 bytes Desc: ordination plot species.png URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170324/3f52702b/attachment.png>