[R] Sorting Data?
Martin Klaffenboeck
martin.klaffenboeck at gmx.at
Fri May 28 19:48:55 CEST 2004
Am 28.05.2004 15:18:58 schrieb(en) Jonathan Baron:
> >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 don't think this is a trivial problem at all, so I am hesitant
> to offer advice. I see now that you reall do want a matrix,
> where you have mothers in the columns and daughters in the rows,
> and distance (difference, similarity) measures in the cells.
> Perhaps you have several such measures, so you want a
> three-dimensional array.
Hm. I don't know. I tried the following:
Creating a new Variable by:
Fbg[['F.gesamt']] <- rowSums(Fbg[11:27], na.rm=TRUE)
Which contains everything from F01 to F17 as sum().
Than I do the thing to split mothers from daugthers as you told me.
The next step i get:
dist(Muetter['F.gesamt'] - Toechter['F.gesamt'])
Which gives me some output, where I am not sure what it is. ;-(
But it looks like the thing I want, but I think I don't really have the
right data inside.
> You might do something like this. First define a function to
> measure your distance, like
>
> Itemdist <- function(x,y) {sum(abs(x[-(1:4)]-y[-(1:4)]))}
>
> Dists <- matrix(NA,nrow(Daughters),nrow(Mothers))
>
> for (i in 1:nrow(Daughters)
> {for (j in 1:nrow(Mothers))
> {Dists[i,j] <- Itemdist(Daughters[i,],Mothers[j,])}}
Hm. I get some syntax errors inside this. If you want you can have my
small sample I'm now createing a source file about. There I have 12
mother daugther pairs. I will get about 20 pairs within the next two
months, but then I will have my source file (loading by source("file.
R")) ready. The small sample is just to work now.
Thanks for your help,
Martin
More information about the R-help
mailing list