Re: [R] How to preserve the numeric format and digits ?

2008-07-24 Thread Austin, Matt
paste(A, format(m, scientific=FALSE, trim=TRUE), B, sep=)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daren Tan
Sent: Thursday, July 24, 2008 5:47 PM
To: [EMAIL PROTECTED]
Subject: [R] How to preserve the numeric format and digits ?


Instead of

 m - c(4, 500)
 paste(A, m, B, sep=)
[1] A4e+08B A5e+10B

I want A4 and A500

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using PrettyR to produce LaTeX output

2008-07-23 Thread Austin, Matt
You might look at the summary method in Dr. Harrell's Hmisc package, I believe 
this would give you almost exactly what you want.

latex(summary(gender ~ age + bmi, data=yourdata, method='reverse'))

This will get you quartiles, but if you read the documentation 
(?summary.formula) you can see how to create custom summaries.

--Matt

Matt Austin
Global Statistical Leader, denosumab PMO
Director, Biostatistics
Amgen, Inc


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jcarmichael
Sent: Wednesday, July 23, 2008 12:46 PM
To: r-help@r-project.org
Subject: [R] Using PrettyR to produce LaTeX output


Hello everyone.  I am new to R, so please bear with me.  I am trying to find an 
easy way to export descriptive statistics and other information about my data 
frame to a LaTeX format.

I have found the describe function in PrettyR to be very helpful in producing 
results in the exact format I'm looking for.  However, the value of the 
describe function is a LIST (rather than a data frame) which I am then unable 
to convert to LaTeX using the xtable package or the latex function of Hmisc.  
When I try to convert the list to a data frame, I get an error that says 
arguments imply differing number of rows.

If that didn't make any sense...ultimately, here is what I'm trying (and
failing) to produce as a LaTeX document...

 MALES   FEMALES
Q10 MedQ90Q10Med   Q90
AGE   xxxx   xx  xx   xx  xx
BMI   xxxxxx xxxx
xx
etc.   xxxxxx xxxx
xx

Any help or guidance would be appreciated!  Thank you in advanced!

J.
--
View this message in context: 
http://www.nabble.com/Using-PrettyR-to-produce-LaTeX-output-tp18618195p18618195.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Labelling curves on graphs

2008-07-16 Thread Austin, Matt
Dr. Harrell's Hmisc package has labcurve.

--Matt

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ted Harding
Sent: Wednesday, July 16, 2008 1:17 PM
To: [EMAIL PROTECTED]
Subject: [R] Labelling curves on graphs

Hi Folks,
I'd be grateful for good suggestions about the following.

I'm plotting a family of (X,Y) curves (for different levels of another 
variable, Z): say 6 curves in all but could be more or less -- it's a rather 
variables situation.

I'd like to label each curve with the value of Z that it corresponds to.

The problem is that the layout (shapes, spacings, ranges of X over which non-NA 
values of Y get plotted) of the curves are very variable, and somewhat 
unpredictable beforehand.

Of course one could simply wait until the graph was done, and then by hand 
position one's labels to the best effect.
That, given time, is on a certain sense the optimum solution.
But I'd like to be able to do a satisfactory job automatically, and quickly!

This is the sort of problem already solved, in one particular way, in 
contour(). But here the curves are broken at the labels and the labels are 
centred on the curves (though nicely aligned with the curves).

It might be satisfactory for me to place each label so that its baseline is on 
its curve, thus without overlaying the curve with the text. So maybe a 
displaced analogue of the way contour() does it (including alignment of the 
text) may be OK.

Anothe possibility, for instance, is to draw lines from the ends of the curves 
to antries in a plotted table of Z-values. This could end up looking very 
untidym, though.

I grant that this is a vague query. I'm still trying to form a clear view of 
how it ought to be approached; and I don't have R code to refer to and 
experiment with (that of contour() is hidden in its method).

But people out there must have faced it, and I'd be grateful for their own 
feedback from the coal-face!

With thanks,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 16-Jul-08   Time: 21:17:13
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] linear model in the repeated data type~

2008-06-05 Thread Austin, Matt
allFits - lmList(y ~ t|id, data=table1, pool=FALSE)

allCoefs - sapply(allFits, coef)  ## preferred by me

or

allCoefs - list(length(allFits))
for(i in 1:length(allFits)) allCoef[[i]] -  coef(allFits[[i]])

--Matt


From: Manli Yan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 04, 2008 9:12 PM
To: Austin, Matt
Cc: r-help@r-project.org
Subject: Re: [R] linear model in the repeated data type~

hi:lot thanks,how to use list to extract,I type  allFit$coefficents,it came to 
nothing,
such as I need to extract the estimates,how to do it by using list

2008/6/3 Austin, Matt [EMAIL PROTECTED]mailto:[EMAIL PROTECTED]:
How about


library(nlme)
allFits - lmList(y ~ t|id, data=table1, pool=FALSE)

or

allFits - by(table1, table1$id, function(x) lm(y ~ t, data=x))

Both ways store the results as a list, so you can access individual results 
using list extraction.


--Matt

-Original Message-
From: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] [mailto:[EMAIL 
PROTECTED]mailto:[EMAIL PROTECTED]] On Behalf Of Manli Yan
Sent: Tuesday, June 03, 2008 9:07 PM
To: r-help@r-project.orgmailto:r-help@r-project.org
Subject: [R] linear model in the repeated data type~

 here is the data:
 y-c(5,2,3,7,9,0,1,4,5)
id-c(1,1,6,6,7,8,15,15,19)
t-c(50,56,50,56,50,50,50,60,50)
table1-data.frame(y,id,t)//longitudinal data

what  I want to do is to use the linear model for each id ,then get the 
estimate value,like:

fit1-lm(y~t,data=table1,subset=(id==1))

but ,you can see the variable id is quite irregular,they are not arranaged in 
order and many number missing,if I write a loop by using for,it will give me 
a lot NA, and for sure ,I dont want to type id=## for about 500 times,any one 
know how to deal with it?

   [[alternative HTML version deleted]]

__
R-help@r-project.orgmailto:R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] linear model in the repeated data type~

2008-06-05 Thread Austin, Matt
Apologies, the second method should have been

allCoefs - vector(list, length(allFits))

for(i in 1:length(allFits)) allCoefs[[i]] -  coef(allFits[[i]])

--Matt


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Austin, Matt
Sent: Thursday, June 05, 2008 3:03 PM
To: Manli Yan
Cc: r-help@r-project.org
Subject: Re: [R] linear model in the repeated data type~

allFits - lmList(y ~ t|id, data=table1, pool=FALSE)

allCoefs - sapply(allFits, coef)  ## preferred by me

or

allCoefs - list(length(allFits))
for(i in 1:length(allFits)) allCoef[[i]] -  coef(allFits[[i]])

--Matt


From: Manli Yan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 04, 2008 9:12 PM
To: Austin, Matt
Cc: r-help@r-project.org
Subject: Re: [R] linear model in the repeated data type~

hi:lot thanks,how to use list to extract,I type  allFit$coefficents,it came to 
nothing, such as I need to extract the estimates,how to do it by using list

2008/6/3 Austin, Matt [EMAIL PROTECTED]mailto:[EMAIL PROTECTED]:
How about


library(nlme)
allFits - lmList(y ~ t|id, data=table1, pool=FALSE)

or

allFits - by(table1, table1$id, function(x) lm(y ~ t, data=x))

Both ways store the results as a list, so you can access individual results 
using list extraction.


--Matt

-Original Message-
From: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] [mailto:[EMAIL 
PROTECTED]mailto:[EMAIL PROTECTED]] On Behalf Of Manli Yan
Sent: Tuesday, June 03, 2008 9:07 PM
To: r-help@r-project.orgmailto:r-help@r-project.org
Subject: [R] linear model in the repeated data type~

 here is the data:
 y-c(5,2,3,7,9,0,1,4,5)
id-c(1,1,6,6,7,8,15,15,19)
t-c(50,56,50,56,50,50,50,60,50)
table1-data.frame(y,id,t)//longitudinal data

what  I want to do is to use the linear model for each id ,then get the 
estimate value,like:

fit1-lm(y~t,data=table1,subset=(id==1))

but ,you can see the variable id is quite irregular,they are not arranaged in 
order and many number missing,if I write a loop by using for,it will give me 
a lot NA, and for sure ,I dont want to type id=## for about 500 times,any one 
know how to deal with it?

   [[alternative HTML version deleted]]

__
R-help@r-project.orgmailto:R-help@r-project.org mailing list 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] linear model in the repeated data type~

2008-06-03 Thread Austin, Matt
How about


library(nlme)
allFits - lmList(y ~ t|id, data=table1, pool=FALSE)

or

allFits - by(table1, table1$id, function(x) lm(y ~ t, data=x))

Both ways store the results as a list, so you can access individual results 
using list extraction.


--Matt

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Manli Yan
Sent: Tuesday, June 03, 2008 9:07 PM
To: r-help@r-project.org
Subject: [R] linear model in the repeated data type~

  here is the data:
 y-c(5,2,3,7,9,0,1,4,5)
id-c(1,1,6,6,7,8,15,15,19)
t-c(50,56,50,56,50,50,50,60,50)
table1-data.frame(y,id,t)//longitudinal data

what  I want to do is to use the linear model for each id ,then get the 
estimate value,like:

fit1-lm(y~t,data=table1,subset=(id==1))

but ,you can see the variable id is quite irregular,they are not arranaged in 
order and many number missing,if I write a loop by using for,it will give me 
a lot NA, and for sure ,I dont want to type id=## for about 500 times,any one 
know how to deal with it?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Row mean scores differ association

2008-04-10 Thread Austin, Matt


There is a R companion to Agresti's text at the following site, I believe the 
answer to your question is there:

http://www.stat.ufl.edu/~aa/cda/cda.html


--Matt

Matt Austin
Biostatistics Director
Amgen, Inc


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of dt Excellent
Sent: Thursday, April 10, 2008 1:18 PM
To: R-Help
Subject: [R] Row mean scores differ association

Suppose that we have o 2-D contingency table where the row variable is nominal 
and the column one is ordinal. In SAS it is possible to compute the statistic 
named as row mean scores differ. How can we programmed it in R?
(See also Aggresti (2002), Categorical Data Analysis, p. 302) With regards


-



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] basehaz and newdata

2008-04-07 Thread Austin, Matt
I don't believe basehaz takes a newdata argument.

 args(basehaz)
function (fit, centered = TRUE)
NULL

It simply extracts info from the fitted object.  I think you want to use 
survfit method for coxph objects and then derive/extract what you need.

--Matt

Matt Austin
Global Statistical Leader, denosumab PMO
Biostatistics Director
Amgen, Inc


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of mah
Sent: Monday, April 07, 2008 10:01 AM
To: r-help@r-project.org
Subject: Re: [R] basehaz and newdata

Thanks Roland, but using data frames does not resolve the issue.  See revised 
code and output below:

  test1 - data.frame(
+ time=  c(4, 3,1,1,2,2,3),
+ status=c(1,NA,1,0,1,1,0),
+ x= c(0, 2,1,1,1,0,0),
+ sex=   c(0, 0,0,0,1,1,1)
+ )
  f1 - coxph( Surv(time, status) ~ x + strata(sex), data=test1)
 #stratified model

  test2 - data.frame(
+ time=  c(4, 3,1,1,2,2,3),
+ status=c(1,NA,1,0,1,1,0),
+ x= c(1, 2,1,1,1,0,0),
+ sex=   c(0, 0,0,0,1,1,1)
+ )
  f2 - coxph( Surv(time, status) ~ x + strata(sex), data=test2)
 #stratified model

  f1
Call:
coxph(formula = Surv(time, status) ~ x + strata(sex), data = test1)


  coef exp(coef) se(coef) zp
x 1.17  3.22 1.29 0.907 0.36

Likelihood ratio test=0.87  on 1 df, p=0.351  n=6 (1 observation deleted due to 
missingness)
  f2
Call:
coxph(formula = Surv(time, status) ~ x + strata(sex), data = test2)


   coef exp(coef) se(coef)zp
x 0.896  2.45 1.42 0.63 0.53

Likelihood ratio test=0.38  on 1 df, p=0.535  n=6 (1 observation deleted due to 
missingness)
  basehaz(f1, newdata=test2)
Error in basehaz(f1, newdata = test2) :
  unused argument(s) (newdata = list(time = c(4, 3, 1, 1, 2, 2, 3), status = 
c(1, NA, 1, 0, 1, 1, 0), x = c(1, 2, 1, 1, 1, 0, 0), sex = c(0, 0, 0, 0, 1, 1, 
1)))


Mike

On Apr 7, 11:43 am, Roland Rau [EMAIL PROTECTED] wrote:
 Hi,

 just looked at it briefly and I don't know if it is the real cause for
 your problems. But 'data' as well as 'newdata' require a data.frame
 and not a list as input.

 Does this help?

 Best,
 Roland





 mah wrote:
  I am unable to get thebasehazfunction to apply a proportional
  hazards model to a new data frame.  I replicated my specific
  situation with the example for coxph in the help, where I changed
  the x value of the first record from 0 to 1.  Is there something
  incorrect in the syntax that I am using?  Thanks in advance!

  test1 - list(time=  c(4, 3,1,1,2,2,3),
status=c(1,NA,1,0,1,1,0),
x= c(0, 2,1,1,1,0,0),
sex=   c(0, 0,0,0,1,1,1))
  test2 - list(time=  c(4, 3,1,1,2,2,3),
status=c(1,NA,1,0,1,1,0),
x= c(1, 2,1,1,1,0,0),
sex=   c(0, 0,0,0,1,1,1))
  f1 - coxph( Surv(time, status) ~ x + strata(sex), data=test1)
  #stratified model
  f2 - coxph( Surv(time, status) ~ x + strata(sex), data=test2)
  #stratified model
   f1
  Call:
  coxph(formula = Surv(time, status) ~ x + strata(sex), data = test1)

coef exp(coef) se(coef) zp
  x 1.17  3.22 1.29 0.907 0.36

  Likelihood ratio test=0.87  on 1 df, p=0.351  n=6 (1 observation
  deleted due to missingness)
  f2
  Call:
  coxph(formula = Surv(time, status) ~ x + strata(sex), data = test2)

 coef exp(coef) se(coef)zp
  x 0.896  2.45 1.42 0.63 0.53

  Likelihood ratio test=0.38  on 1 df, p=0.535  n=6 (1 observation
  deleted due to missingness)
 basehaz(f1, newdata=test2)
  Error inbasehaz(f1, newdata = test2) :
unused argument(s) (newdata = list(time = c(4, 3, 1, 1, 2, 2, 3),
  status = c(1, NA, 1, 0, 1, 1, 0), x = c(1, 2, 1, 1, 1, 0, 0), sex =
  c(0, 0, 0, 0, 1, 1, 1)))

  __
  [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting
 guidehttp://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 __
 [EMAIL PROTECTED] mailing
 listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting
 guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.-
 Hide quoted text -

 - Show quoted text -

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] format numbers using 1000 separator

2008-04-04 Thread Austin, Matt
 format(10, big.mark=,, scientific=FALSE)
[1] 1,000,000,000

--Matt

Matt Austin
Biostatistics Director
Amgen, Inc


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tom soyer
Sent: Friday, April 04, 2008 2:41 PM
To: r-help@r-project.org
Subject: [R] format numbers using 1000 separator

Hi,

Does anyone know how one could format numbers using 1000 separator in R? For 
example, format 1000 as 1,000 and 10 as 100,000, etc.

Thanks,

--
Tom

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Graphics and LaTeX documents with the same font

2007-09-28 Thread Austin, Matt
I find them helpful for displaying the differences in coupled biomarkers
between therapies with different therapeutic targets.  You can quickly
see/show which marker is affected quicker and then the other compensating in
response and how they can be reversed depending on target. Having each
measure on its own actual scale and not having to do something like percent
change over time is very helpful (for many biomarkers it's hard to judge the
clinical relavence of scaled values).  

I believe in looking at the data in numerous ways, to help myself from
confusing or misleading myself--which is not my intent.

--Matt Austin
Statistician, Amgen Inc.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of hadley wickham
Sent: Friday, September 28, 2007 10:14 AM
To: Frank E Harrell Jr
Cc: R-help
Subject: Re: [R] Graphics and LaTeX documents with the same font

 Yes there is harm.  But to make bold lines, easy to read titles is fine.
   See the spar function in
 http://biostat.mc.vanderbilt.edu/SgraphicsHints for a starter.  Also see
 the setps, ps.slide, and setpdf functions in the Hmisc package.

I was interested to see that you have code for drawing scatterplots
with multiple y-axes.  As far as I know the only legitimate use for a
double-axis plot is to confuse or mislead the reader (and this is not
a very ethical use case).  Perhaps you have a counter-example?

Hadley

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.