[R] How to split data for NMDS plots

David Winsemius dwinsemius at comcast.net
Sun Apr 4 22:25:45 CEST 2010

On Apr 4, 2010, at 3:50 PM, Trey wrote:

> I have a data matrix that contains site data for paired infested and  
> control
> plots.  For example:
>       ab     ac  ad af ag ah
> 1     .024   x   x   x   x   x
> 2     .9      x   x   x   x   x
> 3     1.5    x   x   x   x   x
> 4     2.3    x   x   x   x   x
> 5     1.0    x   x   x   x   x
> 1c    .75   x   x   x   x   x
> 2c    2.1   x   x   x   x   x
> 3c    1.7   x   x   x   x   x
> 4c    10.2 x   x   x   x   x
> 5c    2.1   x   x   x   x   x

Well, after reading with read table and textConnection, it's not a  
"data.matrix" but this was a dataframe:

  dta$infect <- grepl("c", row.names(dta))

 > dta
        ab ac ad af ag ah infect
1   0.024  x  x  x  x  x  FALSE
2   0.900  x  x  x  x  x  FALSE
3   1.500  x  x  x  x  x  FALSE
4   2.300  x  x  x  x  x  FALSE
5   1.000  x  x  x  x  x  FALSE
1c  0.750  x  x  x  x  x   TRUE
2c  2.100  x  x  x  x  x   TRUE
3c  1.700  x  x  x  x  x   TRUE
4c 10.200  x  x  x  x  x   TRUE
5c  2.100  x  x  x  x  x   TRUE

(I did not like the way plot.formula handled the logical variable  
infect so I "factorized it.)

  plot(ab ~ as.factor(infect), data=dta)

> where: 1-5 stand for infested sites, and 1c-5c stand for control  
> sites.  Row
> 1 headings are the species within each site.  Numerical data exists  
> for all
> columns, the x's are used here just to fill out the matrix.  What I  
> seek to
> do is to split out the "infested" sites from the control "sites" in my
> subsequent graphical plot of the ordination.  I know there is a  
> simple way
> to do this, but I have not discovered it.  Once I split them I can  
> create
> unique graphical parameters for each to display within the plot; I  
> know how
> to alter graphics and how to plot sites alone in the graphical output.
> Anyone know how to split these out?
> -- 
> View this message in context: http://n4.nabble.com/How-to-split-data-for-NMDS-plots-tp1751101p1751101.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> R-help at r-project.org mailing list
> 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 Winsemius, MD
West Hartford, CT

More information about the R-help mailing list