CHAPTER ONE: DATA MANAGEMENT IN R

In this chapter, we will cover a number of functions, commands and packages used for data analysis in R

Data Types in R

There are six different data types in R including:

  • Vectors
  • Matrix
  • Arrays
  • Data frames
  • Lists
  • Factors

Vectors

Vectors are fundamental components for all data types in R. Based on the scale of measurement , they can be categorized in to six different components including:

  1. Character
  2. Ordered
  3. Factors
  4. Integers
  5. Numeric
  6. Logical

Example 1:

X<-c(12,11.5,12.5,13.5,21,23,24,21,25,26)
plot(density(X))

hist(X)

boxplot(X)

Example 2

y<-c(T,T,T,T,F,F,F,F,T,F)
table(y)
## y
## FALSE  TRUE 
##     5     5
barplot(y)