[R] Coagulation data by Box/Hunter/Hunter

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Aug 20 12:50:11 CEST 2004


On 19-Aug-04 T. Murlidharan Nair wrote:
> Hi!!
> Has anyone used the coagulation data for statistical analysis?
> I managed to get the data from the web but unsure of the way its
> supposed to read. I am new to R so trying to gets myself familiarized
> with the statistical tools using available data. I am appending the
> data I got of the web. If anyone is aware of its use I would welcome
> their input.
> Cheers always!!
> Murli
> 
> =======================================================================
[Original dataset omitted]

Hi Murli,

There are several approaches to getting started with this sort of
situation in R. The approach I usually adopt is generally as follows.

First, copy the original data to a file, say "blood.csv", and then
edit this file to remove all except the line which lists the variables
and the lines of data themselves; then edit these lines to replace
the spaces separating data items on a line with a single comma.
In this way you obtain

Y,X1,RUNSEQ
62,1,20
60,1,2
63,1,11
59,1,10
63,2,12
67,2,9
71,2,15
64,2,14
65,2,4
66,2,8
68,3,16
66,3,7
71,3,1
67,3,17
68,3,13
68,3,21
56,4,23
62,4,3
60,4,6
61,4,18
63,4,22
64,4,19
63,4,5
59,4,24

Then start R, and enter commands like

D <- read.csv("blood.csv")
Y <- D$Y; X1 <- D$X1; RUNSEQ <- D$RUNSEQ

Now R has all the data, both combined into a dataframe D and
also as separate variables. From this point on, you can do
what you like.

Some examples:

  plot(X1,Y)

  ix<-(X1==1);  plot(RUNSEQ[ix],Y[ix],pch=1,xlim=c(0,25),ylim=c(40,80))
  ix<-(X1==2);points(RUNSEQ[ix],Y[ix],pch=2,col="red")
  ix<-(X1==3);points(RUNSEQ[ix],Y[ix],pch=3,col="green")
  ix<-(X1==4);points(RUNSEQ[ix],Y[ix],pch=4,col="blue")

  X1.f <- factor(X1); D.lm <- lm(Y ~ X1.f)
  summary(D.lm)

  plot(RUNSEQ,D.lm$res)

and so on.

Good hunting!
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 20-Aug-04                                       Time: 11:50:11
------------------------------ XFMail ------------------------------




More information about the R-help mailing list