[R] I: Problem

Ambrosini Alessandro klavan at tiscalinet.it
Mon Apr 29 20:38:36 CEST 2002

-----Messaggio originale-----
Da: Ambrosini Alessandro [mailto:klavan at tiscalinet.it]
Inviato: lunedì 29 aprile 2002 20.38
A: R-help at lists.R-project.org
Oggetto: Problem

This is the situation.
I have a file in wich there is a scattered matrix. I give an example:

aa bb cc
bb xx
dd cv st rw
xx yu de qw ww zzp

where aa is a node that has a path with aa, one with bb, and one with cc.
bb has a path with xx, dd has a path with cv, one with st, ...
In my experiment I have more or less 100 lines. My nodes are Web pages.
I have another file that gives me a wich nodes are related with the query1

query1 0 aa 1
query1 0 cc 0
query1 0 dd 0
query1 0 cv 1
query1 0 rw 0
query1 0 qw 0
query1 0 ww 1

The query1 is not related with all the nodes of the scattered matrix but
only with someone. The third column gives me which node is related with
query1. This is the most important column.
The second column with all "0" is a vector of costant that is useless. The
fourth column tells me if the node considered in the second column is
relevant to the query or not and also this column is not important for my
Now, considering the query1, I want to obtain a new scattered matrix where
only the nodes related with query1 appears. Starting from the example a have
to obtain:

aa cc
dd cv rw

The steps to do are: take the first line of the scattered matrix. If the
first node (of the first column) of the row doesn't appear in the list of
the nodes related to query, do not consider this line. If the node appears,
then look if at least  another node in the row is related with query1. Write
the lines with all the nodes related with query1, without writing the nodes
that are not related with query1.
Take the second line and do the same things...

Summarizing: starting from the first matrix I want to use the third column
of the second matrix to obtain a new one that contains only the nodes that
appear in the third column.
The output must be a matrix that has at least two elements for row.
The most important node is in the first column and so if it doesn't match
with the third column of query1, the row is not considered.
For example if I have a b c in a row of the matrix and "a" is not a node
related with query, the row must not be considered.

If a solve this problem I'm in a good point of my thesis.
Thank you very much. Excuseme for my english.
Alessandro Ambrosini

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list