R 3D Ellipsoid Graph- How to change axis limits? - r

I am trying to make a 3D plot showing the relationship between x, y, and z, based on a sample program I found. However, as you can see in the picture, all the x and y points are clumped together. I need the x and y limits to be from about .35 to.5 and from .275 to .4, respectively. I think the problem may be from this step:
Cov <- matrix(c(3,3.5,0,3.5,10,0,0,0,1), 3,3)
I am not exactly sure what this line does.
Any help fixing this issue would be much appreciated.
data <- read.table(textConnection(
'x y z
0.461 0.348 5.42
0.429 0.343 4.99
0.457 0.336 5.22
0.402 0.332 4.5
0.438 0.331 4.66
0.426 0.33 4.69
0.43 0.329 4.83
0.398 0.329 4.41
0.43 0.326 4.74
0.426 0.326 4.71
0.442 0.325 4.81
0.433 0.322 4.72
0.407 0.322 4.14
0.405 0.322 4.43
0.394 0.322 4.07
0.384 0.321 4.03
0.432 0.32 4.64
0.417 0.319 4.47
0.409 0.319 4.48
0.443 0.317 4.59
0.41 0.317 4.23
0.417 0.316 4.14
0.421 0.316 4.46
0.408 0.316 4.42
0.405 0.315 4.2
0.4 0.312 4.17
0.426 0.307 4.15
0.395 0.304 4.03
0.384 0.301 3.77
0.39 0.299 4.23
0.414 0.324 4.44
0.359 0.314 3.54
0.421 0.307 4.4
0.415 0.325 4.62
0.398 0.321 4.25
0.38 0.306 3.84
0.394 0.312 3.95
0.401 0.325 4.16
0.432 0.315 4.55
0.42 0.328 4.28
0.437 0.315 4.5
0.412 0.322 4.47
0.396 0.307 4.08
0.413 0.326 4.12
0.384 0.31 3.78
0.393 0.307 4.04
0.399 0.305 4.3
0.4 0.312 4.22
0.421 0.323 4.72
0.395 0.312 4.28
0.382 0.303 3.86
0.396 0.323 4.3
0.385 0.3 4.01
0.411 0.311 4.05
0.406 0.326 4.3
0.394 0.321 3.99
0.406 0.314 3.98
0.413 0.325 4.64
0.457 0.34 5.5
0.403 0.321 4.34
0.376 0.302 3.8
0.36 0.305 3.54
0.422 0.311 4.35
0.369 0.316 3.91
0.385 0.3 3.79
0.398 0.31 4.07
0.365 0.296 3.67
0.389 0.317 4.13
0.445 0.327 4.66
0.426 0.331 4.67
0.383 0.309 3.88
0.376 0.314 4.02
0.406 0.322 4.77
0.406 0.333 4.43
0.378 0.317 3.98
0.397 0.311 4.01
0.389 0.324 4.41
0.364 0.308 3.88
0.38 0.307 3.91
0.381 0.32 4.5
0.363 0.302 3.82
0.404 0.33 4.21
0.342 0.292 3.3
0.376 0.3 3.91
0.388 0.311 4.1
0.369 0.32 3.82
0.367 0.317 3.78
0.375 0.314 3.93
0.414 0.323 4.46
0.393 0.321 4.23
0.391 0.323 4.23
0.402 0.321 4.25
0.431 0.313 4.6
0.446 0.349 5.27
0.392 0.3 3.72
0.378 0.302 3.69
0.391 0.327 4.31
0.41 0.327 4.6
0.418 0.323 4.36
0.434 0.346 4.91
0.375 0.299 3.77
0.379 0.315 4
0.414 0.329 4.52
0.396 0.326 4.01
0.335 0.293 3.17
0.398 0.311 3.95
0.38 0.312 3.79
0.366 0.306 3.82
0.376 0.307 4.01
0.419 0.327 4.73
0.384 0.306 3.77
0.396 0.313 3.91
0.378 0.308 3.81
0.39 0.306 3.85
0.381 0.32 3.88
0.401 0.332 4.83
0.408 0.329 4.29
0.412 0.323 4.48
0.411 0.318 4.4
0.398 0.313 4.05
0.418 0.328 4.53
0.389 0.32 4.32
0.417 0.311 4.4
0.415 0.315 4.53
0.378 0.302 3.78
0.422 0.318 4.62
0.411 0.315 4.13
0.381 0.324 4.12
0.436 0.33 4.68
0.422 0.335 4.48
0.371 0.302 3.6
0.4 0.317 4.17
0.433 0.332 4.73
0.374 0.317 3.93
0.382 0.308 3.76
0.437 0.325 4.79
0.39 0.325 4.33
0.386 0.316 4.01
0.453 0.337 4.96
0.404 0.31 4.4
0.4 0.317 4.22
0.395 0.304 4.02
0.38 0.319 4.02
0.369 0.296 3.82
0.397 0.327 4.43
0.421 0.338 4.72
0.394 0.317 4.3
0.446 0.334 4.99
0.407 0.309 4.42
0.428 0.322 4.51
0.413 0.322 4.51
0.387 0.308 3.96
0.413 0.316 4.37
0.461 0.349 5.4
0.401 0.314 4.04
0.388 0.319 4.04
0.408 0.326 4.54
0.396 0.317 4.35
0.41 0.329 4.54
0.434 0.34 4.86
0.388 0.318 3.86
0.374 0.311 3.8
0.415 0.329 4.51
0.402 0.313 4.12
0.375 0.322 4
0.425 0.325 4.45
0.36 0.306 3.82
0.391 0.335 4.43
0.444 0.343 5.35
0.369 0.311 3.98
0.395 0.323 4.4
0.368 0.309 3.77
0.349 0.305 3.66
0.348 0.292 3.43
0.368 0.303 3.52
0.425 0.341 4.7
0.402 0.322 4.36
0.46 0.34 5.28
0.413 0.317 4.59
0.383 0.309 3.88
0.416 0.325 4.4
0.401 0.339 4.56
0.386 0.316 3.78
0.451 0.339 5.05
0.401 0.32 4.23
0.42 0.332 4.64
0.436 0.338 4.88
0.378 0.322 3.99
0.425 0.336 4.75
0.415 0.335 4.64
0.403 0.321 4.44
0.362 0.303 3.77
0.399 0.331 4.17
0.39 0.311 4.2
0.379 0.322 4.12
0.424 0.335 4.63
0.422 0.341 4.82
0.383 0.314 4.05
0.436 0.35 5.3
0.378 0.324 4.09
0.413 0.332 4.77
0.373 0.304 3.62
0.371 0.317 4.1
0.339 0.298 3.17
0.408 0.321 4.3
0.402 0.332 4.54
0.403 0.333 4.95
0.419 0.338 4.86
0.454 0.312 4.66
0.39 0.318 4.04'), header = TRUE)
Mean <- c(0.402,0.319, 4.279)
Mean
Cov <- matrix(c(3,3.5,0,3.5,10,0,0,0,1), 3,3)
Cov
round(var(data),2)
round(Cov - var(data),2)
options(rgl.printRglwidget = TRUE)
open3d()
plot3d(data, box=TRUE,
xlab="x", ylab="y", zlab="z")
aspect3d("iso")
dataMean <- colMeans(data)
dataCov <- var(data)
plot3d( ellipse3d(Cov,centre=Mean, level=.9),
col="cyan", alpha=0.5, add = TRUE)][1]][1]

The Cov <- line is defining a covariance matrix. I'm assuming these values are leftover from the script you found? I notice that the Mean vector matches the column means of your dataset (colMeans(data)), so I'm hoping that all that needs to happen is to update the Cov matrix.
The following appeared to work for me (updated to dataCov and took out the aspect3d("iso") line) - hope it works on your machine too. BTW - there was a typo in one of your square brackets.
options(rgl.printRglwidget = TRUE)
open3d()
plot3d(data, box=TRUE,
xlab="x", ylab="y", zlab="z")
# aspect3d("iso") ## this makes it long and skinny and ugly
dataMean <- colMeans(data)
dataCov <- var(data)
plot3d(ellipse3d(dataCov,centre=Mean, level=.9),
col="cyan", alpha=0.5, add = TRUE)[[1]][1]

Related

Error in plot.xy(xy, type, ...) : invalid color name 'A'

I am working on a paper writing exercise and was provided the following R code to use analyze a given data set. It has worked perfectly until I reach this last step and then I receive this error and I'm not sure how/where I need to redefine the color as I need the scatter plot to be two different colors for the groups. Its the very last line that doesnt produce the needed graph. Thanks for the help.
dat<-read.table("F:/University/NSU_TEACHING/NEW_CORES/NEW_MARINE
GEOLOGY/NEW_MODULES_2015_7/Online_data/SANDS2.txt", header=F)
par(mfrow=c(1,2))
plot(dat$V2,col="blue",main="Median grain size" )
plot(dat$V3,col="red",main="Sorting Coefficient")
boxplot(dat$V2~dat$V1,main="Median grain size" )
boxplot(dat$V3~dat$V1,main="Sorting Coefficient")
hist(dat$V2,main="Median grain size")
hist(dat$V3,main="Sorting Coefficient")
hist(dat$V2,main="Median grain size",breaks=20)
qqnorm(dat$V2,main="Median Grain Size"); qqline(dat$V2)
qqnorm(dat$V3,main="Sorting Coefficient"); qqline(dat$V3)
shapiro.test(dat$V2)
shapiro.test(dat$V3)
ks.test(dat$V2[dat$V1=="A"],dat$V2[dat$V1=="B"])
hist(dat$V2[dat$V1=="A"])
hist(dat$V2[dat$V1=="B"])
fligner.test(dat$V2~dat$V1)
t.test(dat$V2~dat$V1)
boxplot(dat$V2~dat$V1,notch=T,main="Median grain size" )
plot(dat[,c(2,3)],col=dat[,1])
Data set if needed
#Group A = Beach sands, Group B = Offshore sands, Column 2 = Median grain size in mm., Column 3 = Sorting coefficient
A 0.333 1.08
A 0.340 1.08
A 0.338 1.09
A 0.333 1.10
A 0.323 1.13
A 0.327 1.12
A 0.329 1.13
A 0.331 1.13
A 0.336 1.12
A 0.333 1.14
A 0.341 1.14
A 0.328 1.15
A 0.336 1.15
A 0.327 1.16
A 0.329 1.16
A 0.330 1.16
A 0.323 1.17
A 0.328 1.17
A 0.332 1.17
A 0.331 1.18
A 0.326 1.18
A 0.333 1.18
A 0.330 1.19
A 0.336 1.19
A 0.327 1.20
A 0.324 1.21
A 0.332 1.21
A 0.322 1.22
A 0.329 1.22
A 0.325 1.24
A 0.328 1.26
A 0.322 1.27
A 0.318 1.22
A 0.330 1.17
B 0.339 1.12
B 0.346 1.12
B 0.350 1.12
B 0.352 1.13
B 0.341 1.15
B 0.347 1.15
B 0.337 1.16
B 0.343 1.16
B 0.340 1.17
B 0.346 1.17
B 0.349 1.17
B 0.339 1.18
B 0.342 1.18
B 0.346 1.18
B 0.351 1.18
B 0.340 1.19
B 0.344 1.19
B 0.333 1.20
B 0.337 1.20
B 0.339 1.20
B 0.342 1.20
B 0.339 1.21
B 0.340 1.21
B 0.341 1.21
B 0.335 1.22
B 0.337 1.22
B 0.340 1.22
B 0.343 1.22
B 0.334 1.22
B 0.348 1.22
B 0.337 1.22
B 0.342 1.23
B 0.334 1.24
B 0.340 1.24
B 0.342 1.24
B 0.331 1.25
B 0.336 1.25
B 0.341 1.25
B 0.334 1.26
B 0.337 1.27
B 0.339 1.27
B 0.330 1.28
B 0.334 1.28
B 0.332 1.29
B 0.330 1.31
B 0.334 1.31
B 0.340 1.21
From comments:
I suspect this is a stringsAsFactors=FALSE problem. If the guide was written for R 3.0 and you're using R 4.0 or higher, the encoding of that column will be different. Try adding stringsAsFactors = TRUE to your original read.table call, or change the last line to plot(dat[,c(2,3)],col=factor(dat[,1]))

Unable to read SAS Transport File in R using Haven

I'm trying to view a SAS Transport File provided by CMS HCC risk adjustment model software files (2020 Model Software (zip)).
I already tried to open with SAS Universal Viewer to no luck.
Also tried reading in the file using library(haven) by doing the following.
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
setwd('~/Documents/MSSP/CMS-HCC software V2421.86.P1')
library(haven)
sasdata <- read_xpt("C2419P1M")
Which gave me the following error.
Error: Failed to parse Documents/MSSP/CMS-HCC software V2421.86.P1/C2419P1M: Invalid file, or file has unsupported features.
The read_xpt() from haven should be able to read the transport file according to the documentation.
Hoping someone may have a troubleshooting idea that I haven't come across.
The files are not SAS transport files. They are SAS CPORT files, created by PROC CPORT. So HAVEN cannot read them.
You seem to be asking about one data file that is just one observation with 1,039 variables. Here is SAS code to convert it to a text file with 1,039 lines containing the variable name and value.
%let path=C:\downloads\CMS-HCC;
libname out "&path";
proc cimport file="&path\C2419P1M" lib=out; run;
proc transpose data=out.C2419P1M out=C2419P1M(rename=(col1=VALUE)) name=NAME;
run;
filename text temp;
data _null_;
set C2419P1M;
file text;
put name value;
run;
Results:
CFA_F65_69 0.441
CFA_F70_74 0.519
CFA_F75_79 0.593
CFA_F80_84 0.716
CFA_F85_89 0.865
CFA_F90_94 0.987
CFA_F95_GT 1.041
CFA_M65_69 0.494
CFA_M70_74 0.6
CFA_M75_79 0.71
CFA_M80_84 0.803
CFA_M85_89 1
CFA_M90_94 1.142
CFA_M95_GT 1.267
CFA_OriginallyDisabled_Female 0.173
CFA_OriginallyDisabled_Male 0.182
CFA_HCC1 0.595
CFA_HCC2 0.453
CFA_HCC6 0.572
CFA_HCC8 2.566
CFA_HCC9 1.01
CFA_HCC10 0.717
CFA_HCC11 0.317
CFA_HCC12 0.158
CFA_HCC17 0.34
CFA_HCC18 0.34
CFA_HCC19 0.107
CFA_HCC21 0.693
CFA_HCC22 0.383
CFA_HCC23 0.211
CFA_HCC27 1.111
CFA_HCC28 0.411
CFA_HCC29 0.042
CFA_HCC33 0.258
CFA_HCC34 0.349
CFA_HCC35 0.275
CFA_HCC39 0.558
CFA_HCC40 0.371
CFA_HCC46 1.214
CFA_HCC47 0.452
CFA_HCC48 0.221
CFA_HCC54 0.538
CFA_HCC55 0.538
CFA_HCC56 0.538
CFA_HCC57 0.57
CFA_HCC58 0.57
CFA_HCC59 0.299
CFA_HCC60 0.299
CFA_HCC70 1.038
CFA_HCC71 0.921
CFA_HCC72 0.532
CFA_HCC73 1.101
CFA_HCC74 0
CFA_HCC75 0.407
CFA_HCC76 0.413
CFA_HCC77 0.742
CFA_HCC78 0.601
CFA_HCC79 0.237
CFA_HCC80 0.511
CFA_HCC82 2.183
CFA_HCC83 0.902
CFA_HCC84 0.492
CFA_HCC85 0.371
CFA_HCC86 0.377
CFA_HCC87 0.302
CFA_HCC88 0.034
CFA_HCC96 0.384
CFA_HCC99 0.38
CFA_HCC100 0.38
CFA_HCC103 0.487
CFA_HCC104 0.345
CFA_HCC106 1.724
CFA_HCC107 0.565
CFA_HCC108 0.294
CFA_HCC110 0.509
CFA_HCC111 0.43
CFA_HCC112 0.161
CFA_HCC114 0.641
CFA_HCC115 0.258
CFA_HCC122 0.271
CFA_HCC124 0.298
CFA_HCC134 0.683
CFA_HCC135 0.683
CFA_HCC136 0.26
CFA_HCC137 0.26
CFA_HCC138 0.017
CFA_HCC157 2.463
CFA_HCC158 1.471
CFA_HCC161 0.727
CFA_HCC162 0.162
CFA_HCC166 0.511
CFA_HCC167 0.144
CFA_HCC169 0.532
CFA_HCC170 0.409
CFA_HCC173 0.221
CFA_HCC176 0.68
CFA_HCC186 0.728
CFA_HCC188 0.742
CFA_HCC189 0.795
CFA_HCC51 0.453
CFA_HCC52 0.453
CFA_HCC159 0.863
CFA_HCC47_gCancer 0.853
CFA_DIABETES_CHF 0.192
CFA_CHF_gCopdCF 0.23
CFA_HCC85_gRenal_V24 0.187
CFA_gCopdCF_CARD_RESP_FAIL 0.528
CFA_HCC85_HCC96 0.138
CFA_D6 0.04
CFA_D7 0.057
CFA_D8 0.095
CFA_D9 0.156
CFA_D10P 0.373
CFD_F0_34 0.349
CFD_F35_44 0.349
CFD_F45_54 0.374
CFD_F55_59 0.434
CFD_F60_64 0.49
CFD_M0_34 0.24
CFD_M35_44 0.235
CFD_M45_54 0.307
CFD_M55_59 0.402
CFD_M60_64 0.526
CFD_HCC1 0.396
CFD_HCC2 0.53
CFD_HCC6 0.803
CFD_HCC8 2.801
CFD_HCC9 1.001
CFD_HCC10 0.756
CFD_HCC11 0.355
CFD_HCC12 0.212
CFD_HCC17 0.423
CFD_HCC18 0.423
CFD_HCC19 0.145
CFD_HCC21 0.723
CFD_HCC22 0.297
CFD_HCC23 0.299
CFD_HCC27 1.101
CFD_HCC28 0.365
CFD_HCC29 0.292
CFD_HCC33 0.538
CFD_HCC34 0.762
CFD_HCC35 0.551
CFD_HCC39 0.682
CFD_HCC40 0.328
CFD_HCC46 4.309
CFD_HCC47 0.691
CFD_HCC48 0.298
CFD_HCC54 0.896
CFD_HCC55 0.356
CFD_HCC56 0.348
CFD_HCC57 0.381
CFD_HCC58 0.231
CFD_HCC59 0.127
CFD_HCC60 0.1
CFD_HCC70 1
CFD_HCC71 0.957
CFD_HCC72 0.377
CFD_HCC73 1.245
CFD_HCC74 0
CFD_HCC75 0.404
CFD_HCC76 0.597
CFD_HCC77 0.789
CFD_HCC78 0.443
CFD_HCC79 0.139
CFD_HCC80 0.105
CFD_HCC82 1.465
CFD_HCC83 0.531
CFD_HCC84 0.531
CFD_HCC85 0.486
CFD_HCC86 0.425
CFD_HCC87 0.425
CFD_HCC88 0.152
CFD_HCC96 0.308
CFD_HCC99 0.486
CFD_HCC100 0.324
CFD_HCC103 0.296
CFD_HCC104 0.258
CFD_HCC106 1.748
CFD_HCC107 0.653
CFD_HCC108 0.267
CFD_HCC110 3.516
CFD_HCC111 0.331
CFD_HCC112 0.275
CFD_HCC114 0.375
CFD_HCC115 0
CFD_HCC122 0.269
CFD_HCC124 0.145
CFD_HCC134 0.594
CFD_HCC135 0.594
CFD_HCC136 0.323
CFD_HCC137 0.138
CFD_HCC138 0
CFD_HCC157 2.582
CFD_HCC158 1.38
CFD_HCC161 0.583
CFD_HCC162 0.308
CFD_HCC166 0.105
CFD_HCC167 0.025
CFD_HCC169 0.377
CFD_HCC170 0.469
CFD_HCC173 0.525
CFD_HCC176 0.982
CFD_HCC186 0.865
CFD_HCC188 0.77
CFD_HCC189 0.934
CFD_HCC51 0.256
CFD_HCC52 0.256
CFD_HCC159 0.467
CFD_HCC47_gCancer 0.679
CFD_DIABETES_CHF 0.043
CFD_CHF_gCopdCF 0.154
CFD_HCC85_gRenal_V24 0.461
CFD_gCopdCF_CARD_RESP_FAIL 0.455
CFD_HCC85_HCC96 0.361
CFD_gSubstanceUseDisorder_gPsych 0.191
CFD_D5 0.055
CFD_D6 0.167
CFD_D7 0.269
CFD_D8 0.424
CFD_D9 0.549
CFD_D10P 1.056
CPA_F65_69 0.359
CPA_F70_74 0.406
CPA_F75_79 0.476
CPA_F80_84 0.55
CPA_F85_89 0.653
CPA_F90_94 0.783
CPA_F95_GT 0.873
CPA_M65_69 0.37
CPA_M70_74 0.427
CPA_M75_79 0.5
CPA_M80_84 0.544
CPA_M85_89 0.659
CPA_M90_94 0.834
CPA_M95_GT 1.047
CPA_OriginallyDisabled_Female 0.136
CPA_OriginallyDisabled_Male 0.083
CPA_HCC1 0.482
CPA_HCC2 0.316
CPA_HCC6 0.318
CPA_HCC8 2.455
CPA_HCC9 1.001
CPA_HCC10 0.648
CPA_HCC11 0.33
CPA_HCC12 0.154
CPA_HCC17 0.326
CPA_HCC18 0.326
CPA_HCC19 0.087
CPA_HCC21 0.457
CPA_HCC22 0.233
CPA_HCC23 0.174
CPA_HCC27 0.729
CPA_HCC28 0.403
CPA_HCC29 0.181
CPA_HCC33 0.232
CPA_HCC34 0.371
CPA_HCC35 0.275
CPA_HCC39 0.443
CPA_HCC40 0.347
CPA_HCC46 1.234
CPA_HCC47 0.674
CPA_HCC48 0.186
CPA_HCC54 0.372
CPA_HCC55 0.372
CPA_HCC56 0.372
CPA_HCC57 0.495
CPA_HCC58 0.449
CPA_HCC59 0.306
CPA_HCC60 0.255
CPA_HCC70 1
CPA_HCC71 1
CPA_HCC72 0.512
CPA_HCC73 0.687
CPA_HCC74 0.114
CPA_HCC75 0.287
CPA_HCC76 0
CPA_HCC77 0.276
CPA_HCC78 0.536
CPA_HCC79 0.257
CPA_HCC80 0.729
CPA_HCC82 0.836
CPA_HCC83 0.361
CPA_HCC84 0.361
CPA_HCC85 0.336
CPA_HCC86 0.293
CPA_HCC87 0.276
CPA_HCC88 0.149
CPA_HCC96 0.264
CPA_HCC99 0.23
CPA_HCC100 0.23
CPA_HCC103 0.438
CPA_HCC104 0.3
CPA_HCC106 1.504
CPA_HCC107 0.463
CPA_HCC108 0.297
CPA_HCC110 0.392
CPA_HCC111 0.358
CPA_HCC112 0.2
CPA_HCC114 0.514
CPA_HCC115 0.093
CPA_HCC122 0.182
CPA_HCC124 0.393
CPA_HCC134 0.446
CPA_HCC135 0.446
CPA_HCC136 0.28
CPA_HCC137 0.28
CPA_HCC138 0.043
CPA_HCC157 2.028
CPA_HCC158 1.162
CPA_HCC161 0.541
CPA_HCC162 0
CPA_HCC166 0.729
CPA_HCC167 0.034
CPA_HCC169 0.512
CPA_HCC170 0.354
CPA_HCC173 0.176
CPA_HCC176 0.52
CPA_HCC186 0.438
CPA_HCC188 0.52
CPA_HCC189 0.697
CPA_HCC51 0.42
CPA_HCC52 0.42
CPA_HCC159 0.649
CPA_HCC47_gCancer 0.656
CPA_DIABETES_CHF 0.113
CPA_CHF_gCopdCF 0.158
CPA_HCC85_gRenal_V24 0.186
CPA_gCopdCF_CARD_RESP_FAIL 0.392
CPA_HCC85_HCC96 0.101
CPA_D5 0.037
CPA_D6 0.071
CPA_D7 0.08
CPA_D8 0.125
CPA_D9 0.402
CPA_D10P 0.548
CPD_F0_34 0.383
CPD_F35_44 0.414
CPD_F45_54 0.418
CPD_F55_59 0.414
CPD_F60_64 0.412
CPD_M0_34 0.389
CPD_M35_44 0.282
CPD_M45_54 0.313
CPD_M55_59 0.34
CPD_M60_64 0.373
CPD_HCC1 0.2
CPD_HCC2 0.297
CPD_HCC6 0.658
CPD_HCC8 2.659
CPD_HCC9 0.88
CPD_HCC10 0.667
CPD_HCC11 0.351
CPD_HCC12 0.181
CPD_HCC17 0.373
CPD_HCC18 0.373
CPD_HCC19 0.122
CPD_HCC21 0.679
CPD_HCC22 0.204
CPD_HCC23 0.319
CPD_HCC27 0.887
CPD_HCC28 0.341
CPD_HCC29 0.238
CPD_HCC33 0.552
CPD_HCC34 0.597
CPD_HCC35 0.543
CPD_HCC39 0.435
CPD_HCC40 0.264
CPD_HCC46 4.138
CPD_HCC47 0.594
CPD_HCC48 0.33
CPD_HCC54 0.679
CPD_HCC55 0.275
CPD_HCC56 0.275
CPD_HCC57 0.309
CPD_HCC58 0.239
CPD_HCC59 0.109
CPD_HCC60 0.065
CPD_HCC70 1.134
CPD_HCC71 0.933
CPD_HCC72 0.336
CPD_HCC73 0.933
CPD_HCC74 0
CPD_HCC75 0.314
CPD_HCC76 0.286
CPD_HCC77 0.46
CPD_HCC78 0.43
CPD_HCC79 0.169
CPD_HCC80 0.134
CPD_HCC82 0.769
CPD_HCC83 0.769
CPD_HCC84 0.343
CPD_HCC85 0.422
CPD_HCC86 0.379
CPD_HCC87 0.379
CPD_HCC88 0.149
CPD_HCC96 0.281
CPD_HCC99 0.163
CPD_HCC100 0.163
CPD_HCC103 0.31
CPD_HCC104 0.164
CPD_HCC106 1.525
CPD_HCC107 0.45
CPD_HCC108 0.314
CPD_HCC110 3.051
CPD_HCC111 0.267
CPD_HCC112 0.229
CPD_HCC114 0.198
CPD_HCC115 0.082
CPD_HCC122 0.201
CPD_HCC124 0.158
CPD_HCC134 0.48
CPD_HCC135 0.48
CPD_HCC136 0.261
CPD_HCC137 0.039
CPD_HCC138 0
CPD_HCC157 2.512
CPD_HCC158 0.925
CPD_HCC161 0.542
CPD_HCC162 0.324
CPD_HCC166 0.134
CPD_HCC167 0.019
CPD_HCC169 0.336
CPD_HCC170 0.333
CPD_HCC173 0.18
CPD_HCC176 0.832
CPD_HCC186 0.613
CPD_HCC188 0.732
CPD_HCC189 0.626
CPD_HCC51 0.257
CPD_HCC52 0.257
CPD_HCC159 0.824
CPD_HCC47_gCancer 0.601
CPD_DIABETES_CHF 0
CPD_CHF_gCopdCF 0.141
CPD_HCC85_gRenal_V24 0.382
CPD_gCopdCF_CARD_RESP_FAIL 0.479
CPD_HCC85_HCC96 0.303
CPD_gSubstanceUseDisorder_gPsych 0.201
CPD_D5 0.083
CPD_D6 0.117
CPD_D7 0.291
CPD_D8 0.452
CPD_D9 0.499
CPD_D10P 0.893
CND_F0_34 0.241
CND_F35_44 0.315
CND_F45_54 0.348
CND_F55_59 0.379
CND_F60_64 0.428
CND_M0_34 0.156
CND_M35_44 0.199
CND_M45_54 0.241
CND_M55_59 0.287
CND_M60_64 0.33
CND_HCC1 0.287
CND_HCC2 0.414
CND_HCC6 0.74
CND_HCC8 2.714
CND_HCC9 0.91
CND_HCC10 0.663
CND_HCC11 0.345
CND_HCC12 0.212
CND_HCC17 0.351
CND_HCC18 0.351
CND_HCC19 0.124
CND_HCC21 0.674
CND_HCC22 0.183
CND_HCC23 0.378
CND_HCC27 1.065
CND_HCC28 0.334
CND_HCC29 0.314
CND_HCC33 0.503
CND_HCC34 0.58
CND_HCC35 0.523
CND_HCC39 0.378
CND_HCC40 0.367
CND_HCC46 3.566
CND_HCC47 0.86
CND_HCC48 0.312
CND_HCC54 0.543
CND_HCC55 0.279
CND_HCC56 0.247
CND_HCC57 0.352
CND_HCC58 0.352
CND_HCC59 0.164
CND_HCC60 0.108
CND_HCC70 1.001
CND_HCC71 0.739
CND_HCC72 0.369
CND_HCC73 1.132
CND_HCC74 0.098
CND_HCC75 0.481
CND_HCC76 0.621
CND_HCC77 0.566
CND_HCC78 0.501
CND_HCC79 0.196
CND_HCC80 0.274
CND_HCC82 0.781
CND_HCC83 0.4
CND_HCC84 0.385
CND_HCC85 0.447
CND_HCC86 0.264
CND_HCC87 0.264
CND_HCC88 0.111
CND_HCC96 0.262
CND_HCC99 0.17
CND_HCC100 0.146
CND_HCC103 0.281
CND_HCC104 0.27
CND_HCC106 1.521
CND_HCC107 0.464
CND_HCC108 0.301
CND_HCC110 2.676
CND_HCC111 0.246
CND_HCC112 0.237
CND_HCC114 0.236
CND_HCC115 0
CND_HCC122 0.231
CND_HCC124 0.314
CND_HCC134 0.406
CND_HCC135 0.406
CND_HCC136 0.231
CND_HCC137 0.105
CND_HCC138 0.021
CND_HCC157 2.097
CND_HCC158 1.212
CND_HCC161 0.592
CND_HCC162 0.506
CND_HCC166 0.274
CND_HCC167 0
CND_HCC169 0.369
CND_HCC170 0.394
CND_HCC173 0.172
CND_HCC176 0.911
CND_HCC186 0.445
CND_HCC188 0.755
CND_HCC189 0.437
CND_HCC51 0.224
CND_HCC52 0.224
CND_HCC159 0.628
CND_HCC47_gCancer 0.46
CND_DIABETES_CHF 0.024
CND_CHF_gCopdCF 0.121
CND_HCC85_gRenal_V24 0.411
CND_gCopdCF_CARD_RESP_FAIL 0.379
CND_HCC85_HCC96 0.282
CND_gSubstanceUseDisorder_gPsych 0.138
CND_D5 0.043
CND_D6 0.131
CND_D7 0.201
CND_D8 0.441
CND_D9 0.441
CND_D10P 0.897
INS_F0_34 0.902
INS_F35_44 1.105
INS_F45_54 1.043
INS_F55_59 1.065
INS_F60_64 1.067
INS_F65_69 1.245
INS_F70_74 1.15
INS_F75_79 1.014
INS_F80_84 0.882
INS_F85_89 0.798
INS_F90_94 0.668
INS_F95_GT 0.501
INS_M0_34 1.101
INS_M35_44 1.002
INS_M45_54 0.965
INS_M55_59 1.017
INS_M60_64 1.061
INS_M65_69 1.288
INS_M70_74 1.329
INS_M75_79 1.317
INS_M80_84 1.207
INS_M85_89 1.122
INS_M90_94 0.989
INS_M95_GT 0.821
INS_LTIMCAID 0.061
INS_ORIGDS 0
INS_DISABLED_HCC85 0.279
INS_DISABLED_PRESSURE_ULCER 0.544
INS_DISABLED_HCC161 0.473
INS_DISABLED_HCC39 0.456
INS_DISABLED_HCC77 0.496
INS_DISABLED_HCC6 0.405
INS_CHF_gCopdCF 0.191
INS_gCopdCF_CARD_RESP_FAIL 0.414
INS_SEPSIS_PRESSURE_ULCER 0.155
INS_SEPSIS_ARTIF_OPENINGS 0.474
INS_ART_OPENINGS_PRESS_ULCER 0.359
INS_DIABETES_CHF 0.169
INS_gCopdCF_ASP_SPEC_B_PNEUM 0.216
INS_ASP_SPEC_B_PNEUM_PRES_ULC 0.472
INS_SEPSIS_ASP_SPEC_BACT_PNEUM 0.346
INS_SCHIZOPHRENIA_gCopdCF 0.417
INS_SCHIZOPHRENIA_CHF 0.127
INS_SCHIZOPHRENIA_SEIZURES 0.573
INS_HCC1 1.722
INS_HCC2 0.324
INS_HCC6 0.534
INS_HCC8 1.303
INS_HCC9 0.623
INS_HCC10 0.461
INS_HCC11 0.294
INS_HCC12 0.21
INS_HCC17 0.44
INS_HCC18 0.44
INS_HCC19 0.178
INS_HCC21 0.267
INS_HCC22 0.455
INS_HCC23 0.379
INS_HCC27 0.874
INS_HCC28 0.485
INS_HCC29 0.485
INS_HCC33 0.352
INS_HCC34 0.422
INS_HCC35 0.355
INS_HCC39 0.401
INS_HCC40 0.292
INS_HCC46 0.799
INS_HCC47 0.576
INS_HCC48 0.19
INS_HCC54 0.178
INS_HCC55 0.178
INS_HCC56 0.178
INS_HCC57 0.187
INS_HCC58 0.187
INS_HCC59 0.187
INS_HCC60 0
INS_HCC70 0.549
INS_HCC71 0.492
INS_HCC72 0.289
INS_HCC73 0.476
INS_HCC74 0
INS_HCC75 0.332
INS_HCC76 0.356
INS_HCC77 0
INS_HCC78 0.159
INS_HCC79 0.065
INS_HCC80 0
INS_HCC82 1.622
INS_HCC83 0.511
INS_HCC84 0.313
INS_HCC85 0.203
INS_HCC86 0.366
INS_HCC87 0.366
INS_HCC88 0.366
INS_HCC96 0.252
INS_HCC99 0.111
INS_HCC100 0.111
INS_HCC103 0
INS_HCC104 0
INS_HCC106 0.867
INS_HCC107 0.299
INS_HCC108 0.093
INS_HCC110 0.593
INS_HCC111 0.311
INS_HCC112 0.11
INS_HCC114 0.156
INS_HCC115 0.156
INS_HCC122 0.394
INS_HCC124 0.217
INS_HCC134 0.468
INS_HCC135 0.468
INS_HCC136 0.245
INS_HCC137 0.201
INS_HCC138 0.092
INS_HCC157 0.854
INS_HCC158 0.322
INS_HCC161 0.294
INS_HCC162 0
INS_HCC166 0
INS_HCC167 0
INS_HCC169 0.25
INS_HCC170 0
INS_HCC173 0.092
INS_HCC176 0.469
INS_HCC186 1.046
INS_HCC188 0.514
INS_HCC189 0.357
INS_HCC51 0
INS_HCC52 0
INS_HCC159 0.322
NE_NMCAID_NORIGDIS_NEF0_34 0.804
NE_NMCAID_NORIGDIS_NEF35_44 0.947
NE_NMCAID_NORIGDIS_NEF45_54 1.016
NE_NMCAID_NORIGDIS_NEF55_59 1.017
NE_NMCAID_NORIGDIS_NEF60_64 1.122
NE_NMCAID_NORIGDIS_NEF65 0.52
NE_NMCAID_NORIGDIS_NEF66 0.515
NE_NMCAID_NORIGDIS_NEF67 0.544
NE_NMCAID_NORIGDIS_NEF68 0.598
NE_NMCAID_NORIGDIS_NEF69 0.6
NE_NMCAID_NORIGDIS_NEF70_74 0.69
NE_NMCAID_NORIGDIS_NEF75_79 0.86
NE_NMCAID_NORIGDIS_NEF80_84 1.014
NE_NMCAID_NORIGDIS_NEF85_89 1.293
NE_NMCAID_NORIGDIS_NEF90_94 1.293
NE_NMCAID_NORIGDIS_NEF95_GT 1.293
NE_NMCAID_NORIGDIS_NEM0_34 0.442
NE_NMCAID_NORIGDIS_NEM35_44 0.657
NE_NMCAID_NORIGDIS_NEM45_54 0.864
NE_NMCAID_NORIGDIS_NEM55_59 0.904
NE_NMCAID_NORIGDIS_NEM60_64 0.921
NE_NMCAID_NORIGDIS_NEM65 0.518
NE_NMCAID_NORIGDIS_NEM66 0.533
NE_NMCAID_NORIGDIS_NEM67 0.582
NE_NMCAID_NORIGDIS_NEM68 0.626
NE_NMCAID_NORIGDIS_NEM69 0.69
NE_NMCAID_NORIGDIS_NEM70_74 0.786
NE_NMCAID_NORIGDIS_NEM75_79 1.06
NE_NMCAID_NORIGDIS_NEM80_84 1.247
NE_NMCAID_NORIGDIS_NEM85_89 1.498
NE_NMCAID_NORIGDIS_NEM90_94 1.498
NE_NMCAID_NORIGDIS_NEM95_GT 1.498
NE_MCAID_NORIGDIS_NEF0_34 0.969
NE_MCAID_NORIGDIS_NEF35_44 1.202
NE_MCAID_NORIGDIS_NEF45_54 1.306
NE_MCAID_NORIGDIS_NEF55_59 1.307
NE_MCAID_NORIGDIS_NEF60_64 1.408
NE_MCAID_NORIGDIS_NEF65 0.993
NE_MCAID_NORIGDIS_NEF66 0.897
NE_MCAID_NORIGDIS_NEF67 0.92
NE_MCAID_NORIGDIS_NEF68 0.951
NE_MCAID_NORIGDIS_NEF69 0.951
NE_MCAID_NORIGDIS_NEF70_74 0.985
NE_MCAID_NORIGDIS_NEF75_79 1.134
NE_MCAID_NORIGDIS_NEF80_84 1.353
NE_MCAID_NORIGDIS_NEF85_89 1.536
NE_MCAID_NORIGDIS_NEF90_94 1.701
NE_MCAID_NORIGDIS_NEF95_GT 1.701
NE_MCAID_NORIGDIS_NEM0_34 0.734
NE_MCAID_NORIGDIS_NEM35_44 1.059
NE_MCAID_NORIGDIS_NEM45_54 1.353
NE_MCAID_NORIGDIS_NEM55_59 1.418
NE_MCAID_NORIGDIS_NEM60_64 1.551
NE_MCAID_NORIGDIS_NEM65 1.144
NE_MCAID_NORIGDIS_NEM66 1.094
NE_MCAID_NORIGDIS_NEM67 1.151
NE_MCAID_NORIGDIS_NEM68 1.202
NE_MCAID_NORIGDIS_NEM69 1.202
NE_MCAID_NORIGDIS_NEM70_74 1.298
NE_MCAID_NORIGDIS_NEM75_79 1.407
NE_MCAID_NORIGDIS_NEM80_84 1.555
NE_MCAID_NORIGDIS_NEM85_89 1.777
NE_MCAID_NORIGDIS_NEM90_94 1.777
NE_MCAID_NORIGDIS_NEM95_GT 1.777
NE_NMCAID_ORIGDIS_NEF65 1.122
NE_NMCAID_ORIGDIS_NEF66 1.174
NE_NMCAID_ORIGDIS_NEF67 1.174
NE_NMCAID_ORIGDIS_NEF68 1.174
NE_NMCAID_ORIGDIS_NEF69 1.174
NE_NMCAID_ORIGDIS_NEF70_74 1.174
NE_NMCAID_ORIGDIS_NEF75_79 1.174
NE_NMCAID_ORIGDIS_NEF80_84 1.174
NE_NMCAID_ORIGDIS_NEF85_89 1.293
NE_NMCAID_ORIGDIS_NEF90_94 1.293
NE_NMCAID_ORIGDIS_NEF95_GT 1.293
NE_NMCAID_ORIGDIS_NEM65 0.921
NE_NMCAID_ORIGDIS_NEM66 1.071
NE_NMCAID_ORIGDIS_NEM67 1.123
NE_NMCAID_ORIGDIS_NEM68 1.123
NE_NMCAID_ORIGDIS_NEM69 1.32
NE_NMCAID_ORIGDIS_NEM70_74 1.408
NE_NMCAID_ORIGDIS_NEM75_79 1.408
NE_NMCAID_ORIGDIS_NEM80_84 1.408
NE_NMCAID_ORIGDIS_NEM85_89 1.498
NE_NMCAID_ORIGDIS_NEM90_94 1.498
NE_NMCAID_ORIGDIS_NEM95_GT 1.498
NE_MCAID_ORIGDIS_NEF65 1.462
NE_MCAID_ORIGDIS_NEF66 1.887
NE_MCAID_ORIGDIS_NEF67 1.887
NE_MCAID_ORIGDIS_NEF68 1.887
NE_MCAID_ORIGDIS_NEF69 1.887
NE_MCAID_ORIGDIS_NEF70_74 1.887
NE_MCAID_ORIGDIS_NEF75_79 1.887
NE_MCAID_ORIGDIS_NEF80_84 1.887
NE_MCAID_ORIGDIS_NEF85_89 1.887
NE_MCAID_ORIGDIS_NEF90_94 1.887
NE_MCAID_ORIGDIS_NEF95_GT 1.887
NE_MCAID_ORIGDIS_NEM65 1.811
NE_MCAID_ORIGDIS_NEM66 2.199
NE_MCAID_ORIGDIS_NEM67 2.199
NE_MCAID_ORIGDIS_NEM68 2.199
NE_MCAID_ORIGDIS_NEM69 2.199
NE_MCAID_ORIGDIS_NEM70_74 2.199
NE_MCAID_ORIGDIS_NEM75_79 2.199
NE_MCAID_ORIGDIS_NEM80_84 2.199
NE_MCAID_ORIGDIS_NEM85_89 2.199
NE_MCAID_ORIGDIS_NEM90_94 2.199
NE_MCAID_ORIGDIS_NEM95_GT 2.199
CFA_D1 0
CFA_D2 0
CFA_D3 0
CFA_D4 0
CFA_D5 0
CPA_D1 0
CPA_D2 0
CPA_D3 0
CPA_D4 0
CFD_D1 0
CFD_D2 0
CFD_D3 0
CFD_D4 0
CND_D1 0
CND_D2 0
CND_D3 0
CND_D4 0
CPD_D1 0
CPD_D2 0
CPD_D3 0
CPD_D4 0
CNA_F65_69 0.323
CNA_F70_74 0.386
CNA_F75_79 0.451
CNA_F80_84 0.528
CNA_F85_89 0.641
CNA_F90_94 0.783
CNA_F95_GT 0.787
CNA_M65_69 0.308
CNA_M70_74 0.394
CNA_M75_79 0.473
CNA_M80_84 0.556
CNA_M85_89 0.686
CNA_M90_94 0.841
CNA_M95_GT 0.986
CNA_OriginallyDisabled_Female 0.25
CNA_OriginallyDisabled_Male 0.147
CNA_HCC1 0.335
CNA_HCC2 0.352
CNA_HCC6 0.424
CNA_HCC8 2.659
CNA_HCC9 1.024
CNA_HCC10 0.675
CNA_HCC11 0.307
CNA_HCC12 0.15
CNA_HCC17 0.302
CNA_HCC18 0.302
CNA_HCC19 0.105
CNA_HCC21 0.455
CNA_HCC22 0.25
CNA_HCC23 0.194
CNA_HCC27 0.882
CNA_HCC28 0.363
CNA_HCC29 0.147
CNA_HCC33 0.219
CNA_HCC34 0.287
CNA_HCC35 0.308
CNA_HCC39 0.401
CNA_HCC40 0.421
CNA_HCC46 1.372
CNA_HCC47 0.665
CNA_HCC48 0.192
CNA_HCC54 0.329
CNA_HCC55 0.329
CNA_HCC56 0.329
CNA_HCC57 0.524
CNA_HCC58 0.393
CNA_HCC59 0.309
CNA_HCC60 0.309
CNA_HCC70 1.242
CNA_HCC71 1.068
CNA_HCC72 0.481
CNA_HCC73 0.999
CNA_HCC74 0.339
CNA_HCC75 0.472
CNA_HCC76 0.518
CNA_HCC77 0.423
CNA_HCC78 0.606
CNA_HCC79 0.22
CNA_HCC80 0.486
CNA_HCC82 1
CNA_HCC83 0.354
CNA_HCC84 0.282
CNA_HCC85 0.331
CNA_HCC86 0.195
CNA_HCC87 0.195
CNA_HCC88 0.135
CNA_HCC96 0.268
CNA_HCC99 0.23
CNA_HCC100 0.23
CNA_HCC103 0.437
CNA_HCC104 0.331
CNA_HCC106 1.488
CNA_HCC107 0.383
CNA_HCC108 0.288
CNA_HCC110 0.51
CNA_HCC111 0.335
CNA_HCC112 0.219
CNA_HCC114 0.517
CNA_HCC115 0.13
CNA_HCC122 0.222
CNA_HCC124 0.521
CNA_HCC134 0.435
CNA_HCC135 0.435
CNA_HCC136 0.289
CNA_HCC137 0.289
CNA_HCC138 0.069
CNA_HCC157 2.028
CNA_HCC158 1.069
CNA_HCC161 0.515
CNA_HCC162 0.224
CNA_HCC166 0.486
CNA_HCC167 0.077
CNA_HCC169 0.476
CNA_HCC170 0.35
CNA_HCC173 0.208
CNA_HCC176 0.582
CNA_HCC186 0.832
CNA_HCC188 0.534
CNA_HCC189 0.519
CNA_HCC51 0.346
CNA_HCC52 0.346
CNA_HCC159 0.656
CNA_HCC47_gCancer 0.838
CNA_DIABETES_CHF 0.121
CNA_CHF_gCopdCF 0.155
CNA_HCC85_gRenal_V24 0.156
CNA_gCopdCF_CARD_RESP_FAIL 0.363
CNA_HCC85_HCC96 0.085
CNA_D4 0.006
CNA_D5 0.042
CNA_D6 0.077
CNA_D7 0.126
CNA_D8 0.214
CNA_D9 0.258
CNA_D10P 0.505
CNA_D1 0
CNA_D2 0
CNA_D3 0
SNPNE_NMCAID_NORIGDIS_NEF0_34 1.513
SNPNE_NMCAID_NORIGDIS_NEF35_44 1.513
SNPNE_NMCAID_NORIGDIS_NEF45_54 1.513
SNPNE_NMCAID_NORIGDIS_NEF55_59 1.619
SNPNE_NMCAID_NORIGDIS_NEF60_64 1.686
SNPNE_NMCAID_NORIGDIS_NEF65 0.999
SNPNE_NMCAID_NORIGDIS_NEF66 0.999
SNPNE_NMCAID_NORIGDIS_NEF67 1.07
SNPNE_NMCAID_NORIGDIS_NEF68 1.108
SNPNE_NMCAID_NORIGDIS_NEF69 1.164
SNPNE_NMCAID_NORIGDIS_NEF70_74 1.31
SNPNE_NMCAID_NORIGDIS_NEF75_79 1.516
SNPNE_NMCAID_NORIGDIS_NEF80_84 1.746
SNPNE_NMCAID_NORIGDIS_NEF85_89 1.971
SNPNE_NMCAID_NORIGDIS_NEF90_94 2.161
SNPNE_NMCAID_NORIGDIS_NEF95_GT 2.161
SNPNE_NMCAID_NORIGDIS_NEM0_34 1.276
SNPNE_NMCAID_NORIGDIS_NEM35_44 1.276
SNPNE_NMCAID_NORIGDIS_NEM45_54 1.498
SNPNE_NMCAID_NORIGDIS_NEM55_59 1.63
SNPNE_NMCAID_NORIGDIS_NEM60_64 1.673
SNPNE_NMCAID_NORIGDIS_NEM65 0.98
SNPNE_NMCAID_NORIGDIS_NEM66 0.98
SNPNE_NMCAID_NORIGDIS_NEM67 1.02
SNPNE_NMCAID_NORIGDIS_NEM68 1.082
SNPNE_NMCAID_NORIGDIS_NEM69 1.14
SNPNE_NMCAID_NORIGDIS_NEM70_74 1.345
SNPNE_NMCAID_NORIGDIS_NEM75_79 1.581
SNPNE_NMCAID_NORIGDIS_NEM80_84 1.832
SNPNE_NMCAID_NORIGDIS_NEM85_89 2.095
SNPNE_NMCAID_NORIGDIS_NEM90_94 2.351
SNPNE_NMCAID_NORIGDIS_NEM95_GT 2.351
SNPNE_MCAID_NORIGDIS_NEF0_34 1.776
SNPNE_MCAID_NORIGDIS_NEF35_44 1.776
SNPNE_MCAID_NORIGDIS_NEF45_54 2.01
SNPNE_MCAID_NORIGDIS_NEF55_59 2.095
SNPNE_MCAID_NORIGDIS_NEF60_64 2.126
SNPNE_MCAID_NORIGDIS_NEF65 1.375
SNPNE_MCAID_NORIGDIS_NEF66 1.375
SNPNE_MCAID_NORIGDIS_NEF67 1.483
SNPNE_MCAID_NORIGDIS_NEF68 1.559
SNPNE_MCAID_NORIGDIS_NEF69 1.576
SNPNE_MCAID_NORIGDIS_NEF70_74 1.789
SNPNE_MCAID_NORIGDIS_NEF75_79 1.98
SNPNE_MCAID_NORIGDIS_NEF80_84 2.194
SNPNE_MCAID_NORIGDIS_NEF85_89 2.49
SNPNE_MCAID_NORIGDIS_NEF90_94 2.68
SNPNE_MCAID_NORIGDIS_NEF95_GT 2.68
SNPNE_MCAID_NORIGDIS_NEM0_34 1.533
SNPNE_MCAID_NORIGDIS_NEM35_44 1.533
SNPNE_MCAID_NORIGDIS_NEM45_54 1.854
SNPNE_MCAID_NORIGDIS_NEM55_59 2.041
SNPNE_MCAID_NORIGDIS_NEM60_64 2.167
SNPNE_MCAID_NORIGDIS_NEM65 1.525
SNPNE_MCAID_NORIGDIS_NEM66 1.525
SNPNE_MCAID_NORIGDIS_NEM67 1.646
SNPNE_MCAID_NORIGDIS_NEM68 1.646
SNPNE_MCAID_NORIGDIS_NEM69 1.646
SNPNE_MCAID_NORIGDIS_NEM70_74 1.967
SNPNE_MCAID_NORIGDIS_NEM75_79 2.14
SNPNE_MCAID_NORIGDIS_NEM80_84 2.272
SNPNE_MCAID_NORIGDIS_NEM85_89 2.63
SNPNE_MCAID_NORIGDIS_NEM90_94 2.63
SNPNE_MCAID_NORIGDIS_NEM95_GT 2.63
SNPNE_NMCAID_ORIGDIS_NEF65 1.81
SNPNE_NMCAID_ORIGDIS_NEF66 1.81
SNPNE_NMCAID_ORIGDIS_NEF67 1.834
SNPNE_NMCAID_ORIGDIS_NEF68 1.834
SNPNE_NMCAID_ORIGDIS_NEF69 1.834
SNPNE_NMCAID_ORIGDIS_NEF70_74 2.006
SNPNE_NMCAID_ORIGDIS_NEF75_79 2.112
SNPNE_NMCAID_ORIGDIS_NEF80_84 2.476
SNPNE_NMCAID_ORIGDIS_NEF85_89 2.476
SNPNE_NMCAID_ORIGDIS_NEF90_94 2.476
SNPNE_NMCAID_ORIGDIS_NEF95_GT 2.476
SNPNE_NMCAID_ORIGDIS_NEM65 1.664
SNPNE_NMCAID_ORIGDIS_NEM66 1.667
SNPNE_NMCAID_ORIGDIS_NEM67 1.725
SNPNE_NMCAID_ORIGDIS_NEM68 1.74
SNPNE_NMCAID_ORIGDIS_NEM69 1.797
SNPNE_NMCAID_ORIGDIS_NEM70_74 1.935
SNPNE_NMCAID_ORIGDIS_NEM75_79 2.073
SNPNE_NMCAID_ORIGDIS_NEM80_84 2.349
SNPNE_NMCAID_ORIGDIS_NEM85_89 2.349
SNPNE_NMCAID_ORIGDIS_NEM90_94 2.349
SNPNE_NMCAID_ORIGDIS_NEM95_GT 2.349
SNPNE_MCAID_ORIGDIS_NEF65 2.183
SNPNE_MCAID_ORIGDIS_NEF66 2.209
SNPNE_MCAID_ORIGDIS_NEF67 2.213
SNPNE_MCAID_ORIGDIS_NEF68 2.248
SNPNE_MCAID_ORIGDIS_NEF69 2.336
SNPNE_MCAID_ORIGDIS_NEF70_74 2.424
SNPNE_MCAID_ORIGDIS_NEF75_79 2.562
SNPNE_MCAID_ORIGDIS_NEF80_84 2.772
SNPNE_MCAID_ORIGDIS_NEF85_89 2.772
SNPNE_MCAID_ORIGDIS_NEF90_94 2.772
SNPNE_MCAID_ORIGDIS_NEF95_GT 2.772
SNPNE_MCAID_ORIGDIS_NEM65 2.173
SNPNE_MCAID_ORIGDIS_NEM66 2.173
SNPNE_MCAID_ORIGDIS_NEM67 2.179
SNPNE_MCAID_ORIGDIS_NEM68 2.179
SNPNE_MCAID_ORIGDIS_NEM69 2.179
SNPNE_MCAID_ORIGDIS_NEM70_74 2.419
SNPNE_MCAID_ORIGDIS_NEM75_79 2.509
SNPNE_MCAID_ORIGDIS_NEM80_84 2.805
SNPNE_MCAID_ORIGDIS_NEM85_89 2.805
SNPNE_MCAID_ORIGDIS_NEM90_94 2.805
SNPNE_MCAID_ORIGDIS_NEM95_GT 2.805

Writing functions over the same variable in a list of data frames in R

I am working with some baseball data and am trying to figure out how to write functions that operate on all columns in a list of like data frames. So for instance, I have on base percentage for a team for each game played, what I want to do is run shift(cumsum(teamname$OBP)) for each data frame in the list in order to find the cumulative sum of their OBP for the season, and then shift the data so each row will contain the previous days cumulative sum. Is there a way to do this specifically with an apply function so that it runs the same function over all the data frames?
Below are some of the variables that I'm looking to apply this over:
> head(teams$SEA[27:34])
# A tibble: 6 x 8
RA OBP SLG wOBA wOPS RC PE BBSOr
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 7 0.375 0.452 0.326 0.777 6.20 0.623 0.6
2 4 0.314 0.442 0.298 0.740 7.29 0.610 0.556
3 4 0.419 0.861 0.478 1.34 13.8 0.9 0.444
4 7 0.3 0.559 0.350 0.908 6.48 0.424 0.4
5 5 0.368 0.441 0.354 0.795 6.74 0.590 0.4
6 8 0.422 0.568 0.418 0.985 10.1 0.610 0.636
My list looks like this.
> summary(teams)
Length Class Mode
SEA 34 spec_tbl_df list
PIT 34 spec_tbl_df list
ARI 34 spec_tbl_df list
COL 34 spec_tbl_df list
SLN 34 spec_tbl_df list
Sample Data
I gave the Pirates a lower OBP to show the function runs over the data frames separately, and also because they seemed the most likely candidate of the five non-SEA teams to have such a poor OBP :)
On future questions, please add sample data that others can easily paste into R. dput() is a useful function for doing so.
library(data.table)
SEA <- read.table(text = " RA OBP SLG wOBA wOPS RC PE BBSOr
7 0.375 0.452 0.326 0.777 6.20 0.623 0.6
4 0.314 0.442 0.298 0.740 7.29 0.610 0.556
4 0.419 0.861 0.478 1.34 13.8 0.9 0.444
7 0.3 0.559 0.350 0.908 6.48 0.424 0.4
5 0.368 0.441 0.354 0.795 6.74 0.590 0.4
8 0.422 0.568 0.418 0.985 10.1 0.610 0.636",
head = TRUE,)
PIT <- SEA
PIT$OBP <- PIT$OBP/2
ARI <- SEA
COL <- SEA
SLN <- SEA
teams <- list(SEA = SEA,
PIT = PIT,
ARI = ARI,
COL = COL,
SLN = SLN)
Solution
lapply(teams,
function(x){
x$OBP_cumsum <- shift(cumsum(x$OBP))
x
})
$SEA
RA OBP SLG wOBA wOPS RC PE BBSOr OBP_cumsum
1 7 0.375 0.452 0.326 0.777 6.20 0.623 0.600 NA
2 4 0.314 0.442 0.298 0.740 7.29 0.610 0.556 0.375
3 4 0.419 0.861 0.478 1.340 13.80 0.900 0.444 0.689
4 7 0.300 0.559 0.350 0.908 6.48 0.424 0.400 1.108
5 5 0.368 0.441 0.354 0.795 6.74 0.590 0.400 1.408
6 8 0.422 0.568 0.418 0.985 10.10 0.610 0.636 1.776
$PIT
RA OBP SLG wOBA wOPS RC PE BBSOr OBP_cumsum
1 7 0.1875 0.452 0.326 0.777 6.20 0.623 0.600 NA
2 4 0.1570 0.442 0.298 0.740 7.29 0.610 0.556 0.1875
3 4 0.2095 0.861 0.478 1.340 13.80 0.900 0.444 0.3445
4 7 0.1500 0.559 0.350 0.908 6.48 0.424 0.400 0.5540
5 5 0.1840 0.441 0.354 0.795 6.74 0.590 0.400 0.7040
6 8 0.2110 0.568 0.418 0.985 10.10 0.610 0.636 0.8880
$ARI
RA OBP SLG wOBA wOPS RC PE BBSOr OBP_cumsum
1 7 0.375 0.452 0.326 0.777 6.20 0.623 0.600 NA
2 4 0.314 0.442 0.298 0.740 7.29 0.610 0.556 0.375
3 4 0.419 0.861 0.478 1.340 13.80 0.900 0.444 0.689
4 7 0.300 0.559 0.350 0.908 6.48 0.424 0.400 1.108
5 5 0.368 0.441 0.354 0.795 6.74 0.590 0.400 1.408
6 8 0.422 0.568 0.418 0.985 10.10 0.610 0.636 1.776
$COL
RA OBP SLG wOBA wOPS RC PE BBSOr OBP_cumsum
1 7 0.375 0.452 0.326 0.777 6.20 0.623 0.600 NA
2 4 0.314 0.442 0.298 0.740 7.29 0.610 0.556 0.375
3 4 0.419 0.861 0.478 1.340 13.80 0.900 0.444 0.689
4 7 0.300 0.559 0.350 0.908 6.48 0.424 0.400 1.108
5 5 0.368 0.441 0.354 0.795 6.74 0.590 0.400 1.408
6 8 0.422 0.568 0.418 0.985 10.10 0.610 0.636 1.776
$SLN
RA OBP SLG wOBA wOPS RC PE BBSOr OBP_cumsum
1 7 0.375 0.452 0.326 0.777 6.20 0.623 0.600 NA
2 4 0.314 0.442 0.298 0.740 7.29 0.610 0.556 0.375
3 4 0.419 0.861 0.478 1.340 13.80 0.900 0.444 0.689
4 7 0.300 0.559 0.350 0.908 6.48 0.424 0.400 1.108
5 5 0.368 0.441 0.354 0.795 6.74 0.590 0.400 1.408
6 8 0.422 0.568 0.418 0.985 10.10 0.610 0.636 1.776

Apply a function to n columns and get results in n new columns in R. How?

Let's say I have a dataset with 10 numerical values and I want to normalize (apply any function in fact) each of these columns, so for column A, I´ll want to normalize and get "A normalized" in column ANorm. Same for the rest.
How can I program that in R?
I tried a for loop and lapply, which I think was the right approach but I couldn´t reach a final result.
Any help or direction is much appreciated!
This is perfect for a tidyverse solution
library(tidyverse)
set.seed(123)
matrix(runif(50),ncol=5) %>%
as_tibble() %>%
mutate_at(vars(V1:V5), funs(norm = ./mean(.)))
# A tibble: 10 x 10
V1 V2 V3 V4 V5 V1_norm V2_norm V3_norm V4_norm V5_norm
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 0.288 0.957 0.890 0.963 0.143 0.497 1.83 1.45 1.79 0.413
2 0.788 0.453 0.693 0.902 0.415 1.36 0.866 1.13 1.68 1.20
3 0.409 0.678 0.641 0.691 0.414 0.707 1.29 1.04 1.28 1.20
4 0.883 0.573 0.994 0.795 0.369 1.53 1.09 1.62 1.48 1.07
5 0.940 0.103 0.656 0.0246 0.152 1.63 0.197 1.07 0.0458 0.441
6 0.0456 0.900 0.709 0.478 0.139 0.0788 1.72 1.15 0.888 0.402
7 0.528 0.246 0.544 0.758 0.233 0.913 0.470 0.884 1.41 0.675
8 0.892 0.0421 0.594 0.216 0.466 1.54 0.0804 0.965 0.402 1.35
9 0.551 0.328 0.289 0.318 0.266 0.954 0.627 0.470 0.592 0.770
10 0.457 0.955 0.147 0.232 0.858 0.790 1.82 0.239 0.431 2.48

Plot elements of a matrix with different colours for a specific column

I have the following correlation matrix.
AUS AUT CAN CHE DEU EU15 FRA GBR ITA JPN USA
AUS 1.000 0.058 0.476 0.313 0.111 0.277 0.184 0.296 0.202 0.192 0.267
AUT 0.058 1.000 0.254 0.658 0.749 0.761 0.626 0.387 0.460 0.410 0.278
CAN 0.476 0.254 1.000 0.390 0.321 0.534 0.377 0.538 0.391 0.231 0.746
CHE 0.313 0.658 0.390 1.000 0.604 0.706 0.610 0.310 0.565 0.437 0.305
DEU 0.111 0.749 0.321 0.604 1.000 0.859 0.620 0.387 0.472 0.520 0.369
EU15 0.277 0.761 0.534 0.706 0.859 1.000 0.808 0.682 0.713 0.601 0.531
FRA 0.184 0.626 0.377 0.610 0.620 0.808 1.000 0.467 0.553 0.444 0.357
GBR 0.296 0.387 0.538 0.310 0.387 0.682 0.467 1.000 0.324 0.407 0.591
ITA 0.202 0.460 0.391 0.565 0.472 0.713 0.553 0.324 1.000 0.492 0.315
JPN 0.192 0.410 0.231 0.437 0.520 0.601 0.444 0.407 0.492 1.000 0.321
USA 0.267 0.278 0.746 0.305 0.369 0.531 0.357 0.591 0.315 0.321 1.000
My goal: plot all correlations in ascending order assigning different colours to the correlations of USA.
I have accomplished to plot all the correlations like this:
x[lower.tri(x)] <- NA
diag(x) <- NA
x <- as.vector(gdpcor)
x <- x[!is.na(x)]
x <- x[order(x)]
plot(x)
But I can't figure out how to assign a different colour for USA's correlations. Any ideas?
How about starting with something like:
x <- as.matrix(read.table(text="AUS AUT CAN CHE DEU EU15 FRA GBR ITA JPN USA
AUS 1.000 0.058 0.476 0.313 0.111 0.277 0.184 0.296 0.202 0.192 0.267
AUT 0.058 1.000 0.254 0.658 0.749 0.761 0.626 0.387 0.460 0.410 0.278
CAN 0.476 0.254 1.000 0.390 0.321 0.534 0.377 0.538 0.391 0.231 0.746
CHE 0.313 0.658 0.390 1.000 0.604 0.706 0.610 0.310 0.565 0.437 0.305
DEU 0.111 0.749 0.321 0.604 1.000 0.859 0.620 0.387 0.472 0.520 0.369
EU15 0.277 0.761 0.534 0.706 0.859 1.000 0.808 0.682 0.713 0.601 0.531
FRA 0.184 0.626 0.377 0.610 0.620 0.808 1.000 0.467 0.553 0.444 0.357
GBR 0.296 0.387 0.538 0.310 0.387 0.682 0.467 1.000 0.324 0.407 0.591
ITA 0.202 0.460 0.391 0.565 0.472 0.713 0.553 0.324 1.000 0.492 0.315
JPN 0.192 0.410 0.231 0.437 0.520 0.601 0.444 0.407 0.492 1.000 0.321
USA 0.267 0.278 0.746 0.305 0.369 0.531 0.357 0.591 0.315 0.321 1.000"))
x[lower.tri(x)] <- NA
diag(x) <- NA
df <- subset(as.data.frame(as.table(x), responseName = 'Corr'),!is.na(Corr))
df <- df[order(df$Corr),]
ggplot(df, aes(x=1:nrow(df),y=Corr,col=Var2=='USA')) + geom_point()
side note: In case you haven't tried it, check out library(corrplot) as a good way to visualize correlations. For example:
corrplot(x, is.corr = FALSE, method='square', diag=FALSE)

Resources