r - Plotting ordiellipse from vegan package with ggplot2 -
I am working to create a NMDS coordinate plot for some data using ggplot2 Excellent example of how this can be obtained from the previous stack overflow thread:
I have tried to copy this function from this thread and used it for my data. However, after I pass the function to R, I go to the following error message:
Error in the array (x, c (length (x), 1L), if (! Is.null (Name (x)) list (name (x): 'data' should be of a vector type, 'null' was
I worked for the donated dataset provided to the function with a vegetarian package Can I do but a roadblock with my dataset is killed. Anyone have any idea or idea? Dataset has provided a link below and my code has been pasted below.
The data can be seen:
Code:
# rm (list = ls (all = T)) setwd ( 'C:') library (vegetarian) library (ggplot2) PCBprop & LT; -read.csv ( "PCBprop_stackoverflow.csv", header = T) #Subset the only Lake Michigan Overview MICH & LT; with -PCBprop [(PCBprop, basin == "Michigan"),] #MICHIGAN michcovariate & LT for; -MICH [, C (1,2)] # covariate data michcongener & lt; - MICH [, 3: 60] # PCB congener data michpcbnmds & lt; - metaMDS (michcongener k = 2, distance = 'About', autotransform = right, TryMax = 500) score & lt; -scores (michpc bnmds) nmdsscores & lt; -data.frame (cbind (michcovariate, score)) conspiracy (michpcbnmds $ points, col = nmdsscores $ CAT2) #basic coordination plot from vector l of the Ord; -ordiellipse (michpcbnmds, nmdsscores $ CAT2, display = "sites", type = "off", conf = 0.95, label = T) # 95 plot #Ordiellipse Graph NMDS =% ellipse on data.frame (NMDS1 = nmdsscores $ NMDS1, Data.frame () {df_ell & lt; for NMDS2 = nmdsscores $ NMDS2, group = nmdsscores $ CAT2} #sets (gram in level (NMDS $ group)) - -; Data frame df_ell & lt rbind (df_ell, cbind (as.data.frame ((NMDS [NMDS == G,], Vegan ::: veganCovEllipse (ord with $ groups [[g]] $ cov, ord [[g ]] $ Center, ord [[g]] $ scale)), group = g))} g1 & lt; -ggplot data = Anmdis, AES (Anmdis 1, Anmdis 2)) + Jiom_point (AES (color = Group), size = 1.5) + Jiom_pth (data = Dif_l, AES (X = Anmdis 1, Y = Anmdis 2, color = Group), size = 1.5, linetype = 2) + scale_colour_brewer (palette = "dark2", name = "Species_Location")
this way?
The problem is that ord [[ G]] = zero for one of the groups (
BND_NO
). This is probably because there are only 2 rows of data for that group, when BASIN == Michigan \
, and that 95% confidence is not sufficient to generate Alps
I The following line has been added to the beginning of your loop:
if (is.null (ord [[g]]))
The above plot generated to do.
Comments
Post a Comment