Displaying 2 results from an estimated 2 matches for "factor_var".
2005 May 04
3
How to intepret a factor response model?
Hello,
I'd like to create a model with a factor-type response variable. This is
an example:
> mydata <- data.frame(factor_var = as.factor(c(rep('one', 100), rep('two', 100), rep('three', 100))), real_var = c(rnorm(150), rnorm(150) + 5))
> summary(mydata)
factor_var real_var
one :100 Min. :-2.742877
three:100 1st Qu.:-0.009493
two :100 Median : 2.361669...
2011 Feb 02
1
Merging by factor variables
...cause factors are actually stored as integers, with 6,7,8,9,10 stored internally as 1,2,3,4,5.
This concerns me somewhat, as I often merge data frames using factors as the by variables. From what I can tell, the merge function creates matches based on factor labels (i.e. the result of as.character(factor_var)) and not the internally stored integers, but I'm wondering if there are particular lurking problems that I should be aware of? I'm especially curious as to how R recalculates the levels of the by variables in outer joins where not every observation is matched, as in:
df1<-data.frame(a...