-
Notifications
You must be signed in to change notification settings - Fork 0
/
7. Conversion VA to LogMar.R
125 lines (88 loc) · 3.36 KB
/
7. Conversion VA to LogMar.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
112
113
114
115
116
117
118
119
120
121
install.packages("eye")
library("eye")
#Opening VA.Numeric data on R
VA.Numeric <- read.csv("Mary_June26_Optho_VA.csv")
#Right Eye--------------------------------------------------------
Right.eye <- VA.Numeric$VA_snellen_R
Right.eye.LogMar <- to_logmar(Right.eye)
Right.eye.LogMarframe=as.data.frame(Right.eye.LogMar)
library("writexl")
write_xlsx(Right.eye.LogMarframe,"/Users/maryagopi/Desktop/Right.eye.LogMarframe.xlsx")
#Left Eye--------------------------------------------------------
Left.eye <- VA.Numeric$VA_snellen_L
Left.eye.LogMar <- to_logmar(Left.eye)
Left.eye.LogMarframe=as.data.frame(Left.eye.LogMar)
library("writexl")
write_xlsx(Left.eye.LogMarframe,"/Users/maryagopi/Desktop/Left.eye.LogMarframe.xlsx")
#Both Eyes--------------------------------------------------------
Both.eye <- VA.Numeric$VA_snellen_Bi
Both.eye.LogMar <- to_logmar(Both.eye)
Both.eye.LogMarframe=as.data.frame(Both.eye.LogMar)
library("writexl")
write_xlsx(Both.eye.LogMarframe,"/Users/maryagopi/Desktop/Both.eye.LogMarframe.xlsx")
#############################################Finding Frequencies and averages
#Opening LogMar.VA.Numeric data on R
Log.Mar.VA.Numeric <- read.csv("LogMary_Mary_June26_Optho_VA._NumOnly.csv")
#Right eye-------------------------------------------------------------------
library("plyr")
Frequency.Right.eye <- count(Log.Mar.VA.Numeric, 'VA_snellen_R')
library("writexl")
write_xlsx(Frequency.Right.eye,"/Users/maryagopi/Desktop/Frequency.Right.eye.xlsx")
#BAR PLOT
library(ggplot2)
# Basic barplot
p<-ggplot(data=Frequency.Right.eye, aes(x=VA_snellen_R, y=freq)) +
geom_bar(stat="identity", fill="green")+
geom_text(aes(label=freq), vjust=-0, size=2.5)+
theme_minimal()
p
# Horizontal bar plot
p + coord_flip()
#Left eye-------------------------------------------------------------------
library("plyr")
Frequency.Left.eye <- count(Log.Mar.VA.Numeric, 'VA_snellen_L')
library("writexl")
write_xlsx(Frequency.Left.eye,"/Users/maryagopi/Desktop/Frequency.Left.eye.xlsx")
#BAR PLOT
library(ggplot2)
# Basic barplot
p<-ggplot(data=Frequency.Left.eye, aes(x=VA_snellen_L, y=freq)) +
geom_bar(stat="identity", fill="green")+
geom_text(aes(label=freq), vjust=-0, size=2.5)+
theme_minimal()
p
# Horizontal bar plot
p + coord_flip()
#Bilateral eye-------------------------------------------------------------------
library("plyr")
Frequency.Both.eye <- count(Log.Mar.VA.Numeric, 'VA_snellen_Bi')
library("writexl")
write_xlsx(Frequency.Both.eye,"/Users/maryagopi/Desktop/Frequency.Both.eye.xlsx")
#BAR PLOT
library(ggplot2)
# Basic barplot
p<-ggplot(data=Frequency.Both.eye, aes(x=VA_snellen_Bi, y=freq)) +
geom_bar(stat="identity", fill="green")+
geom_text(aes(label=freq), vjust=-0, size=2.5)+
theme_minimal()
p
# Horizontal bar plot
p + coord_flip()
#---------------------------------------------------------------------------------------
##CC/SC Pie Chart
#Loading packages
library(dplyr) # for data wrangling
library(tidytext) # for NLP
library(stringr) # to deal with strings
library(wordcloud) # to render wordclouds
library(RColorBrewer)
library(knitr) # for tables
library(tidyr)
##isolate out one row at a time for word cloud
SCCC <- Log.Mar.VA.Numeric$SC.CC.
SCCCframe=as.data.frame(SCCC)
#Tokenize
SCCCToken <- tibble(SCCCframe)
SCCCCount <- count(SCCCToken, SCCC)
library("writexl")
write_xlsx(SCCCCount,"/Users/maryagopi/Desktop/Frequency.SCCC.xlsx")