Jon -

Jon A wrote:
Hello,
I have a dataset with a continuous independent variable (fish length, range:
30-150 mm) and a binary response (foraging success, 0 or 1). I want to
discretize fish length into 5 mm bins and give the proportion of individuals
who successfully foraged in each each size bin. I have used the cut function
to discretize the length values into my desired bins, but I can't figure out
how to manipulate my response data in terms of the levels I've created. Any
advice on how to achieve my task?

You don't give example data, but would something like:

df ## your data frame
df$flcat <- cut(...) ## make categorical variable

## install package catspec from CRAN
library(catspec)
dftab <- table(df$flcat, df$success)
ctab(dftab) ## see ?ctab for options about row/column proportions

Hope that helps.




Thanks in advance.



______________________________________________
R-help@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.

Reply via email to