Académique Documents
Professionnel Documents
Culture Documents
Data Objects in R
ANLY 510 Late Fall
Dr. Stephen Penn
December 10, 2015
+
Working Directory
> getwd()
> list.files()
+
Loading Data
Dataset1 read.csv(C:/mystatsdata/mysurvey.csv)
+
Other read functions
> read.table(
+
Data Sets
+
So, what makes up a data
frame?
Such as 3
> x <- 3
> typeof(x)
> class(x)
> mode(x)
+
Current list of variables
> ls()
You can also see data sets that come with base R, such
as the iris data set
> data()
+
Vectors
> x[1]
> x[3]
+
Functions on Vectors
> length(x)
>typeof(x[1])
+
Arrays
+
Arrays
+
Matrices
+
Factors
> x <factor(AZ,TX,DE,GA,MO,NY,WV,DE,AZ,M
D)
> levels(x)
+
Data Frames
> typeof(iris)
> class(iris)
The terms data set and data frame are practically synonyms.
+
Data Frames
I think of tapply as a
+
Data Editor
+
Attributes
+
Attributes
+
Attributes
+
Referencing Columns
Takes the
vector as a
list of
columns.
Makes a
correlation
matrix.
Takes the
numbers 1
through 4
as a
vector.
Pulls the
first 4
columns of
iris.
+
Classes, Modes, and Types
Types and modes are usually the same. But dont trust R to
be consistent.
Sometimes the type is different and the mode and class are
the same, such as vectors.
+
Missing Values
X == NA
+
Homework Assignment
After the library command, pull up the data set CHFLS using
the data command
+
Homework Page 2