RE: is there a way to change fit to csv

From: Matt Fidler Date: September 14, 2010 technical Source: mail-archive.com
Chandramouli, Justin's solution is elegant and works on most datasets produced. However, occasionally NONMEM outputs "numbers" formatted like the following 1.00-103 which should be 1.00E+103. I have created a small function that reads in NONMEM datasets and fixes this problem: read.nm<-function(file,na.strings=c("NA","."),...){ nmf<-readLines(file,n=-1)[-1] nmf<-gsub("+",",",nmf) nmf<-gsub("^,","",nmf) nmf<-gsub("([0-9])([-+])([0-9])","\\1E\\2\\3",nmf) tf<-tempfile() cat(nmf,file=tf,sep="\n") d<-read.csv(tf,na.strings=na.strings,...) unlink(tf) return(d) } Once this function is sourced, all you need to do is read NONMEM in through the new function: d<- read.nm("table.tbl") Matt.
Quoted reply history
From: [email protected] [mailto:[email protected]] On Behalf Of Justin Wilkins Sent: Tuesday, September 14, 2010 1:24 AM To: Chandramouli Radhakrishnan Cc: [email protected] Subject: Re: [NMusers] is there a way to change fit to csv Dear Chandramouli Typically something like > fit <- read.table("run1.fit", head=T, skip=1) (where run1.fit is a typical NONMEM table file, with headers) should do what you need. If not, have a look at the NONMEM table in a text editor - NONMEM tables are basically space-delimited text files, which R's read.table function ought to be able to handle easily. Best Justin On 14 September 2010 07:42, Chandramouli Radhakrishnan <[email protected]<mailto:[email protected]>> wrote: Hi I am trying to use R to produce plots from NONMEM fit file. However, I could not get R to read the fit file Can any one help? Kind Regards Chandramouli Radhakrishnan -- Justin Wilkins ----------------------------- Colmarerstrasse 31 4055 Basel Switzerland ----------------------------- Email: [email protected]<mailto:[email protected]> Skype: kestrel_za2002 Mobile: +41 76 561 0949 ________________________________ This e-mail (including any attachments) is confidential and may be legally privileged. If you are not an intended recipient or an authorized representative of an intended recipient, you are prohibited from using, copying or distributing the information in this e-mail or its attachments. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete all copies of this message and any attachments. Thank you.
Sep 14, 2010 Chandramouli Radhakrishnan is there a way to change fit to csv
Sep 14, 2010 Justin Wilkins Re: is there a way to change fit to csv
Sep 14, 2010 Dieter Menne RE: is there a way to change fit to csv
Sep 14, 2010 Matt Fidler RE: is there a way to change fit to csv
Sep 14, 2010 Robert Bauer RE: is there a way to change fit to csv
Sep 14, 2010 Nick Holford Re: is there a way to change fit to csv