# [R] Creating vegetation distance groups from one column

Fri Oct 5 13:46:01 CEST 2012

```Hello,

That now seems to be a presentation problem. See this example:

x <- 0:30 + runif(124)
y <- cut(x, breaks = seq(0, 35, 5))

l <- levels(y)
l1 <- sub("\\]", ")", l[1])
l2 <- as.numeric(sub("\\(([[:digit:]]+),.*", "\\1", l[-1])) + 1
l3 <- sub(".*,([[:digit:]]+).*", "\\1", l[-1])
l.new <- c(l1, paste0("(", l2, ",", l3, ")"))
levels(y) <- l.new

str(y)
barplot(table(y))

Instead of 'y' use data.to.analyze\$VegIndex and it should give what you
want.

Hope this helps,

Em 05-10-2012 08:38, Jhope escreveu:
> Thank you! That has worked for me when creating graphs. In plyr I used the
> script:
>
> # Veg Index
> data.to.analyze\$VegIndex <- cut(data.to.analyze\$Veg,
>        breaks=seq(0, 35, 5), include.lowest=TRUE)
> VegIndex <- data.to.analyze\$VegIndex
> plot(VegIndex)
>
> But the vegetation distances on the x-axis in the graph are showing up as:
> [-5,0] (0,5] (5,10] (10,15] (15,20] (20,25] (25,30]
>
> I am concerned these vegetation classes are not grouped probably and there
> is overlap between the classes. It should read, preferably without brackets
> or only one kind ():
> (-5-0) (1-5) (6-10) (11-15) (16-20) (21-25) (26-30)
>
> How do I fix this?
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Creating-vegetation-distance-groups-from-one-column-tp4644970p4645127.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