Types of stuff in R

I know … I know … its been a while. I am busy with my online classes what can I do?

Lets get back to the topic.

What type of stuff is in R that you can work with ? Well … there are plenty.

I am definitely not going to go into details because it would make this post probably the longest post of the history of posts. Before you go read more, let me share you the one thing you always have to keep in mind.

Everything in R is an object.

Sounds familiar ? *cough* javascript *cough* Do not worry if it does not. Just make sure you understand that and always remember it.

R has five basic or dare I say “atomic” classes of objects.

  • character
  • integer
  • logical (TRUE/FALSE)
  • numeric
  • complex

If they sound too confusing, lets clear your mind. The character type is your “abCD” etc etc. Integers are your numbers 1 2 3 4 and so on. Logical is TRUE or FALSE and that is all there is to it. Numeric is a number with a decimal point. That is how it differentiates from integer. Complex is something like 2+5i …

Couple of key things that I want to point out to you. Numbers are generally treated as double precision real numbers. If you want an integer specifically, you have to specify the L suffix. If you enter 1, that is an object but if you enter 1L, that is an integer. Try it out.

> class(1)
[1] "numeric"
> class(1L)
[1] "integer"

In R, there is a NaN value. It is not necessarily a type – if you do class(NaN) you get numeric – but it is special. It represents an undefined value and it can also be thought as a missing value.

> 0 / 0
[1] NaN

See what I mean?

Another one is Inf which represents infinity. Just do 1 / Inf to see it for your self. Reading here is one thing but doing it your self is another.

Now this is all good but we can not examine millions of rows of data just with what I listed above now can we ? We need some sort of operators that help us organize our data and do math on it. The most basic operator is a vector but of course there are more.

  • Vectors (most common one)
  • Lists
  • Matrices
  • Arrays
  • Factors
  • Data Frames

I am not going to talk about them here because they deserve their individual topics. Yes with an “s” at the end. You are going to use them and abuse them. It is best if you start researching now.