# [R] store and repeat data based on row names (loop, if statement)

RCulloch ross.culloch at dur.ac.uk
Mon May 31 09:28:30 CEST 2010

```Hello fellow R users,

I have an issue that has me a little confused - sorry if the subject makes
little sense, I wasn't sure how to refer to this problem. I have a data set
I've extracted from ArcInfo (a section is shown below). It is spatial data,
showing the distance from one ID to another. I want to get the actual 'TO'
ID from the data set (there is no easy way to do this in Arc so I thought I
would try in R). The way to do this is to find the dist = 0 row for an ID
then that is that IDs unique 'TO' code, so if you look down the second
column the highest no. is 4, and A1 = 2, A1.1 = 1, A2 = 4, A2.1 = 3. So I
need to get that data and then put it in a new column that will basically
read A1.1, A1, A2.1, A2, A1.1, A1, A2.1, A2, A1.1, A1, A2.1, A2, A1.1, A1,
A2.1, A2.

If anyone has any hints or tips or places to look I would be most grateful!

Cheers,

Ross

TO	DIST  	ID
1	2.63981	'A1'
2	0	           'A1'
3	6.95836	'A1'
4	8.63809	'A1'
1	0	           'A1.1'
2	2.63981	'A1.1'
3	8.03071	'A1.1'
4	8.90896	'A1.1'
1	8.90896	'A2'
2	8.63809	'A2'
3	2.85602	'A2'
4	0	           'A2'
1	8.03071	'A2.1'
2	6.95836	'A2.1'
3	0	           'A2.1'
4	2.85602	A2.1'
--
View this message in context: http://r.789695.n4.nabble.com/store-and-repeat-data-based-on-row-names-loop-if-statement-tp2236928p2236928.html
Sent from the R help mailing list archive at Nabble.com.

```