Difference between as.numeric() and as.factor() in R

as.numeric(), as.factor() in R

Indhumathy Chelliah
PRogRamming with R
Published in
2 min readDec 6, 2023

--

Photo by Karolina Grabowska: https://www.pexels.com/photo/colorful-plastic-numbers-and-mathematical-symbols-for-kids-to-learn-from-5412230/

Let’s look at the difference between as.numeric() and as.factor() in R.

as.factor()

→ It will convert the column type to factor which means we won’t be able to perform any arithmetic operations on that column. It is treated like categorical values.

--

--