r - Missing values - Subset function -
this code not doing designed for. have ideas why?
vet.in <- 1:30 vet.cut <- cut(vet.in, breaks = c(0,10,20, 30), labels = c("peq", "med", "gra") ) vet.cut <- subset(vet.cut, vet.cut == c("peq", "med"))
after use of subset, elements "gra" filled in desapear , number of elements "peq" , "med" decreased half, not intention. purpose of subset function getting rid of "gra" while prevailing "peq" , "med"
the problem did not implement intention - code else. if intention filter out "gra", use:
evet.in <- 1:30 vet.cut <- cut(evet.in, breaks = c(0,10,20, 30), labels = c("peq", "med", "gra") ) vet.cut <- subset(vet.cut, vet.cut %in% c("peq", "med"))
the key success use %in% operator instead of == operator.
Comments
Post a Comment