-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraitsFrequencyStagesMapping.R
246 lines (186 loc) · 9.54 KB
/
traitsFrequencyStagesMapping.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# ===============================================================
# results of the interviews concerning with
# - Prof. Dr. med. vet. Samuel Kohler (SK) and
# - Prof. Dr. med. vet. Gaby Hirsbrunner (GH)
#
# Frequency of the traits and mapping of traits to birth stages
#
#===============================================================
# ----------------------------------------------------------------
# import & configuration used for LaTeX-Tables out of DataFrame
# ----------------------------------------------------------------
library(xtable)
options(xtable.floating = FALSE)
options(xtable.timestamp = "")
# ----------------------------------------------------------------
##### constants #####
# ----------------------------------------------------------------
## Vector with all the traits identified as signs of upcoming birth ##
TRAITS_LABELS_SK <- c( "Wiederkehrende Schwanzhebung",
"Wiederholtes Aufstehen und Abliegen",
"Häufiges hin-und-her-Treten (Trippeln)",
"Drehung des Kopfes zum Bauch hin",
"Rote Färbung der äusseren Geschlechtsorgane",
"Blutiger Scheidenausfluss",
"Klarer Scheidenausfluss",
"Eingefallene Beckenbänder",
"Euterödem",
"Glänzende Zitzen",
"Tropfende Milch",
"Hyperplasie des Euters",
"Schleimsekretion",
"Schamlippenödem",
"Seitliches Liegen mit Abdominalkontraktion"
)
TRAITS_LABELS_GH <- c( "Wiederkehrende Schwanzhebung",
"Wiederholtes Aufstehen und Abliegen",
"Häufiges hin-und-her-Treten (Trippeln)",
"Drehung des Kopfes zum Bauch hin",
"Rote Färbung der äusseren Geschlechtsorgane",
"Blutiger Scheidenausfluss",
"Klarer Scheidenausfluss",
"Eingefallene Beckenbänder",
"Euterödem",
"Glänzende Zitzen",
"Tropfende Milch",
"Hyperplasie des Euters",
"Schleimsekretion",
"Schamlippenödem",
"Seitliches Liegen ohne Abdominalkontraktion",
"Seitliches Liegen mit Abdominalkontraktion",
"Wasserblase",
"Schleimblase"
)
## Vector with the name of all the identified birth stages ##
BIRTH_STAGES_SK <- c( "Vorbereitungsphase (4 Tage)",
"Vorbereitungsphase (24h)",
"Öffnungsphase",
"Aufweitungsphase",
"Austreibungsphase",
"Nachgeburtsphase"
)
BIRTH_STAGES_GH <- c( "Vorbereitungsphase (4 Tage)",
"Vorbereitungsphase (24h",
"Eröffnungsphase",
"Austreibungsphase",
"Nachgeburtsphase"
)
FREQUENCY_COLUMN_NAME <- "Häufigkeit"
BITH_STAGE_MARKER_POSITIVE <- "xmark" #This sign shows, that this trait does occur in a particular birth stage
BITH_STAGE_MARKER_NEGATIVE <- "" #This sign shows, that this trait does not occur in a particular birth stage
LATEX_TABLE_CAPTION_SK <- "Zuordnung von Merkmalen zu Geburtsphasen und Bewertung der Häufigkeiten von Merkmalen (Samuel Kohler)"
LATEX_TABLE_CAPTION_GH <- "Zuordnung von Merkmalen zu Geburtsphasen und Bewertung der Häufigkeiten von Merkmalen (Gaby Hirsbrunner)"
# ----------------------------------------------------------------
# frequency and birth stage data
# ----------------------------------------------------------------
## birth stage data is being modelled as binary data instad of "x" to facilitate ongoing changes and calculation ##
traits_frequency_sk <- c( "häufig", "häufig", "häufig", "immer", "häufig",
"häufig", "häufig", "immer", "häufig", "häufig",
"selten-häufig", "immer", "häufig", "immer", "immer"
)
traits_stages_sk <-matrix(
c(
c(1,1,0,0,0,0), c(0,1,0,0,0,0), c(0,1,0,0,0,0), c(1,1,0,0,0,0), c(0,1,1,0,0,0),
c(0,1,1,0,0,0), c(0,1,1,0,0,0), c(1,1,0,0,0,0), c(1,1,0,0,0,0), c(1,1,0,0,0,0),
c(1,1,0,0,0,0), c(1,0,0,0,0,0), c(0,1,1,0,0,0), c(1,1,0,0,0,0), c(0,0,1,1,1,0)
),
byrow=TRUE, nrow=15
)
traits_frequency_gh <- c( "häufig", "häufig", "selten", "häufig", "nicht zutreffend",
"nicht zutreffend", "immer", "immer", "selten", "häufig",
"häufig", "immer", "immer", "häufig", "häufig",
"immer", "immer", "immer"
)
traits_stages_gh <-matrix(
c(
c(0,1,1,0,0), c(0,0,1,0,0), c(1,1,0,0,0), c(0,0,0,1,0), c(0,0,0,0,0),
c(0,0,0,0,0), c(1,0,0,0,0), c(1,1,0,0,0), c(1,1,0,0,0), c(0,1,1,0,0),
c(0,1,1,0,0), c(1,1,0,0,0), c(1,0,0,0,0), c(1,1,0,0,0), c(0,0,0,1,0),
c(0,0,0,1,0), c(0,0,1,0,0), c(0,0,0,1,0)
),
byrow=TRUE, nrow=18
)
## column naming according to birth stages
colnames(traits_stages_sk) <- BIRTH_STAGES_SK
colnames(traits_stages_gh) <- BIRTH_STAGES_GH
#traits_stages_mapping <-c()
str(traits_frequency_sk)
str(traits_stages_sk)
str(traits_stages_sk)
frequency_stage_map_sk_df <- data.frame(
traits_frequency_sk,traits_stages_sk,
check.rows=TRUE, row.names = TRAITS_LABELS_SK
)
frequency_stage_map_gh_df <- data.frame(
traits_frequency_gh,traits_stages_gh,
check.rows=TRUE, row.names = TRAITS_LABELS_GH
)
# ----------------------------------------------------------------
# prepare the data for LaTeX-Code Generation
# ----------------------------------------------------------------
## Set column names
colnames(frequency_stage_map_sk_df)<- c(FREQUENCY_COLUMN_NAME, BIRTH_STAGES_SK)
colnames(frequency_stage_map_gh_df)<- c(FREQUENCY_COLUMN_NAME, BIRTH_STAGES_GH)
## set "x" if value=1 and " " if value=0
for ( i in seq_along(frequency_stage_map_sk_df)) {
for(j in seq_along(frequency_stage_map_sk_df[,i])){
if (frequency_stage_map_sk_df[j,i] == 1){
frequency_stage_map_sk_df[j,i] <- BITH_STAGE_MARKER_POSITIVE
}
if (frequency_stage_map_sk_df[j,i] == 0){
frequency_stage_map_sk_df[j,i] <- BITH_STAGE_MARKER_NEGATIVE
}
}
}
## set "x" if value=1 and " " if value=0
for ( i in seq_along(frequency_stage_map_gh_df)) {
for(j in seq_along(frequency_stage_map_gh_df[,i])){
if (frequency_stage_map_gh_df[j,i] == 1){
frequency_stage_map_gh_df[j,i] <- BITH_STAGE_MARKER_POSITIVE
}
if (frequency_stage_map_gh_df[j,i] == 0){
frequency_stage_map_gh_df[j,i] <- BITH_STAGE_MARKER_NEGATIVE
}
}
}
# ----------------------------------------------------------------
# prepare the data for further analysis (factors)
# ----------------------------------------------------------------
factor_frequency_sk <- factor(traits_frequency_sk, order = TRUE, levels = c("nicht zutreffend",
"nie",
"selten",
"selten-häufig",
"häufig",
"immer"
)
)
factor_frequency_gh <- factor(traits_frequency_gh, order = TRUE, levels = c("nicht zutreffend",
"nie",
"selten",
"selten-häufig",
"häufig",
"immer"
)
)
factor_frequency_sk
factor_frequency_gh
# ----------------------------------------------------------------
# print the data
# ----------------------------------------------------------------
print(frequency_stage_map_sk_df)
print(frequency_stage_map_gh_df)
# ----------------------------------------------------------------
# Generate the LaTeX-Table
# ----------------------------------------------------------------
## 1 digit "after comma" for the last who values. Otherwise integers only
print("LaTeX Tabelle mit Daten von Samuel Kohler")
xtable(frequency_stage_map_sk_df,
caption=LATEX_TABLE_CAPTION_SK,
)
print("LaTeX Tabelle mit Daten von Gaby Hirsbrunnder")
xtable(frequency_stage_map_gh_df,
caption=LATEX_TABLE_CAPTION_GH,
)
# ==========================================================
# END
# ==========================================================