Skip to content
Prev 280591 / 398503 Next

Help with code

Re
This depends on how you want to define "dangerous".  If t1d_ptype ought
take values from a certain set of strings then making it a factor gives
you some safety, since it warns you when you go outside of that set and
try to give it an illegal value.  E.g.,
    > sex <- factor(c("M","F","F"), levels=c("F", "M"))
    > sex[2] <- "no"
    Warning message:
    In `[<-.factor`(`*tmp*`, 2, value = "no") :
      invalid factor level, NAs generated

It does take more work to set up, since you need to enumerate the set
of good strings.  That is tedium, not danger.

If t1d_ptype might take any value, then make it a character vector.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com