Page 1 of 1

Multi-line inp files

PostPosted: Mon Dec 20, 2010 1:07 pm
by jlaake
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

Re: Multi-line inp files

PostPosted: Mon Dec 20, 2010 1:26 pm
by bacollier
All,
Just visited with Jeff, I told him I was not sure this is a MARK issue or a text editor issue. The abomination (notepad) I think has some forced word wrapping function at a certain point (e.g., either as wide as your screen is or some other arbitrary embedded length). I use emacs, ted, or gsnote and I have successfully run large dataset with lots more columns than most standard studies using RMark without errors so this may just be a text editor issue and not a MARK problem.

So I will also toss this at Gary, are there MARK length limits?

Bret

Re: Multi-line inp files

PostPosted: Mon Dec 20, 2010 1:28 pm
by bacollier
Sorry fingers to fast, I meant "not sure this is a MARK issue, rather, I think its a text editor issue."

Re: Multi-line inp files

PostPosted: Mon Dec 20, 2010 1:34 pm
by cooch
bacollier wrote:Sorry fingers to fast, I meant "not sure this is a MARK issue, rather, I think its a text editor issue."


Correct -- this is not a MARK limitation, but an editor limitation. Item 9(b) from the MARK FAQ:

9(b) 'garbage in, garbage out' - the input file - many of the problems people have getting started with MARK can ultimately be traced back to problems with the input (.inp) file. You are strongly encouraged to spend a lot of quality time reading the documentation about data formatting before you do anything else. Also, as a general suggestion, avoid - as in 'like the plague' - using Windows Notepad (or, even worse, Word) to do much of anything related to building/editing .inp files. Do yourself a favor and get yourself a real ASCII editor - there are a number of very good 'free' applications you can (and should) use instead of Notepad (e.g., Notepad++, EditPad Lite, jEdit, and so on...)