-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_dataDescription.R
109 lines (83 loc) · 2.46 KB
/
2_dataDescription.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#--------------Types of Data----------------------
# 1_Quantitative data:measurment of quantity of something
# a:Discrete data= eg: no of arrivals ,no of success :: represented by integers
# b:Continious data= eg: height,weight,length,time :: represented by decimals
# example
# 1:Annual Precipitions in US Cities- avg amnt of rainfall for each 70 cities
# quantitative continious data
str(precip)
precip[1:4]
# 2:Lengths of Major North American Rivers
# quantitative continious data
str(rivers)
# 3:Yearly no. of important Discoveries
str(discoveries)
discoveries[1:4]
#--------------------Displaying Qunatitive Data--------------
# Strip Charts(Dot Plots)
stripchart(precip, xlab = "rainfall")
str(precip)
stripchart(rivers, method = "jitter",xlab = "length")
str(rivers)
stripchart(discoveries,method = "stack",xlab = "number")
str(discoveries)
# Histogram (typically used with continious data)
# Annual Precipitation in US Cities
hist(precip, main="Histogram of precip")
hist(precip, freq = FALSE, main = "Histogram of precip")
#change bins slightly (with break argument to hist)
hist(precip,breaks = 10,main="")
hist(precip,breaks = 200,main = "")
# Stemplots(stems and leaves)
#https://stackoverflow.com/questions/5567500/can-not-load-package-tcltk-in-r
# UKDriverDeath time series
install.packages("tcltk",dependencies = TRUE)
library(aplpack)
help(aplpack)
??aplpack
stem.leaf(UKDriverDeaths,depths = FALSE)
str(UKDriverDeaths)
# Index Plot
plot(LakeHuron, type="h")
str(LakeHuron)
plot(LakeHuron, type="p")
#Qualitative Data, Categorical Data, Factors
str(state.abb)
state.abb[1:50]
str(state.region)
#---------------Displaying Qualitaive Data--------------------
# table
tbl <- table(state.division)
tbl
#relative frequencies
tbl/sum(tbl)
#same thing
prop.table(tbl)
# Bar Graph
barplot(table(state.region),cex.names = 0.6)#cex.names label size
?state.region
str(state.region)
barplot(prop.table(table(state.region)), cex.names = 0.5)
# Pareto Diagrams
install.packages("qcc",dependencies = TRUE)
library(qcc)
pareto.chart(table(state.division), ylab = "Frequency")
# Dot Charts
x <- table(state.region)
dotchart(as.vector(x),labels = names(x))
# Clusters and Gaps
library(aplpack)
stem.leaf(faithful$eruptions)
#----------------Outliers-----------------------------
boxplot.stats(rivers)$out
boxplot.stats(rivers,coef = 3)$out
str(rivers)
#-------------Multivariate Data and Data Frames---------------
x <- 5:8
y <- letters[3:6]
A <- data.frame(v1=x, v2=y)
A
A[3,]
A[,2]
names(A)
A$v1