Re: [R] Sorting Data?

About this list Date view Thread view Subject view Author view Attachment view

From: Martin Klaffenboeck (martin.klaffenboeck@gmx.at)
Date: Fri 28 May 2004 - 20:21:42 EST


Message-id: <20040528102142.GE4117@martin.kleinerdrache.org>

Am 27.05.2004 22:43:02 schrieb(en) Jonathan Baron:
> On 05/27/04 21:58, Martin Klaffenboeck wrote:
> >Hello,
> >
> >Im reading through some manuals, but I cannot find my answer.
> >
> >I have a file containing many data:
> >
> >Vpn Code Family Age F1 F2 ... F17
> >1 1 M 46 1 2 ... 1
> >2 1 D 18 3 2 ... 4
> >3 2 M 50 3 3 ... 3
> >...
> >and so on.
> >
> >Now I can read it by:
> >
> >F = read.table("file", header=T)
> >
> >but now I want to seperate the mothers (M) and daugthers (D) of the
> >family with all the data in all other fields. How can I do that?
> >
> >The 'Code' Tells me which mother belongs to which dougther. I want
> to
> >make a matrix where I have the mothers on one and the daugthers on
> the
> >other axis and compair the distance of every question (F1...F17) and
> >the distance of the sum of this questions. The questions are
> semantic
> >differencials, 5 values. F4, and F7 must have reverse polarity in
> this
> >case.
>
> The following is not tested and probably contains at least one error.

Thanks, that helps me much as I am a R newbie.

> Lets assume that there is one mother per daughter and one
> daughter per mother, and your file is Myfile, and the Codes are
> in order. One way is this:

Ok, we really have only one daughter per mother in our sample.
Im sorting by:

Myfile <- read.table("Fragebogen.data", header=TRUE)
Myfile <- Myfile[order(e[, 'Code'], Myfile[, 'Family']), ]

Code has one equal code for mother and daugther the same - so I know
which mother has which daughter, Family tells me if the person it she
mother or the daugther.

> Myfile$F4 <- -Myfile$F4 # reverse polarity
> Myfile$F7 <- -Myfile$F7

Is this also true, if we have a semantic differential with 5 steps?
(from 1 to five. I have one missing value (NA), should I set it to 0?)
(please tell me also if I use incorrect words).
You didn't know that I assume. So now I'm doing:

Myfile$F3 <- 5-Myfile$F3

that seems to be good for me, please tell me what you think.

> Mothers <- Myfile[Family="M",]
> Daughters <- Myfile[Family="D",]

Hm. This seems not to work for me i was testing arround, for me seems
to work:

Mothers <- Myfile[Myfile[["Family"]]=="M",]
Daugthers <- ...

I hope we have the same results now. ;-) Im really a newbie in R.

> Itemdiffs <- Mothers[,-(1:4)]-Daughters[,-(1:4)] # the -(1:4)
> # removes cols 1:4

Ok, this seems to work, also but I don't really know what I am doing
with it. Also the other things.

I have to test the hypothesis: Does a daugther answer the questions
(semantic differential) more equal the own mother and more different to
the mothers of the other daugthers. I hope you get that in
english. ;-)

Thanks,
Martin

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:13 EST