Re: [R] storing output data from a loop that has varying row numbers

From: RCulloch <ross.culloch_at_dur.ac.uk>
Date: Tue, 01 Jun 2010 07:25:23 -0700 (PDT)

Hi Joris,

Thanks for your help!

The data as requested:

structure(list(FROM = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 

    TO = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L,

    2L, 3L, 4L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 
    3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), DIST = c(2.63981, 
    0, 6.95836, 8.63809, 0, 2.63981, 8.03071, 8.90896, 8.90896, 
    8.63809, 2.85602, 0, 8.03071, 6.95836, 0, 2.85602, 3.53695,     4.32457, 0, 8.85851, 12.09194, 7.44743, 0, 4.32457, 13.16728,
    16.34761, 6.13176, 13.16728, 8.85851, 0, 3.40726, 9.03345, 
    16.34761, 12.09194, 3.40726, 0, 0, 7.44743, 3.53695, 6.13176, 
    9.03345), ID = structure(c(12L, 12L, 12L, 12L, 11L, 11L, 
    11L, 11L, 14L, 14L, 14L, 14L, 13L, 13L, 13L, 143L, 12L, 12L, 
    12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L, 
    14L, 13L, 13L, 13L, 13L, 13L, 94L, 94L, 94L, 94L, 94L), .Label =
c("'11.1'",

"'15.1'", "'15.5'", "'18.1'", "'24.2'", "'26.1'", "'26.2'",
"'28.3'", "'4.2'", "'7.1'", "'A1.1'", "'A1'", "'A2.1'", "'A2'",
"'B1'", "'C1'", "'D1.1'", "'D1'", "'D2.1'", "'D2'", "'D3.1'",
"'D3'", "'D4.1'", "'D4'", "'D5.1'", "'D5'", "'D6.1'", "'D6'",
"'E1.1'", "'E1'", "'E2.1'", "'E2'", "'E4'", "'E5'", "'F1.1'",
"'F1'", "'F10.1'", "'F10'", "'F11'", "'F2'", "'F3'", "'F4.1'",
"'F4'", "'F5.1'", "'F5'", "'F7'", "'F8.1'", "'F8'", "'G2.1'",
"'G2'", "'G3.1'", "'G3'", "'G4.1'", "'G4'", "'G5.1'", "'G5'",
"'H1.1'", "'H1'", "'H2'", "'H3.1'", "'H3'", "'H8'", "'I1.1'",
"'I1'", "'I2'", "'I4.1'", "'I4'", "'J1.1'", "'J1'", "'J2.1'",
"'J2'", "'J3'", "'J6'", "'J7'", "'JUV'", "'K1.1'", "'K1'",
"'K2'", "'K3'", "'K4.1'", "'K4'", "'L1.1'", "'L1'", "'L2.1'",
"'L2'", "'L4'", "'M1'", "'M2.1'", "'M2'", "'M3.1'", "'M3'",
"'M4.1'", "'M4'", "'MALE1'", "'N1.1'", "'N1'", "'N2'", "'N3'",
"'N4.1'", "'N4'", "'O1'", "'O2'", "'O3.1'", "'O3'", "'O4.1'",
"'O4'", "'O5'", "'P1.1'", "'P1'", "'Q1'", "'Q2'", "'Q3'",
"'R1.1'", "'R1'", "'R2'", "'R3.1'", "'R3'", "'R4.1'", "'R4'",
"'R5.1'", "'R5'", "'S1.1'", "'S1'", "'S2.1'", "'S2'", "'S3.1'",
"'S3'", "'S4.1'", "'S4'", "'T1'", "'U1.1'", "'U1'", "'U2'",
"'U3'", "'UKFEM'", "'UKMAL'", "'UKPUP'", "'V1.1'", "'V1'",
"'W1.1'", "'W1'", "'WR'", "A2.1'"), class = "factor"), HR = c(9L,

    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
    10L), DD = c(30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
    30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
    30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
    30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L), MM = c(9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), YY = c(7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 7L), ANIMAL = c(1L, 1L, 1L, 1L, 7L, 7L, 
    7L, 7L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 
    7L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 7L, 
    12L, 12L, 12L, 12L, 12L), DAY = c(1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L)), .Names = c("FROM", "TO", "DIST", "ID", "HR", "DD", "MM", "YY", "ANIMAL", "DAY"), row.names = c(NA, 41L ), class = "data.frame")

The output should be as the original file is, but it should have an additional column for 'TO_ID'

I hope that makes sense?

Cheers,

Ross

-- 
View this message in context: http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238576.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 01 Jun 2010 - 15:21:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Jun 2010 - 15:50:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive