[R] Creating vegetation distance groups from one column

Jhope jeanwaijang at gmail.com
Thu Oct 4 09:27:38 CEST 2012


Hi R listers, 

I am trying to group distances of nests to the vegetation into classes that
are define by (0-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26-30m, 31-35m,  36-40m,
41-45m, 46-50m, 51-55m, 56-60m). Each row is a nest and all the distances to
the vegetation is in a column. 

In plyr, I have tried - below script but I think I am going about this the
wrong way and am not successful. 

#Veg index star = resp
Veg.index <- function(values, weights=c(0, 5, 10, 15, 20, 25, 30, 35, 40,
45, 50, 55, 60, 65, 70)) {
  star <- values*weights
  return(apply(star, 1, sum) / apply(values, 1, sum))
}
data.to.analyze$VegIndex <- Veg.index(data.to.analyze[,c("0", "5", "10",
"15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70")])
write.csv(data.to.analyze, "3turtlehatch.csv", row.names=FALSE)

Please advise, Jean



--
View this message in context: http://r.789695.n4.nabble.com/Creating-vegetation-distance-groups-from-one-column-tp4644970.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list