Code runs in RStudio IDE but not from knitr/rmarkdown

rmarkdown

#1

I've found the following code fragment runs in the RStudio IDE without problem:
comment: Merge "BF" and "BH" to "BF"
fpd <-fpd$ELE[fpd$ELE=="BH"] <- "BF"
fpd <- droplevels(fpd)

However, attempting to run the same bit of code from within an rmarkdown file using knitr results in this error message:
"Error in UseMethod("droplevels") :
no applicable method for 'droplevels' applied to an object of class "character"

The Variable in question, "ELE," is a factor with four levels. I wish, as shown in the code snippet, to recode one level to the same value as another level and drop the unused level.