Creating vegetation distance groups from one column
Hi, I have tried the script posted but received the following errors. I hope I copied it correctly. I'm sorry but I don't know how to alter the script myself. Please advise, Jean
x <- 0:30 + runif(124) data.to.analyze$VegIndex <- cut(x, breaks = seq(0, 35, 5))
Error in `$<-.data.frame`(`*tmp*`, "VegIndex", value = c(1L, 1L, 1L, 1L, : replacement has 124 rows, data has 123
l <- levels(data.to.analyze$VegIndex)
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, ")"))
Error: could not find function "paste0"
levels(data.to.analyze$VegIndex) <- l.new
Error: object 'l.new' not found
str(data.to.analyze$VegIndex)
NULL
barplot(table(data.to.analyze$VegIndex))
Error in plot.window(xlim, ylim, log = log, ...) : need finite 'xlim' values In addition: Warning messages: 1: In min(w.l) : no non-missing arguments to min; returning Inf 2: In max(w.r) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf -- View this message in context: http://r.789695.n4.nabble.com/Creating-vegetation-distance-groups-from-one-column-tp4644970p4645230.html Sent from the R help mailing list archive at Nabble.com.