A single element of data in R typically falls into one of these types, or “classes” (there are others, but they are beyond the scope of this course):
-
logical(sometimes calledboolean): Data take on the value of eitherTRUEorFALSE. -
integer: Data are whole numbers (those numbers without a decimal point), e.g.,1,2,-999. To explicitly create an integer data type, use the suffixL(e.g.x <- 2L). -
numeric(also calleddouble): Data are numbers that contain a decimal, e.g.,0.001,1.0,-273.16. -
character: Data are text values, or “strings”, e.g.,"cat","I like bananas", or"Everest is 8848.9 m tall". You can think of character strings as a word or sentence or paragraph. A special type of character string is afactor, which is a string but with additional attributes (like levels or an order).
Any of these can also contain NA to represent missing values.





