Admittedly, R has a steep learning curve. But most common errors faced by beginners can be resolved with a good understanding of the language basics. For example, categorical variables must always be converted to 'factor' class before any data analysis in R. Here's an intuitive explanation. Say we have a an atomic vector with 1 = female and 0 = male:
> gender_vec = c(1, 0, 0, 1, 1)
Would an arithmetic operation on this vector make sense? No!
> gender_vec + 2 # meaningless!
[1] 3 2 2 3 3
We would like R to distinguish between such categorical variables and other numeric vectors. The 'factor' class in R allows for this distinction. Once we convert our vector to 'factor' class, R recognises that the vector represents a categorical variable and refuses to perform meaningless operations on it.
> as.factor(gender_vec)
[1] 1 0 0 1 1
Levels: 0 1