Displaying 1 result from an estimated 1 matches for "reach_yr".
2012 Oct 24
1
randomly select another observation with same grouping factor and year value, do for every record in dataframe
...ervation, and several other characteristics of the randomly chosen observation. Below is the code I have written, but it doesn't work.
Thanks for any help.
Christy
################test
roads=read.csv("streamland23.csv")
for (i in 1:nrow (roads)){
Sitetype= roads$Sitetype
yr=roads$REACH_Yr
initRchid=roads$RchID
huc1=roads$HUC
sample.df <- function(df, n) df[sample(nrow(df), n), , drop = FALSE]
selected=sample.df(roads[roads$HUC == "huc1"& roads$REACH_Yr =="yr" , ], 1)
output=cbind (initRchid,selected$RchID,selected$Sitetype,selected$REACH_Yr)
}
Chr...