Hi All,
A small R conundrum that I am sure I should be able to solve but always seem to get stuck when it comes to subsetting data based on information in another column of the same dataframe.
I have two columns of data (HydroID and NextDownID). I want to identify all the values for HydroID that DONT occur in NextDownID.
(basically this is to identify all the river network heads to start an accumulation of runoff downstream).
Any help appreciated!
Thanks
Cassie
--
An R group for questions, tips and tricks relevant to spatial ecology and climate change.
All R questions welcome.
---
You received this message because you are subscribed to the Google Groups "Tropical R" group.
To post to this group, send an email to tropi...@googlegroups.com.
To unsubscribe from this group, send email to tropical-r+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Does this work?
HydroID <- c(1, 2, 3, 4, 5, 6)
NextDownID <- c(5, 6, 7, 8, 9, 10)
df <- data.frame(HydroID, NextDownID)
df$HydroID[!(df$HydroID %in% df$NextDownID)]