Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Data Science
  3. Question
Data Science

What's the difference between integer class and numeric class in R

Asked by Manish Jhadav Jul 14, 2021 1.9K views 2 answers
Share

About this question

 I want to preface this by saying I'm an absolute programming beginner, so please excuse how basic this question is.

I'm trying to get a better understanding of "atomic" classes in R and maybe this goes for classes in programming in general. I understand the difference between a character, logical, and complex data classes, but I'm struggling to find the fundamental difference between a numeric class and an integer class.

Let's say I have a simple vector x <- c(4, 5, 6, 6) of integers, it would make sense for this to be an integer class. But when I do class(x) I get [1] "numeric". Then if I convert this vector to an integer class x <- as.integer(x). It returns the same exact list of numbers except the class is different.

My question is why is this the case, and why the default class for a set of integers is a numeric class, and what are the advantages and or disadvantages of having an integer set as numeric instead of an integer.

Your answer

2 Answers

Freemanharris Latest answer

Answered on Nov 20, 2024

I appreciate your reply. Very helpful. You can play and rate smash karts on my site!

Was this helpful?

More Data Science discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Data Science Blogs

Guides, tips and career advice on Data Science from JanBask experts.