[R] Read data in sequences

RockO rock.ouimet at gmail.com
Sun Apr 11 20:03:05 CEST 2010


Hi,

Thank you very much for your help! Here is the coding I used to make it
work:

    x <- textConnection("A 2.5 3.4 2.7 5.6 5.7 5.4 10.1 9.4 
    B 5.3 5.4 6.5 7.5 1.3 4.5 10.5 4.1 
    C 2.1 2.3 2.1 5.4 9.0 4.5 20.1 3.7")
    dat <- read.table(x)
    nv <- 2 # Number of variables that are repeated in sequence
    mkvarying <-
function(n)list(paste("V",seq(nv,n,by=nv),sep=""),paste("V",seq(nv+1,n,by=nv),sep=""))
   
reshape(dat,idvar="V1",varying=mkvarying(I(length(dat))),direction="long",timevar=NULL)

It is a good idea to first read the data then rearrange them in a second
step.

Rock
DRF-MRNF, Quebec
-- 
View this message in context: http://n4.nabble.com/Read-data-in-sequences-tp1819487p1836275.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list