Multi-line inp files

I was contacted off-list by someone trying to import a MARK .inp file that was multi-line. She used multi-line because apparently the line length in MARK is limited.
Here is my response which may be useful to others:
convert.inp will not work with a multi-line file as you found. I wrote some code that will handle the file for you. You'll need to modify for the correct group structure/variables. You said there were 6 groups so I just created a dummy covariate. Also, you'll want to assign the variable names that you want.
# use strip.comments in RMark to remove \* *\ values and write out to a temporary file
out.file=strip.comments("sample.inp", use.comments = FALSE, header = FALSE)$out.filename
# read in the temp file which is in blocks of 5 lines
xx=readLines(out.file,-1)
# paste together into single records
for (i in seq(1,length(xx),5))
write(paste(xx[i:(i+4)],collapse=""),file="sample.txt",append=TRUE)
# use convert.inp - this uses dummy covariate names and group structure which I don't know
sampledf=convert.inp("sample.txt",group.df=data.frame(group=1:6),covariates=paste("x",1:108,sep=""))
This code would have to be modified to handle different numbers of variables per line and different number of lines per record but it may be useful for someone. --jeff
Here is my response which may be useful to others:
convert.inp will not work with a multi-line file as you found. I wrote some code that will handle the file for you. You'll need to modify for the correct group structure/variables. You said there were 6 groups so I just created a dummy covariate. Also, you'll want to assign the variable names that you want.
# use strip.comments in RMark to remove \* *\ values and write out to a temporary file
out.file=strip.comments("sample.inp", use.comments = FALSE, header = FALSE)$out.filename
# read in the temp file which is in blocks of 5 lines
xx=readLines(out.file,-1)
# paste together into single records
for (i in seq(1,length(xx),5))
write(paste(xx[i:(i+4)],collapse=""),file="sample.txt",append=TRUE)
# use convert.inp - this uses dummy covariate names and group structure which I don't know
sampledf=convert.inp("sample.txt",group.df=data.frame(group=1:6),covariates=paste("x",1:108,sep=""))
This code would have to be modified to handle different numbers of variables per line and different number of lines per record but it may be useful for someone. --jeff