> You did not change df$quant - you made a new object called 'subdf'
> containing a column called 'quant' that had only one level.  Changing subdf 
> has
> no effect on df.

Also, subsetting a factor _intentionally_ does not change the number of levels. 
Example:
f <- factor(sample(letters[1:3], 30, replace=TRUE))
f[1]  #One element, still three levels

If you want to drop levels, use droplevels() either on the factor or on the 
subset of your data frame. Example: 
droplevels(f[1]) #One element, only one level


Also worth noting that df is a function.
 > df <- data.frame(quant=factor(letters))
looks very like you're assigning a data frame to the function 'df' (density for 
the F distribution)
It doesn't, because R is clever. But it's really not good practice to use 
common function names as variable names. Too much potential for confusion.

S Ellison


*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to