STAT 798S Importing the Kalbfleisch & Prentice Data in R ============================================== 9/2/05 (1) Saved all of the downloaded Excel datasets as space-delimited text, as files DSetI.dat through DSetVI.dat (omitting V, because that was not given in Excel format). (2) In R, > DsetI.fr <- read.table("DSetI.dat", header=T) > DsetII.fr <- read.table("DSetII.dat", header=T) > DsetIII.fr <- data.frame( matrix( scan("DsetIII.dat", skip=1), byrow=T, ncol=3, dimnames=list(NULL, c("InfecTim","IncubTim","Age")))) ### Note: this "scan" instruction just reads the entire ### dataset row-wise; then the "matrix" command forms it ### into a giant matrix with 3 columns and indicated headings. > DsetIV.fr <- read.table("DSetIV.dat", header=T) > DsetVI.fr <- read.table("DSetVI.dat", header=T) > DsetV.fr <- cbind.data.frame(Type=factor(c(rep("Control",99), rep("GFree",82))), Cause=factor(c(rep("Thym.Lym",22), rep("RetCell.Sarc",38), rep("Other",39), rep("Thym.Lym",29), rep("RetCell.Sarc",15), rep("Other",38))), DTime=c(159, 189, 191, 198, 200, 207, 220, 235, 245, 250, 256, 261, 265, 266, 280, 343, 356, 383, 403, 414, 428, 432, 317, 318, 399, 495, 525, 536, 549, 552, 554, 337, 558, 571, 586, 594, 596, 605, 612, 621, 628, 631, 636, 643, 647, 648, 649, 661, 663, 666, 670, 695, 697, 700, 705, 712, 713, 738, 748, 753, 40, 42, 51, 62, 163, 179, 206, 222, 228, 252, 249, 282, 324, 333, 341, 366, 385, 407, 420, 431, 441, 461, 462, 482, 517, 517, 524, 564, 567, 586, 619, 620, 621, 622, 647, 651, 686, 761, 763, 158, 192, 193, 194, 195, 202, 212, 215, 229, 230, 237, 240, 244, 247, 259, 300, 301, 321, 337, 415, 434, 444, 485, 496, 529, 537, 624, 707, 800, 430, 590, 606, 638, 655, 679, 691, 693, 696, 747, 752, 760, 778, 821, 986, 136, 246, 255, 376, 421, 565, 616, 617, 652, 655, 658, 660, 662, 675, 681, 734, 736, 737, 757, 769, 777, 800, 807, 825, 855, 857, 864, 868, 870, 870, 873, 882, 895, 910, 934, 942, 1015, 1019)) > DsetV.fr[1:3,] Type Cause DTime 1 Control Thym.Lym 159 2 Control Thym.Lym 189 3 Control Thym.Lym 191 > write.table(DsetV.fr, "Dset5.txt", row.names=F) #### etc. ### You will probably want to remove the quotes and shorten ### the category names, using an editor with Search/Replace.