-
Notifications
You must be signed in to change notification settings - Fork 0
/
4. Trying for certain Frequencies .R
73 lines (58 loc) · 2.1 KB
/
4. Trying for certain Frequencies .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
#Plotting low n columns with the IDs to see the frequency of representation (ie: if N is 50, are 40 of those entries from one single ID = non-representative?)
#Opening Ophthalmology data on R
optho <- read.csv("June19_optho.csv")
#---------------------------------------------------------------------------
# Central Foveal Thickness frequency- with the dplyr and tidyr packages;
library(tidyr)
library(dplyr)
myFreqs <- optho %>%
group_by(ID, Central.Foveal.Thickness..um.) %>%
summarise(Freq = n())
myFreqs
##Lots of NAs
#Exporting this table to excel
library("writexl")
print(myFreqs)
write_xlsx(myFreqs,"/Users/maryagopi/Desktop/Excel parts/June 20/CFT_freq.xlsx")
write_xlsx
##Table was exported
##Observations, very low n, possibly remove this table
#---------------------------------------------------------------------------
# Mean Thickness frequency- with the dplyr and tidyr packages;
library(tidyr)
library(dplyr)
MTFreqs <- optho %>%
group_by(Mean.thickness..um., ID) %>%
summarise(Freq = n())
MTFreqs
#Exporting this table to excel
library("writexl")
print(MTFreqs)
write_xlsx(MTFreqs,"/Users/maryagopi/Desktop/Excel parts/June 20/MT_freq.xlsx")
write_xlsx
##Table was exported
##Observations, very low n, possibly remove this table
#---------------------------------------------------------------------------
# Refraction_OD_R frequency- with the dplyr and tidyr packages;
library(tidyr)
library(dplyr)
RODRFreqs <- optho %>%
group_by(Refraction_OD_R, ID) %>%
summarise(Freq = n())
RODRFreqs
#Exporting this table to excel
library("writexl")
print(RODRFreqs)
write_xlsx(RODRFreqs,"/Users/maryagopi/Desktop/Excel parts/June 20/RODR_freq.xlsx")
write_xlsx
##Table was exported
#---------------------------------------------
#TRYING FOR SCATTER PLOT
ScatterRODR <-RODRFreqs[c(1:156),c(1:3)]
library(ggplot2)
# Basic scatter plot
scatterplotRODR <- ggplot(ScatterRODR, aes(x=Refraction_OD_R, y=Freq)) + geom_point()
scatterplotRODR
# Make the scatter plot even more intuitive through adding a heat map aspect
scatterplot.RODR <- ggplot(ScatterRODR, aes(x=Refraction_OD_R, y=Freq))
scatterplot.RODR+geom_bin2d()