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
is there a way to change fit to csv
6 messages
6 people
Latest: Sep 14, 2010
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
Quoted reply history
On 14 September 2010 07:42, Chandramouli Radhakrishnan <
[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]
Skype: kestrel_za2002
Mobile: +41 76 561 0949
Chandra,
the usual way to read NOMEM files from R is via the XPOSE(4) library. It's
not on CRAN, you have to download it from
http://xpose.sourceforge.net/index.php
Dieter
Quoted reply history
From: [email protected] [mailto:[email protected]] On
Behalf Of Chandramouli Radhakrishnan
Sent: Tuesday, September 14, 2010 7:42 AM
To: [email protected]
Subject: [NMusers] is there a way to change fit to csv
I am trying to use R to produce plots from NONMEM fit file. However, I could
not get R to read the fit file
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.
This is Fortran format that is trying to keep within the alloted spaced
for the number while expressing values less than 1e-100. Users may
select the following format to express the exponent over 3 digits
instead of the usual 2:
FORMAT=s,1PE16.8E3
the FORMAT option may be used on $EST or $TABLE statements (these act
only on FILE outputted tables).
Robert J. Bauer, Ph.D.
Vice President, Pharmacometrics
ICON Development Solutions
Tel: (215) 616-6428
Mob: (925) 286-0769
Email: [email protected]
Web: www.icondevsolutions.com
Quoted reply history
________________________________
From: [email protected] [mailto:[email protected]]
On Behalf Of Fidler,Matt,FORT WORTH,R&D
Sent: Tuesday, September 14, 2010 9:33 AM
To: Justin Wilkins; Chandramouli Radhakrishnan
Cc: [email protected]
Subject: RE: [NMusers] is there a way to change fit to csv
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.
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]> 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]
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.
Hi,
In case one wishes to read a NONMEM table containing multiple table headers (e.g. as created using $SIMULATION with more than one subproblem) then you need to remove the unwanted table headers e.g.
read.nm<-function(fileName) {
dat=read.csv(fileName,sep="",header=T,skip=1,stringsAsFactors=F)
#remove TABLE and data item header from subsequent sub-problems
temp <- dat[dat[,1]!="TABLE"&dat[,1]!=names(dat[1]),]
temp <- as.data.frame(apply(temp,2,as.numeric))
return(temp)
}
d<-read.nm("table.tbl")
> 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.
>
> *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
>
Quoted reply history
> 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.
--
Nick Holford, Professor Clinical Pharmacology
Dept Pharmacology& Clinical Pharmacology
University of Auckland,85 Park Rd,Private Bag 92019,Auckland,New Zealand
tel:+64(9)923-6730 fax:+64(9)373-7090 mobile:+64(21)46 23 53
email: [email protected]
http://www.fmhs.auckland.ac.nz/sms/pharmacology/holford