I have the following data frame:
dat<-data.frame(site=c(rep("A", 3), rep("B", 3)),
landuse= rep(c("urban", "dev", "undev"),2),
percent= c(30,30,40, 50, 30, 20))
For each site, I want to filter for rows where the percent
is greater than or equal to 50, but for sites where all landuse
categories do not meet the minimum criteria, the landuse
entry is changed to "mixed" and the percent
is changed to 100.
The result data frame would look like this:
result<- data.frame(site= c("A", "B"), landuse=c("mixed", "urban"), percent= c(100, 50))
Aucun commentaire:
Enregistrer un commentaire