Within this document, we will practice how to use R markdown to format our document for a reproducible research. Then introduce what we have learned in class 2 about data types, objects, and basic operations.
Within R, there are 6 common atomic data types:
c('geospatial', 'analysis', 'R').c(3.14, 20.1, 79.6).c(10L, 40L).c(TRUE, FALSE, FALSE).NULL, which means not exist.NA, which means missing value. It is a special
logical type by default, but could add into
any types of vectors.Inf/-Inf, which means infinity. They are
special double type.NaN, which means undefined value. Usually it could
be used as missing value as well.factor(c('F', 'M)). Each value has a
corresponding label.as.Date('2021-01-01').as.POSIXct('1980-01-01').The most basic object in R is atomic vector. It only takes the same
data type. If it is fed with different data types, the items will be
converted based on the rule: \[logical <
integer < double < character\] We could use function
c to concatenate multiple items within a vector. When a
vector has dimensions, it will become a matrix (2 dimensions), or array
(3 or more dimensions). We could use function rbind or
cbind to bind multiple vectors into matrix.
Being very similar to vector, but list can store items of different data types.
Objects have attributes. The most common ones are:
Function attr() can be used to get or set an attribute
of an object. Function attributes() can get all attributes
of an object.