Top "R-factor" questions

The factor is a data type in the R language, used to encode categorical or enumerated data.

Factors in R: more than an annoyance?

One of the basic data types in R is factors. In my experience factors are basically a pain and I …

r language-design internals r-factor
Reorder factor levels by day of the week in R

I have the following data.frame in R: > daily DoW Duration 1 Friday 14.0000000000000 2 Monday 21.0000000000000 3 Saturday 12.0000000000000 4 Thursday 28.0000000000000 5 Tuesday 12.0000000000000 6 Wednesday 91.0000000000000 7 Sunday 20.0000000000000 I'd …

r dataframe r-factor
Linear model (lm) when dependent variable is a factor/categorical variable?

I want to do linear regression with the lm function. My dependent variable is a factor called AccountStatus: 1:0 days in …

r lm categorical-data r-factor
Rename one level of a factor in R

I'm attempting to rename the level A of factor column1 in the dataframe df in R. My current approach is …

r r-factor
How to fill NAs with LOCF by factors in data frame, split by country

I have the following data frame (simplified) with the country variable as a factor and the value variable has missing …

r dataframe missing-data r-factor
In R, how can I access the first element of each level of a factor?

I have a data frame like this: n = c(2, 2, 3, 3, 4, 4) n <- as.factor(n) s = c("a", "b", "c", "…

r r-factor
How to remove ordering of the levels from factor variable in R?

The title says it all, I ordered a factor variable when I generated it, now I would like to remove …

r variables r-factor
How to treat a variable as random factor in GLM in R

I am doing statistical analysis for a dataset using GLM in R. Basically the predictor variables are: "Probe"(types of …

r random glm r-factor
R: Sorting factor by level frequency and plotting

I have a data.frame with several factors such as: df<-data.frame(Var1=as.factor(sample(c("AB", "…

r dataframe ggplot2 plyr r-factor
counting unique factors in r

I would like to know the number of unique dams which gave birth on each of the birth dates recorded. …

r unique r-factor