-
Notifications
You must be signed in to change notification settings - Fork 0
/
8. VA Log MAR averages, spread, boxplots.R
111 lines (79 loc) · 2.66 KB
/
8. VA Log MAR averages, spread, boxplots.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
108
109
110
111
#Calculating averages for LogMAR VAs Right eye
VA.right <- read.csv("Right.eye.LogMarframe copy.csv")
VA.rightt <- VA.right$Right.eye.LogMar
#Doubkechecking everything is a number
str(VA.rightt)
#Now stats
#########AVERAGES--------------------------------------------------------
mean(VA.rightt)
median(VA.rightt)
#Mode is a bit complex
# 1. Create the function.
getmode <- function(VA.rightt) {
uniqv <- unique(VA.rightt)
uniqv[which.max(tabulate(match(VA.rightt, uniqv)))]
}
#2. Now applying the function
result.mode <- getmode(VA.rightt)
print(result.mode)
#########SPREAD-------------------------------------------------------------
range(VA.rightt)
var(VA.rightt)
sd(VA.rightt)
###########BOX PLOT---------------------------------------------
boxplot(VA.right$Right.eye.LogMar, main="VA Right eye", ylab="LogMAR values")
summary(VA.right$Right.eye.LogMar)
################################---------------
################################---------------
#Calculating averages for LogMAR VAs Left eye
VA.left <- read.csv("Left.eye.LogMarframe copy.csv")
VA.leftt <- VA.left$Left.eye.LogMar
#Doubkechecking everything is a number
str(VA.leftt)
#Now stats
#########AVERAGES--------------------------------------------------------
mean(VA.leftt)
median(VA.leftt)
#Mode is a bit complex
# 1. Create the function.
getmode <- function(VA.leftt) {
uniqv <- unique(VA.leftt)
uniqv[which.max(tabulate(match(VA.leftt, uniqv)))]
}
#2. Now applying the function
result.mode <- getmode(VA.leftt)
print(result.mode)
#########SPREAD-------------------------------------------------------------
range(VA.leftt)
var(VA.leftt)
sd(VA.leftt)
###########BOX PLOT---------------------------------------------
boxplot(VA.leftt, main="VA Left eye", ylab="LogMAR values")
summary(VA.leftt)
################################---------------
################################---------------
#Calculating averages for LogMAR VAs bilaterral
VA.both <- read.csv("Both.eye.LogMarframe copy.csv")
VA.botth <- VA.both$Both.eye.LogMar
#Doubkechecking everything is a number
str(VA.botth)
#Now stats
#########AVERAGES--------------------------------------------------------
mean(VA.botth)
median(VA.botth)
#Mode is a bit complex
# 1. Create the function.
getmode <- function(VA.botth) {
uniqv <- unique(VA.botth)
uniqv[which.max(tabulate(match(VA.botth, uniqv)))]
}
#2. Now applying the function
result.mode <- getmode(VA.botth)
print(result.mode)
#########SPREAD-------------------------------------------------------------
range(VA.botth)
var(VA.botth)
sd(VA.botth)
###########BOX PLOT---------------------------------------------
boxplot(VA.botth, main="VA Bilateral", ylab="LogMAR values")
summary(VA.botth)