-
Notifications
You must be signed in to change notification settings - Fork 1
/
.Rhistory
512 lines (512 loc) · 15.4 KB
/
.Rhistory
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
print("IG Downloading...")
# Create directory if not there
createOutputDirectory(sourceDir,"downloads")
# Reads from phuse github biocelerate location
base <- "https://github.com/phuse-org/BioCelerate/tree/master/metadata"
path <- paste0(base, IGFile)
CTxl <- paste0(IGDownloadsDir,IGFile)
print(paste0("Downloading the IG file... ",path))
GET(path, write_disk(CTxl),timeout(40))
}
df <- readWorksheet(loadWorkbook(paste0(IGDownloadsDir, IGFile)), sheet = "SENDIG 3.1 Variables")
dfSENDIG <<- df
bSENDIGRead <<- TRUE
}
}
# This function checks columns to verify if the column needs to be included
# based upon the columns core requirement. Returns a logical vector. TRUE
# if it should be included, FALSE otherwise
# TODO: This isn't very effiecent
checkCore <- function(dataset) {
# Create TF vector for permisable columns
domain_i <- unique(dataset$DOMAIN)
cores <- dfSENDIG[dfSENDIG$Domain == domain_i, "Expectancy"]
isPerm <- cores == "Perm"
# Create TF vector for blank cols
blankCol <- apply(dataset, 2, function(x) all(is.na(x)))
# Return vector where both conditions are true.
!(isPerm & blankCol)
}
# Reset within the dataframe as numeric columns that should be numeric
setSENDNumeric <- function(dataset) {
domain_i <- unique(dataset$DOMAIN)
numerics <- dfSENDIG[dfSENDIG$Domain == domain_i & dfSENDIG$Type=="Num", "Column"]
numerics <- intersect(numerics,names(dataset))
printDebug(paste(" In setSENDNumeric set numeric for these variables",numerics))
if (length(numerics)>1) {
dataset[numerics] <- suppressWarnings(sapply(dataset[numerics],as.numeric))
} else {
dataset[numerics] <- as.numeric(dataset[[numerics]])
printDebug(paste(" In setSENDNumeric",class(dataset[[numerics]])))
}
dataset
}
createOutputDirectory <- function (aDir,aStudy) {
setwd(aDir)
if (file.exists(aStudy)){
setwd(file.path(aDir, aStudy))
} else {
dir.create(file.path(aDir, aStudy))
setwd(file.path(aDir, aStudy))
}
}
sleepSeconds <- function(x)
{
p1 <- proc.time()
Sys.sleep(x)
proc.time() - p1 # The cpu usage should be negligible
}
bSENDIGRead
bSENDIGRead <<- FALSE
bSENDIGRead
SENDIG
dfSENDIG
remove(dfSENDIG)
dfSENDIG
readDomainStructures()
df <- readWorksheet(loadWorkbook(paste0(IGDownloadsDir, IGFile)), sheet = "SENDIG 3.1 Variables")
readDomainStructures()
IGFile <- "sendig-3-1-excel.xls"
IGDownloadsDir <- paste0(sourceDir, "/downloads/")
e
IGFile <- "sendig-3-1-excel.xls"
IGDownloadsDir <- paste0(sourceDir, "/downloads/")
df <- readWorksheet(loadWorkbook(paste0(IGDownloadsDir, IGFile)), sheet = "SENDIG 3.1 Variables")
paste0(IGDownloadsDir, IGFile))
paste0(IGDownloadsDir, IGFile)
loadWorkbook(paste0(IGDownloadsDir, IGFile))
loadWorkbook(paste0(IGDownloadsDir, IGFile))
library("XLConnect")
loadWorkbook(paste0(IGDownloadsDir, IGFile))
readDomainStructures()
exit
quit
stop
stop
exit
readDomainStructures()
readDomainStructures()
library(shiny); runApp('~/SEND-TestDataFactory/SendDataFactory.R')
dfSENDIG
bSENDIGRead
readDomainStructures()
bSENDIGRead
dfSENDIG
labels(readDomainStructures)
dfSENDIG
head(dfSENDIG)
cols(dfSENDIG)
ncol(dfSENDIG)
dfSENDIG$Type
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
bSENDIGremove())
remoev
remove(dfSENDIG)
remove(bSENDIGRead)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
labels(dfSEND)
labels(dfSENDIG)
labels(dfSENDIG)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
readDomainStructures()
df
readDomainStructures()
labels(df)
labels(df)
n
readDomainStructures()
labels(df)
readDomainStructures()
readDomainStructures()
readDomainStructures()
Q
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
remove(dfSENDIG)
remove(bSENDIGRead)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
setSENDNumeric(bwOut)
domain_i
numerics
remove(bSENDIGRead)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
dfSENDIG[dfSENDIG$Domain == domain_i & dfSENDIG$Type=="Num", "Column"]
domain_i <- "BW"
dfSENDIG[dfSENDIG$Domain == domain_i & dfSENDIG$Type=="Num", "Column"]
numerics <- dfSENDIG[dfSENDIG$Domain == domain_i & dfSENDIG$Type=="Num", "Column"]
numerics <- intersect(numerics,names(dataset))
dataset <- BWOut
dataset <- bwOut
numerics <- dfSENDIG[dfSENDIG$Domain == domain_i & dfSENDIG$Type=="Num", "Column"]
numerics <- intersect(numerics,names(dataset))
numerics
class(bwOut$STUDYID)
class(bwOut$BWDY)
class(bwOut$BWNOMDY)
labels(aDFReturned)
labels(aDFReturned)[2]
labels(aDFReturned)[1]
labels(aDFReturned)[2]
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn,]$Label
aColumn <- BWNOMLBL
aColumn <- "BWNOMLBL"
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn,]$Label
aDescription
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
theColumns <- labels(aDFReturned)[2]
index <- 1
for (aColumn in theColumns) {
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn,]$Label
Hmisc::label(aDFReturned$aColumn) <<- aDescription
index <- index + 1
}
aDFReturned <- bwOut
theColumns <- labels(aDFReturned)[2]
index <- 1
for (aColumn in theColumns) {
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn,]$Label
Hmisc::label(aDFReturned$aColumn) <<- aDescription
index <- index + 1
}
aDFReturned
theColumns <- labels(aDFReturned)[2]
index <- 1
for (aColumn in theColumns) {
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn,]$Label
Hmisc::label(aDFReturned$aColumn) <<- aDescription
index <- index + 1
}
labels(aDFReturned)[2]
aDFReturned$aColumn
aColumn
theColumns
length(theColumns)
theColumns
ncol(theColumns)
class(theColumns)
size(list())
size(theColumns)
dataList=list("Hello", c("USA", "Red", "100"), c("India", "Blue", "76"))
for(i in dataList){print(i)}
dataList=list("Hello", c(theColumns)
for(i in dataList){print(i)}
dataList=list("Hello", c(theColumns)
for(i in dataList){print(i)}
dataList=list("Hello", c(theColumns))
for(i in dataList){print(i)}
class(theColumns)
for(i in theColumns){for(j in i){print(j)}}
for(i in theColumns){for(j in i){print(j)}}
theColumns <- labels(aDFReturned)[2]
index <- 1
for (i in theColumns) {
for(aColumn in i){
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn,]$Label
Hmisc::label(aDFReturned$aColumn) <<- aDescription
index <- index + 1
}
}
aColumn
aDFReturned$aColumn
aDescription
dfSENDIG[dfSENDIG$Column==aColumn && dfSENDIG$Domain==aDomain,]$Label
aDomain <- "BW"
dfSENDIG[dfSENDIG$Column==aColumn && dfSENDIG$Domain==aDomain,]$Label
dfSENDIG[dfSENDIG$Column==aColumn & dfSENDIG$Domain==aDomain,]$Label
aDFReturned$aColumn
aDFReturned$[aColumn]
aDFReturned$[[aColumn]]
aDFReturned[,aColumn]
aDFReturned[,aColumn]
for (i in theColumns) {
for(aColumn in i){
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn & dfSENDIG$Domain==aDomain,]$Label
Hmisc::label(aDFReturned[,aColumn]) <<- aDescription
}
}
Hmisc::label(aDFReturned[,aColumn]) <<- aDescription
aDFReturned
Hmisc::label(aDFReturned[,aColumn]) <<- aDescription
Hmisc::label(aDFReturned[,aColumn]) <- aDescription
Hmisc::label(aDFReturned[,aColumn])
Hmisc::label(aDFReturned)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
numerics
head(bwOut)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
setSENDNumeric(bwOut)
length(numerics)
length(numerics)
dataset[numerics] <- suppressWarnings(sapply(dataset[numerics],as.numeric))
printDebug(paste(" In setSENDNumeric",class(dataset[[numerics]])))
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
setLabels("BW",bwOut)
# set description labels for each field
setLabels <- function(theDomain, theDataset) {
printDebug(paste(" In setLabels"))
theColumns <- labels(theDataset)[2]
printDebug(paste(" In setLabels, columns are",theColumns))
for (i in theColumns) {
for(aColumn in i){
aDescription <- dfSENDIG[dfSENDIG$Column==aColumn & dfSENDIG$Domain==theDomain,]$Label
Hmisc::label(theDataset[,aColumn]) <- aDescription
printDebug(paste(" In setLabels",aColumn,aDescription))
}
}
theDataset
}
setLabels("BW",bwOut)
Hmisc::label(theDataset)
Hmisc::label(bwOut)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
anAge <-as.character((TSFromFile[TSFromFile$TSPARMCD=="AGETXT",]$TSVAL))
anAge
anAgeUnit <-as.character((TSFromFile[TSFromFile$TSPARMCD=="AGEU",]$TSVAL))
anAgeUnit
str_trim(anAgeUnit)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
removeColumns <- function(theDataSet) {
# if all NA, remove empty columns
emptycols <- sapply(theDataSet, function (k) all(is.na(k)))
df <- df[!emptycols]
}
head(bwOut)
head(bwOut)
removeColumns(bwOut)
removeColumns <- function(theDataSet) {
# if all NA, remove empty columns
emptycols <- sapply(theDataSet, function (k) all(is.na(k)))
theDataSet <- theDataSet[!emptycols]
theDataSet
}
removeColumns(bwOut)
bwOut <- removeColumns(bwOut)
head(bwOut)
bwOut _<- removeColumns(bwOut)
bwOut <<- removeColumns(bwOut)
bwOut <- removeColumns(bwOut)
bwOut <<- removeColumns(bwOut)
head(bwOut)
head(clOut)
bwOut <<- removeColumns(clOut)
clOut <<- removeColumns(clOut)
head(clOut)
clOut$CLSTAT
removeColumns <- function(theDataSet) {
# if all NA, remove empty columns
theDataSet[theDataSet=="NA"] <- ""
emptycols <- sapply(theDataSet, function (k) all(is.na(k)))
theDataSet <- theDataSet[!emptycols]
theDataSet
}
clOut <<- removeColumns(clOut)
head(clOut)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
setSENDNumeric(dsOut)
setSENDNumeric(dfOut)
setDSFile()
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
bwOut
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
round(aValue, digits=4)
avalue <- 2
avalue
avalue <- 2+3
avalue
tsOut
dmOut
head(dmOut)
bwOut
labels(bwOut)
hmisc:label(bwOut)
hmisc::label(bwOut)
Hmisc::label(bwOut)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
head(dsOut)
dsOut <<- setLabels (aDomain, tOut)
dsOut <<- setLabels ("DS", tOut)
dsOut <<- setLabels ("DS", dsOut)
head(dsOut)
dsOut <<- setLabels ("DS", dsOut)
tOut <<- dsOut
tOut <<- removeColumns(tOut)
tOut <<- setSENDNumeric(tOut)
printDebug(paste("Now setting DS labels"))
# set labels for each field
dsOut <<- setLabels (aDomain, tOut)
head(dsOut)
tOut <<- removeColumns(tOut)
tOut <<- setSENDNumeric(tOut)
printDebug(paste("Now setting DS labels"))
# set labels for each field
dsOut <<- setLabels (aDomain, tOut)
dsOut <<- setLabels (aDomain, tOut)
aDomain
aDomain <- "DS"
dsOut <<- setLabels (aDomain, tOut)
head(dsOut)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
head(taOut)
head(taOut armcd_i <- dmOut[dmOut$USUBJID == animal_i, "ARMCD"])
armcd_i <- dmOut[dmOut$USUBJID == animal_i, "ARMCD"]
armcd_i <- dmOut[dmOut$USUBJID == "MyStudy-1M1", "ARMCD"]
armcd_i
armcd_i <- dmOut[dmOut$USUBJID == "MyStudy-1M1", "ARM"]
armcd_i
TSFromFile[TSFromFile$TSPARMCD == "ROUTE", "TSVAL"]
as.character(TSFromFile[TSFromFile$TSPARMCD == "ROUTE", "TSVAL"])
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
as.character(TSFromFile[TSFromFile$TSPARMCD == "ROUTE
if (exists("bwOut")) {
removeTab(inputId = "navDatasets",target = "BW")
insertTab(inputId = "navDatasets",
tabPanel("BW",tableOutput("showBW")),
position = 'after',
target = "TS"
)
}
exOut
library(shiny); runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
class(seOut$SESEQ)
class(seOut$DOMAIN)
class(seOut$SESEQ)
seOut$SESEQ
seOut$SESEQ[1]
seOut$SESEQ[2]
seOut$SESEQ[3]
seOut$SESEQ[4]
class(seOut$SESEQ[1])
class(seOut$SESEQ)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
class(seOut$SESEQ)
class(seOut$SESEq)
class(seOut$SESEQ)
labels(stOut)
labels(seOut)
class(seOut$STUDYID)
class(seOut$DOMAIN)
class(seOut$USUBJID)
class(seOut$ETCD)
class(seOut$SESTDTC)
class(seOut$SEENDTC)
class(seOut$SEUPDES)
dataset[numerics] <- suppressWarnings(sapply(dataset[numerics],as.numeric))
dataset[numerics] <- suppressWarnings(sapply(dataset[numerics],as.numeric))
dataset <- seOut
dataset[numerics] <- suppressWarnings(sapply(dataset[numerics],as.numeric))
numerics <- c("SESEQ")
dataset[numerics] <- suppressWarnings(sapply(dataset[numerics],as.numeric))
dataset[numerics] <- (sapply(dataset[numerics],as.numeric)
)
dataset[numerics] <- sapply(dataset[numerics],as.numeric)
class(seOut$SESEQ)
numerics
dataset[numerics] <- sapply(dataset[numerics],as.numeric)
as.numeroc(seOut$SESEQ)
as.numeric(seOut$SESEQ)
class(as.numeric(seOut$SESEQ))
seOut <<- setSENDNumeric(seOut)
class(seOut$SESEQ)
labels(bwOut)
labels(seOut)
class(as.numeric(seOut$DOMAIN))
class(as.numeric(seOut$SESEQ))
class(seOut$SESEQ)
seOut
remove(seOut)
remove(seOut)
remove(seOut)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
class(seOut$SESEQ)
class(seOut$BWSEQ)
class(bwOut$BWSEQ)
Hmisc::label(bwOut)
Hmisc::label(seOut)
tOut <- seOut
class(seOut$SESEQ)
tOut$SESEQ <<- 1:nrow(aDataset)
tOut <<- setSENDNumeric(tOut)
tOut$SESEQ <<- 1:nrow(tOut)
tOut <<- setSENDNumeric(tOut)
head(tOut)
tOut$SESEQ <<- 1:nrow(tOut)
nrow(tOut)
1:nrow(tOut)
tOut$SESEQ <<- 1:nrow(tOut)
tOut$SESEQ <<- 1:nrow(tOut)
tOutCopy <- tOut
tOut$SESEQ <<- 1:nrow(tOutCopy)
tOut <<- setSENDNumeric(tOut)
tOut$SESEQ <<- 1:nrow(tOutCopy)
tOut$SESEQ
tOut$SESEQ <<- 1:nrow(tOutCopy)
tOut$SESEQ <<- 3
tOut$SESEQ <- 3
remove(tOut)
tOut <<- seOut
tOut$SESEQ <<- 1:nrow(tOut)
tOut$SESEQ
tOut$SESEQ <<- 1:nrow(tOut)
tOut$SESEQ <- 1:nrow(tOut)
remove(tOut)
remove(tOut)
tOut$SESEQ <- 1:nrow(tOut)
tOut <<- seOut
tOut$SESEQ <- 1:nrow(tOut)
class(tout$SESEQ)
class(tOut$SESEQ)
tOut <<- setSENDNumeric(tOut)
class(tOut$SESEQ)
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
theArm <- dmOut[dmOut$USUBJID == animal_i, "ARM"]
dmOut$USUBJID
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')
runApp('~/SEND-TestDataFactory/SendDataFactory.R')