A factor variable can be converted to numeric using the as.numeric() function in R language. However, the variable first needs to be converted to a character before being converted to numeric because the as.numeric() function in R does not return original values but returns the vector of the levels of the factor variable.
X <- factor(c(4, 5, 6, 6, 4))
X1 = as.numeric(as.character(X))