library(readxl)
TBI <- read_excel("Downloads/TBI.xlsx")
TBI<-as.data.frame(TBI)
emptycols <- colSums(is.na(TBI)) == nrow(TBI)
TBI <- TBI[!emptycols]
library(spida2)
names(TBI) <- sub('_', '.', names(TBI))
names(TBI) <- sub('_', '.', names(TBI))
names(TBI) <- sub('_', '.', names(TBI))
#Some varibles have both _ . in them; unify them into .
names(TBI) <- sub('.([1-5])$', '_\\1', names(TBI))
# changes _1, _2, _3, _4, _5 to .1, .2, .3, .4, .5 if the pattern occurs at the end of a variable name
dlong <- tolong(TBI, sep = '_')
DOI <- as.POSIXct(dlong$DOI, format = "%m/%d/%Y %H:%M")
Date<-as.POSIXct(dlong$date, format = "%m/%d/%Y %H:%M")
dlong$elp<-difftime(Date,DOI,units = "days")
VBR is the ratio of the ventricle to brain. ventricle measures the holes,which is filled with spinal fuild,as compared to the “solid” part to the brain.If brain volume shrinks, VBR goes up\(^1\)
Source:1.http://mtor.sci.yorku.ca/MATH4939/
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following object is masked from 'package:spida2':
##
## labs
VBR<- cbind.data.frame(dlong$elp,dlong$VBR,dlong$group)
VBR<-na.omit(VBR)
VBR$elp<-as.vector(VBR$elp)
ggplot(VBR, aes(`dlong$elp`,`dlong$VBR`,fill=`dlong$group`))+
geom_point(colour="pink")+
ggtitle(" Time Elapsed vs VBR")+
stat_ellipse()+
geom_smooth(formula=y~x,method = "lm" ,linetype=1,se=FALSE)+
xlab("Time Elapsed") +
ylab("VBR") +
labs(fill="Group")
## Don't know how to automatically pick scale for object of type difftime. Defaulting to continuous.
From the plot above, we can see that the general trend (regression line) is slightly inceasing as more time passes since the date of injury with it being 0 (since we are measuring time elapsed). However, due to a lack of data either in VBR or date(aka.time elapsed), there might be information that we missed,especially when there are a little data presented as time increases. Additionally, due to a lack date data presented for the control group, it is impossible to graph the changes in VBR for control group, which also making it impossible to compare patient group with control group.
library(ggplot2)
TOT<- cbind.data.frame(dlong$elp,dlong$CC.TOT,dlong$group)
TOT<-na.omit(TOT)
ggplot(TOT, aes(`dlong$elp`,`dlong$CC.TOT`,fill=`dlong$group`))+
geom_point(colour="pink")+
ggtitle(" Time Elapsed vs CC.TOT")+
stat_ellipse()+
geom_smooth(formula=y~x,method = "lm" ,linetype=1,se=FALSE)+
xlab("Time Elapsed") +
ylab("CC.TOT") +
labs(fill="Group")
## Don't know how to automatically pick scale for object of type difftime. Defaulting to continuous.
The regression line shows a general decreasing trend in CC.TOT as time elapses. However, there are missing data either in CC.TOT or date, making graphing these points impossible. So, we could not get more information, such as more data as time increaseses. Additionally, since no date information is provided for control group, it is not possible to graph the relationship between CC.TOT and Time and to compare between patient group and control group.
library(ggplot2)
HPC_L<- cbind.data.frame(dlong$elp,dlong$HPC.L.TOT,dlong$group)
HPC_L<-na.omit(HPC_L)
ggplot(HPC_L, aes(`dlong$elp`,`dlong$HPC.L.TOT`,fill=`dlong$group`))+
geom_point(colour="pink")+
ggtitle(" Time Elapsed vs HPC.R.TOT")+
stat_ellipse()+
geom_smooth(formula=y~x,method = "lm" ,linetype=1,se=FALSE)+
xlab("Time Elapsed") +
ylab("THPC.L.TOT") +
labs(fill="Group")
## Don't know how to automatically pick scale for object of type difftime. Defaulting to continuous.
The regression line between HPC.L.TOT and Time Elapsed is almost flat.This means there is week decreasing relationship between HPC.L.TOT and Time Elapsed. Additionally, due to a lack of data, especially as time increases, we could not know more information. For example, since control group doesn’t contain any date data, we could not compare its HPC.L.TOT relationship aginst time with that of the patient group.
library(ggplot2)
HPC_R<- cbind.data.frame(dlong$elp,dlong$HPC.R.TOT,dlong$group)
HPC_R<-na.omit(HPC_R)
ggplot(HPC_R, aes(`dlong$elp`,`dlong$HPC.R.TOT`,fill=`dlong$group`))+
geom_point(colour="pink")+
ggtitle(" Time Elapsed vs HPC.R.TOT")+
stat_ellipse()+
geom_smooth(formula=y~x,method = "lm" ,linetype=1,se=FALSE)+
xlab("Time Elapsed") +
ylab("HPC.R.TOT") +
labs(fill="Group")
## Don't know how to automatically pick scale for object of type difftime. Defaulting to continuous.
The HPC.R.TOT is decreasing as time elapses.However, there is a lack of date, which means we could not get any more information. For examples, we could not get the trend for control group and compared it aginst patient group and there is a little data as time increased.
For all the graph, it is obvious that there are a little data as time increases, which might makes the trend of those variables against time not very accurate. Additionally, due to a lack data, we could not compare control control group against patient group.
Below is a table for of how many observations for each subject.Since for each visit (each observation) the data has record of the patients’ID, simply measuring the frequency of patients’ID would yield the number of observations for each subject.
library(plyr)
##
## Attaching package: 'plyr'
## The following object is masked from 'package:spida2':
##
## here
ta<-count(dlong, 'id')
names(ta)<-c("Subjet","Number of Observations")
ta
## Subjet Number of Observations
## 1 312 5
## 2 313 5
## 3 315 5
## 4 316 5
## 5 317 5
## 6 318 5
## 7 319 5
## 8 320 5
## 9 321 5
## 10 322 5
## 11 323 5
## 12 324 5
## 13 325 5
## 14 327 5
## 15 328 5
## 16 329 5
## 17 330 5
## 18 331 5
## 19 333 5
## 20 335 5
## 21 337 5
## 22 338 5
## 23 339 5
## 24 340 5
## 25 341 5
## 26 343 5
## 27 344 5
## 28 345 5
## 29 346 5
## 30 347 5
## 31 348 5
## 32 349 5
## 33 350 5
## 34 352 5
## 35 353 5
## 36 354 5
## 37 355 5
## 38 357 5
## 39 358 5
## 40 359 5
## 41 361 5
## 42 362 5
## 43 363 5
## 44 364 5
## 45 365 5
## 46 366 5
## 47 367 5
## 48 368 5
## 49 369 5
## 50 370 5
## 51 371 5
## 52 372 5
## 53 374 5
## 54 376 5
## 55 377 5
## 56 378 5
## 57 379 5
## 58 380 5
## 59 382 5
## 60 389 5
## 61 392 5
## 62 393 5
## 63 394 5
## 64 395 5
## 65 397 5
## 66 399 5
## 67 401 5
## 68 402 5
## 69 403 5
## 70 404 5
## 71 406 5
## 72 407 5
## 73 408 5
## 74 409 5
## 75 410 5
## 76 411 5
## 77 412 5
## 78 413 5
## 79 415 5
## 80 416 5
## 81 418 5
## 82 419 5
## 83 420 5
## 84 421 5
## 85 422 5
## 86 423 5
## 87 424 5
## 88 426 5
## 89 427 5
## 90 429 5
## 91 430 5
## 92 432 5
## 93 433 5
## 94 435 5
## 95 436 5
## 96 437 5
## 97 438 5
## 98 439 5
## 99 440 5
## 100 441 5
## 101 444 5
## 102 445 5
## 103 446 5
## 104 447 5
## 105 448 5
## 106 449 5
## 107 450 5
## 108 451 5
## 109 452 5
## 110 453 5
## 111 455 5
## 112 457 5
## 113 459 5
## 114 461 5
## 115 462 5
## 116 463 5
## 117 464 5
## 118 465 5
## 119 468 5
## 120 469 5
## 121 470 5
## 122 471 5
## 123 473 5
## 124 c01 5
## 125 c02 5
## 126 c03 5
## 127 c04 5
## 128 c05 5
## 129 c08 5
## 130 c11 5
## 131 c12 5
## 132 c24 5
## 133 c25 5
## 134 c26 5
## 135 c27 5
## 136 c34 5
## 137 c35 5
## 138 c36 5
## 139 c37 5
## 140 c38 5
## 141 c39 5
## 142 c40 5
## 143 c41 5
## 144 c42 5
## 145 c43 5
## 146 c44 5
## 147 c45 5
## 148 c46 5
## 149 c47 5
## 150 c48 5
## 151 c49 5
## 152 c50 5
## 153 c51 5
## 154 c52 5
## 155 c53 5