0

Thanks for the droplevels advice, I used it but when I run the below script (with the droplevels), I am having couldnt get parameter "blue" into ert[3], when I run ert, I get the below instead of NA NA "Blue"

[1] NA NA 1

Thanks for any advice.

setup <- data.frame(c("red","blue","green","blue"))
colnames(setup) <- "tester"
red <- data.frame(unique(setup[,"tester"]))
run <- red[2,1]
run <- droplevels(run)

ert <- vector()
ert[3] <- run
ert
user3655574
  • 692
  • 2
  • 9
  • 27
  • You can use `droplevels(run)` or `factor(run)` to remove the unused levels after subsetting. – akrun Sep 05 '15 at 15:30
  • See `?levels` and the description of `stringAsFactors` in `?data.frame`. – RHertel Sep 05 '15 at 15:36
  • Unless you are doing regressions or working with huge datasets, I almost always start my R programs with `options(stringsAsFactors=FALSE)` – bramtayl Sep 05 '15 at 16:34

0 Answers0