-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHomwork Excercise week 2.R
21 lines (21 loc) · 1.18 KB
/
Homwork Excercise week 2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#Statistics One, Lecture 6, example script
#Read data, plot histograms, get descriptives, examine scatterplots, run correlations.
library(psych)
impact <- read.table ("supplemental_STATS1.EX.02.txt", header=T)
layout(matrix(c(1:10),5,2,byrow=T))
hist(impact$memory.verbal, xlab="Verbal Memory", main="Histogram", col="red")
hist(impact$memory.visual, xlab="Visual Memory", main="Histogram", col="blue")
hist(impact$speed.vismotor, xlab="Vismotor Speed", main="Histogram", col="green")
hist(impact$speed.general, xlab="General Speed", main="Histogram", col="yellow")
hist(impact$impulse.control, xlab="Control Impulse", main="Histogram", col="brown")
print(describe(impact))
plot(impact$memory.verbal ~ impact$memory.visual, main="Scatterplot", ylab="Verbal memory", xlab="Visual memory")
abline(lm(impact$memory.verbal ~ impact$memory.visual), col="blue")
print(cor(impact$memory.verbal, impact$memory.visual))
print(cor.test(impact$memory.verbal, impact$memory.visual))
print(cor(impact))
library(gclus)
impact.r = abs(cor(impact))
impact.col = dmat.color(impact.r)
impact.o <- order.single(impact.r)
cpairs(impact, impact.o, panel.colors=impact.col, gap=.5, main="Variables Ordered and Colored by Correlation")