R selecting duplicate rows
- by Matt
Okay, I'm fairly new to R and I've tried to search the documentation for what I need to do but here is the problem.
I have a data.frame called heeds.data in the following form (some columns omitted for simplicity)
eval.num, eval.count, ... fitness, fitness.mean, green.h.0, green.v.0, offset.0, green.h.1, green.v.1,...green.h.7, green.v.7, offset.7...
And I have selected a row meeting the following criteria:
best.fitness <- min(heeds.data$fitness.mean[heeds.data$eval.count = 10])
best.row <- heeds.data[heeds.data$fitness.mean == best.fitness]
Now, what I want are all of the other rows with that have columns green.h.0 to offset.7 (a contiguous section of columns) equal to the best.row
Basically I'm looking for rows that have some of the conditions the same as the "best" row.
I thought I could just do this,
heeds.best <- heeds.data$fitness[
heeds.data$green.h.0 == best.row$green.h.0 & ...
]
But with 24 columns it seems like a stupid method. Looking for something a bit simpler with less manual typing.
Thanks!