[R] Any tests/exams freely available with answers to test basic R knowledge

2011-06-09 Thread Daniel Brewer
Hello,

I have the responsibility of ensuring that a colleague who is just
learning R knows the basics before a course where that is a requirement.
 The colleague has gone through a couple of tutorials so hopefully she
is ok, but I would like to give her a test to gauge it.

I was therefore wondering if anyone knew if there were any materials on
the web that would be suitable? and is possible had both questions and
answers.

Many thanks

Dan

PS Cross-posted to http://stats.stackexchange.com
-- 
**

Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom

Tel: +44 (0) 20 8722 4109

**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Remove 100 years from a date object

2010-12-10 Thread Daniel Brewer


On 10/12/2010 4:17 PM, Barry Rowlingson wrote:
> On Fri, Dec 10, 2010 at 3:27 PM, Daniel Brewer  
> wrote:
>> Hello,
>>
>> I have some data that has dates in the form 27.02.37.  I convert them to
>> a date object as follows:
>> as.Date(data$date,format="%d.%m.%y")
>>
>> But this gives me years such as 2037 when I would like them to be 1937.
>>  I thought of trying to take off some time i.e.
>> as.Date(camCD$DoB,format="%d.%m.%y") - 100*365
>> But that doesn't seem to work out correctly.  Any ideas how to do this?
> 
> Normally to adjust dates you can use as.difftime() and do arithmetic,
> but a year is a variable thing (can be 365 or 366 days) so you cant
> make a difftime of years. Days are variable things if you worry about
> leap seconds...
> 
> Also, you could end up with an invalid date if you have 29-Feb-2000
> and 29-Feb-1900. One wasn't a leap year...
> 
> A solution minus those caveats is to convert to POSIXlt and adjust the
> $year element:
> 
>  > dob="27.02.37"
>  > as.Date(dob,format="%d.%m.%y")
> [1] "2037-02-27"
>  > dobp = as.POSIXlt(as.Date(dob,format="%d.%m.%y"))
>  > dobp$year = dobp$year - 100
> 
>  > dobp
> [1] "1937-02-27 UTC"
>  > as.Date(dobp)
> [1] "1937-02-27"
> 
> although it might be easier to paste a '19' into your character variable
> 
>  > paste(substr(dob,1,6),"19",substr(dob,7,9),sep="")
> [1] "27.02.1937"
> 
> and then do it the way you started. Assumes you have leading zeroes on
> all fields though.
> 
> Barry

Many thanks.  Thats great

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Remove 100 years from a date object

2010-12-10 Thread Daniel Brewer
Hello,

I have some data that has dates in the form 27.02.37.  I convert them to
a date object as follows:
as.Date(data$date,format="%d.%m.%y")

But this gives me years such as 2037 when I would like them to be 1937.
 I thought of trying to take off some time i.e.
as.Date(camCD$DoB,format="%d.%m.%y") - 100*365
But that doesn't seem to work out correctly.  Any ideas how to do this?

Thanks

Dan
-- 
**********
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] melt causes errors when characters and values are used

2010-12-10 Thread Daniel Brewer
Hello,

I am finding that the melt function from the reshape library causes
errors when applied to a data.frame that contains numeric and character
columns.  For example,

melt(id.vars="ID",data.frame(ID=1:3,date=c("a","b","c"),value=c(1,4,5)))
  ID variable value
1  1 date a
2  2 date b
3  3 date c
4  1value  
5  2value  
6  3value  
Warning message:
In `[<-.factor`(`*tmp*`, ri, value = c(1, 4, 5)) :
  invalid factor level, NAs generated

It would be useful in this situation that the numerical column got
converted to a character column in this situation.  Any ways round this?

In actual fact I have got a situation where it is more like this

ID  Date_1  Value_1 Date_2  Value_2 ...

and I would like to convert it to a data.frame of ID, Date & Value but I
thought the above would be an appropriate middle step.

Thanks

Dan
-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Suitable test for ordinal variable vs continuous variable trend

2010-12-02 Thread Daniel Brewer
Dear all,

For a population of about 200 I have a continuous variable and an ordinal 
variable.  The question I would like to ask is whether the continuously 
increases (or decreases) as the rank of the ordinal variable increases.  I was 
thinking that a Spearmen's rank correlation or or a chi squared trend might be 
appropriate.  I don't have any experience dealing with ordinal variables so I 
am at a bit of a loss.  What is the most appropriate test? and is it 
implemented in R?

Many thanks


******

Daniel Brewer

Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom 

Tel: +44 (0) 20 8722 4109
Fax: +44 (0) 20 8722 4141

Email: daniel.bre...@icr.ac.uk 

**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:5}}

__
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] expand comma separated field vertically in data.frame

2010-11-19 Thread Daniel Brewer
Hello,

I have a data.frame like this:
a   1,2,3,4 b1
b   6,7 b3

And I would like to transform it to this:
a   1   b1
a   2   b1
a   3   b1
a   4   b1
b   6   b3
b   7   b3

I have been looking at ddply but can't seem to work it out.  ANy help
would be gratefully received.

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Highlighting a few bars in a barplot

2010-09-09 Thread Daniel Brewer
Hello,

I have a bar plot where I am already using colour to distinguish one set
of samples from another.  I would also like to highlight a few of these
bars as ones that should be looked at in detail.  I was thinking of
using hatching, but I can't work out how or if you can have a background
colour and hatching which is different between bars.  Any suggestions on
how I should do this?

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Find classes for each column of a data.frame

2010-08-26 Thread Daniel Brewer
Hello,

Is there a simple way to get the class type for each column of a
data.frame?  I am in the situation where I would like to get all the
columns of a data.frame that are factors.

I have tried:
apply(df,2,class)
but all the columns come back as class "character".

Thanks

Dan

-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Bulk editing of mySQL tables

2010-03-24 Thread Daniel Brewer
Hello,

I have started to use RMySQL and I would like to use R to make batch
changes to data.  What it the best way to do this?  Is it to download
the table using dbGetQuery, manipulate the data in R and then
dbWriteTable to delete the existing table and replace it with the local
data.

What I am concerned about this is that it might lose some mySQL table
configuration options and it isn't a very effective way to do it.

An example of the sort of thing I am doing is to try and update a column
based on a CSV file stored locally.

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] A list of data.frames merged together

2010-03-09 Thread Daniel Brewer
Hello,

I have for a long list of data.frames that I would like to get merged.
Each data.frame have two columns with the same names (Date and Value).
What I would like is for the objects in the list to be merged on Only
date with the column header being the name in the list.

For example

A <- data.frame(Date=c("03/15/10","04/15/10","05/15/10"),
Value=c(1,2,3))
B <- data.frame(Date=c("03/15/10","04/15/10","06/15/10"),
Value=c(5,5,5))
...

yoda <- list(A=A,B=B,...)

Result:

DateA   B   C
03/15/101   5   ...
04/15/102   5
05/15/103   NA
06/15/10NA  5

Any ideas? I have been fiddling around with plyr and reshape without success

Thanks

Dan

-- 
******

Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom

Tel: +44 (0) 20 8722 4109

**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] COnfidence intervals for estimates of linear model

2009-12-23 Thread Daniel Brewer
Hello,

I would like to calculate the 95% confidence intervals for the estimates
of a linear model and I just wanted to check that I am doing it correct.
 Is it just:

Estimate + 1.95996*Std.Error to Estimate - 1.95996*Std.Error

or is there another approach that doesn't assume a normal distrbution?

Thanks.  Apologies for my naiivity

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Extract html tables to data.frames

2009-12-02 Thread Daniel Brewer
Hello,

I would like to scrape some html tables from a web page and convert them
to a data.frame so I can perform further analysis.  Could anyone tell me
the best way to do this?  Would it be more appropriate to use an
external tool first?

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] heatmap.2 adapting the colour scale and text overlay

2009-11-23 Thread Daniel Brewer

Hello,

I am using heatmap.2 from the gplots library to plot a small symmetrical 
matrix.


This is the command:

heatmap.2(tempHeat,symm=T,trace="none",cexRow=0.7,cexCol=0.7,col="redgreen",density.info="none")

I have a couple of questions:
1) The range is from -0.2 to 0.4 and the colour scheme I am using is 
redgreen.  What I would like is that a zero value to be black, 0.4 
strong green and -0.2 red.  Is this possible?  At the moment around 0.1 
is black.
2) Is it possible to overlay text on the squares of colour?  How ould 
one go about doing that.


I am happy to use another heatmap function if ti would be better.  I am 
not using the original heatmap as it does not provide a colour key.


Thanks

Dan
--
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Fitting a linear model with a break point

2009-09-08 Thread Daniel Brewer
Hello,

I would like to test some data to see whether it has the shape of a step
function (i.e. y1 up until x_th and then y2 where x_th is the
threshold).  The threshold x_th is unknown and the x values can only
take discrete values (0,1,2,3,4).

An example would be:
data<- data.frame(x=1:20,y=c(rnorm(10),rnorm(10,10)))


I was thinking along the lines of fitting some sort of piiecewise linear
model which has the gradient constrained to zero trying out all possible
different threshold and taking the one with the least residuals.  I am
not sure how to implement this in R.  Anyone got any ideas?

Also is there a way of including the threshold in the actual model, so
that could be estimated too?

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] order by decerasing 1st variable and increasing 2nd variable

2009-06-24 Thread Daniel Brewer
Hello,

I have a data.frame which I would like to sort with the primary key
decreasing while the secondry key is increasing e.g.

x <- data.frame(One=c(1,1,1,2,2,3,4,5),Two=c(2,3,1,2,3,3,3,3))

I would like to order it so it looks like this:

  One Two
8   5   3
7   4   3
6   3   3
4   2   2
5   2   3
3   1   1
1   1   2
2   1   3

i.e. primarily decreasing in the 1st column but if there is a tie
increasing in the second column.

Is this possible?  I can not find anything in order that seems to
support this.  I would have thought,

x[order(x$One,x$Two,decreasing=c(T,F)),]

would do it but it doesn't.

Thanks

Dan

-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Found the stable 64bit OS X leopard builds

2009-06-24 Thread Daniel Brewer
Hi,

I have found the stable 64bit OS X leopard builds here:
http://r.research.att.com/

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] CRAN: 64 bit OS X Leopard build

2009-06-24 Thread Daniel Brewer
Hello,

I am after a stable 64 bit binary of R for OS X Leopard (i.e. 2.8).
There seems to be the siggestion that thery should be available from CRAN:
"leopardBinaries of universal (32-bit and 64-bit) package builds for
Mac OS X 10.5 or higher"

But when I follow the link there is only a contrib directory which seems
to contain libraries only.

Can anyone help?

Thanks

Dan

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Bristol mirror GPG problem ubuntu repository

2009-05-06 Thread Daniel Brewer
Anyone know how to find the details of the mirror maintainers then?
because I can't find it.

Dan

Uwe Ligges wrote:
> 
> 
> Daniel Brewer wrote:
>> Hello,
>>
>> I am getting a GPG error with the ubuntu repository at the bristol UK
>> mirror.
>>
>> When my source.list has this line:
>>
>> deb http://www.stats.bris.ac.uk/R/bin/linux/ubuntu/ intrepid/
>>
>> On an "apt-get update" you get this:
>>
>> W: GPG error: http://www.stats.bris.ac.uk intrepid/ Release: The
>> following signatures were invalid: BADSIG D67FC6EAE2A11821 Vincent
>> Goulet 
>>
>> Whereas if I use another mirror e.g.:
>>
>> deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ intrepid/
>>
>> I don't get such an error.
>>
>> It could be a problem this end but I think it is more likely that
>> something is going wrong with the GPG signing at bristol.
> 
> So please contact the mirror maintainer in Bristol. R-help is pretty
> helpless in that case.
> 
> Uwe Ligges
> 
> 
> 
>> Dan
>>


The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Bristol mirror GPG problem ubuntu repository

2009-05-05 Thread Daniel Brewer
Hello,

I am getting a GPG error with the ubuntu repository at the bristol UK
mirror.

When my source.list has this line:

deb http://www.stats.bris.ac.uk/R/bin/linux/ubuntu/ intrepid/

On an "apt-get update" you get this:

W: GPG error: http://www.stats.bris.ac.uk intrepid/ Release: The
following signatures were invalid: BADSIG D67FC6EAE2A11821 Vincent
Goulet 

Whereas if I use another mirror e.g.:

deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ intrepid/

I don't get such an error.

It could be a problem this end but I think it is more likely that
something is going wrong with the GPG signing at bristol.

Dan

-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Mathematical label in a plot with a percent sign

2009-04-28 Thread Daniel Brewer
That worked great.  Many thanks.

Dan

Gabor Grothendieck wrote:
> Try:
> 
> plot(0, main = ~ x >= 5 * "%")
> 
> 
> On Tue, Apr 28, 2009 at 6:37 AM, Daniel Brewer  
> wrote:
>> Hi,
>>
>> I am trying to produce a plot with an xlabel that reads (x >= 5%) with
>> the >= turned into the correct epression.  I can do this up to the
>> percentage sign by specifiing xlab=expression(x>=5).  Whatever I do to
>> include the % sign as well doesn't seem to work.
>>
>> xlab=bquote(x>=5.("%")) almost works but includes brackets.
>>
>> Anyonw know how to solve this one
>>
>> Dan
>>
>> PS I am running R 2.9.0
>>
>> --
>> **
>> Daniel Brewer, Ph.D.
>>
>> Institute of Cancer Research
>> Molecular Carcinogenesis
>> Email: daniel.bre...@icr.ac.uk
>> **
>>
>> The Institute of Cancer Research: Royal Cancer Hospital, a charitable 
>> Company Limited by Guarantee, Registered in England under Company No. 534147 
>> with its Registered Office at 123 Old Brompton Road, London SW7 3RP.
>>
>> This e-mail message is confidential and for use by the a...{{dropped:2}}
>>
>> __
>> 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.
>>

-- 
**

Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom

Tel: +44 (0) 20 8722 4109

**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Mathematical label in a plot with a percent sign

2009-04-28 Thread Daniel Brewer
Hi,

I am trying to produce a plot with an xlabel that reads (x >= 5%) with
the >= turned into the correct epression.  I can do this up to the
percentage sign by specifiing xlab=expression(x>=5).  Whatever I do to
include the % sign as well doesn't seem to work.

xlab=bquote(x>=5.("%")) almost works but includes brackets.

Anyonw know how to solve this one

Dan

PS I am running R 2.9.0

-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Does R support [:punct:] in regexps?

2009-04-09 Thread Daniel Brewer
Hello does R support [:punct:] in regular expressions?  I am trying to
strip all regular expressions for a vector of strings.

> x <- c("yoda-yoda","billy!")
> gsub("/[:punct:]/","",x)
[1] "yoda-yoda" "billy!"

Thanks

Dan
-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Collapse data matrix with extra info separated by commas

2009-04-06 Thread Daniel Brewer
Hello,

I would like to reshape my data for presentation purposes from something
like this:
> test <-
data.frame(a=c("A","A","A","A","B","B","B"),b=c(1,1,2,2,1,1,1),c=1:7)
> test
  a b c
1 A 1 1
2 A 1 2
3 A 2 3
4 A 2 4
5 B 1 5
6 B 1 6
7 B 1 7

to something like this:
  a b c
1 A 1 1,2
3 A 2 3,4
5 B 1 5,6,7

This seems to be the sort of the thing that the reshape library should
be able to do, but I just can't work out how to do it.

Many thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Best way to turn a list into a data.frame

2009-04-06 Thread Daniel Brewer
Thanks thats marvellous.  Does the trick beautifully.

Dan

hadley wickham wrote:
> On Mon, Apr 6, 2009 at 8:49 AM, Daniel Brewer  wrote:
>> Hello,
>>
>> What is the best way to turn a list into a data.frame?
>>
>> I have a list with something like:
>> $`3845`
>>  [1] "04010" "04012" "04360"
>>
>> $`1029`
>> [1] "04110" "04115"
>>
>> And I would like to get a data frame like the following:
>>
>> 3845 "04010"
>> 3845 "04012"
>> 3845 "04360"
>> 1029 "04110"
>> 1029 "04115"
>>
>> Any ideas?
> 
> l <- list("3845" = c("a", "b", "c"), "1029" = c("d", "e","f"))
> 
> libary(reshape)
> melt(l)
> 
> Hadley
> 

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Best way to turn a list into a data.frame

2009-04-06 Thread Daniel Brewer
Hello,

What is the best way to turn a list into a data.frame?

I have a list with something like:
$`3845`
 [1] "04010" "04012" "04360"

$`1029`
[1] "04110" "04115"

And I would like to get a data frame like the following:

3845 "04010"
3845 "04012"
3845 "04360"
1029 "04110"
1029 "04115"

Any ideas?

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Can no longer use resize graphics X windows

2009-03-02 Thread Daniel Brewer
Hi,

I use the ubuntu deb packages for R.  In previous versions of R I could
resize the graphics windows by dragging the bottom corner, but now I
can't.  Anyone got any idea why this has happened and whether it is
possible to change it back?

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Use SOCKS proxy

2009-01-29 Thread Daniel Brewer
Hi,

Is there anyway to set up R so that it uses a SOCKS proxy in Linux? I am
getting some strange issues with the Institute's new web filtering
system and want to be able to test whether a problem I have with the
biomaRt package is caused by it.

Many thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Memory issue?

2009-01-27 Thread Daniel Brewer
I have a script that sometimes produces the following error:

Error in assign(".target", met...@target, envir = envir) :
  formal argument "envir" matched by multiple actual arguments

Do you think this is a memory issue?  I don't know what else it could be
as it doesn't always occur even if the script is run with exactly the
same data.

Does rm() actually free up memory?

Thanks

Dan

-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Stacked barplot with two stacked bars besides each other

2009-01-20 Thread Daniel Brewer
Thanks Henrique.  Unfortunately, that gets us a step closer but it fails
to stack the individual bars, so instead of having a total of 10 for
each bar you get 7, 8, 9 & 5 (i.e. the largest for each var sample
pair).  I tried adding the stack=T option, but that stacks all of each
sample and you are left with two bars.  Any more ideas?

Appreciate your help

Dan

Henrique Dallazuanna wrote:
> One option is to use lattice package:
> 
> library(lattice)
> newVar <- cbind(stack(rbind(var1, var2)), Var = rep(c("var1", "var2"),
> each = 2))
> barchart(values ~ ind, groups = Var, data = newVar)
> 
> 
> On Tue, Jan 20, 2009 at 9:03 AM, Daniel Brewer  <mailto:daniel.bre...@icr.ac.uk>> wrote:
> 
> Thanks.
> That is definitely in the right direction, but firstly I would like
> yoda1:var1 next to yoda1:var2, not as currently yoda1:var1, yoda2:var1,
> yoda1:var2, yoda2:var2.  Additionally, I would like the gap between
> samples to be greater than the gap between variables.
> 
> Many thanks
> 
> Dan
> 
> Henrique Dallazuanna wrote:
> > Try this:
> >
> > barplot(cbind(as.matrix(var1), as.matrix(var2)), names.arg =
> LETTERS[1:4])
> >
> > On Tue, Jan 20, 2009 at 8:28 AM, Daniel Brewer
> mailto:daniel.bre...@icr.ac.uk>
> > <mailto:daniel.bre...@icr.ac.uk <mailto:daniel.bre...@icr.ac.uk>>>
> wrote:
> >
> > Hi,
> >
> > I have a particular barplot I would like to generate, but I am
> having
> > trouble getting it to work.  What I would like is in effect
> two barplots
> >  with stacked bars merged into one.  For example,  I have two
> samples
> > (yoda1,yoda2) on which I measure whether two variables
> (var1,var2) are
> > present or absent for a number of measurements on that sample.
> >
> > > var1 <- data.frame(yoda1=c(3,7), yoda2=c(1,9))
> > > var2 <- data.frame(yoda1=c(8,2), yoda2=c(5,5))
> >
> > For each variable I can plot a barplot
> >
> > > barplot(as.matrix(var1))
> > > barplot(as.matrix(var2))
> >
> > I would like to join these together, so that for each sample
> there are
> > two stacked bars next to each other, one for var1 and the
> other for
> > var2.  I was thinking something like:
> >
> > > barplot(list(as.matrix(var1),as.matrix(var2)))
> >
> > would work, but it didn't.
> >
> > Any suggestions you could make would be great.
> >
> > Dan

-- 
**

Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom

Tel: +44 (0) 20 8722 4109

Email: daniel.bre...@icr.ac.uk

**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Stacked barplot with two stacked bars besides each other

2009-01-20 Thread Daniel Brewer
Thanks.
That is definitely in the right direction, but firstly I would like
yoda1:var1 next to yoda1:var2, not as currently yoda1:var1, yoda2:var1,
yoda1:var2, yoda2:var2.  Additionally, I would like the gap between
samples to be greater than the gap between variables.

Many thanks

Dan

Henrique Dallazuanna wrote:
> Try this:
> 
> barplot(cbind(as.matrix(var1), as.matrix(var2)), names.arg = LETTERS[1:4])
> 
> On Tue, Jan 20, 2009 at 8:28 AM, Daniel Brewer  <mailto:daniel.bre...@icr.ac.uk>> wrote:
> 
> Hi,
> 
> I have a particular barplot I would like to generate, but I am having
> trouble getting it to work.  What I would like is in effect two barplots
>  with stacked bars merged into one.  For example,  I have two samples
> (yoda1,yoda2) on which I measure whether two variables (var1,var2) are
> present or absent for a number of measurements on that sample.
> 
> > var1 <- data.frame(yoda1=c(3,7), yoda2=c(1,9))
> > var2 <- data.frame(yoda1=c(8,2), yoda2=c(5,5))
> 
> For each variable I can plot a barplot
> 
> > barplot(as.matrix(var1))
> > barplot(as.matrix(var2))
> 
> I would like to join these together, so that for each sample there are
> two stacked bars next to each other, one for var1 and the other for
> var2.  I was thinking something like:
> 
> > barplot(list(as.matrix(var1),as.matrix(var2)))
> 
> would work, but it didn't.
> 
> Any suggestions you could make would be great.
> 
> Dan


-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Stacked barplot with two stacked bars besides each other

2009-01-20 Thread Daniel Brewer
Hi,

I have a particular barplot I would like to generate, but I am having
trouble getting it to work.  What I would like is in effect two barplots
 with stacked bars merged into one.  For example,  I have two samples
(yoda1,yoda2) on which I measure whether two variables (var1,var2) are
present or absent for a number of measurements on that sample.

> var1 <- data.frame(yoda1=c(3,7), yoda2=c(1,9))
> var2 <- data.frame(yoda1=c(8,2), yoda2=c(5,5))

For each variable I can plot a barplot

> barplot(as.matrix(var1))
> barplot(as.matrix(var2))

I would like to join these together, so that for each sample there are
two stacked bars next to each other, one for var1 and the other for
var2.  I was thinking something like:

> barplot(list(as.matrix(var1),as.matrix(var2)))

would work, but it didn't.

Any suggestions you could make would be great.

Dan

-- 
******
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] pwr.prop.test and continuity correction

2008-12-16 Thread Daniel Brewer
Hi,

I am trying to sort out a discrepancy between power calculations results
between me and another statistician.  I use R but I am not sure what she
uses.  It is on the proportions test and so I have been using
pwr.prop.test.  I think I have tracked the problem down to pwr.prop.test
not using the continuity correction for the test (I did this by using
the java applet from
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/power.prop.test.html).

So I was wondering whether:
1) Someone could confirm that pwr.prop.test does not use a continuity
correction in its calculation.
2) Someone could tell me either how to use pwr.prop.test or another
function to get the power of a prop.test with continuity correction.
The reason I want this is that I would normally apply the correction
when I actually used the test.

Many thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] group by quantiles

2008-11-18 Thread Daniel Brewer
Hello,

I was just wondering whether there is a quick way to divide a vector of
data into four groups defined by the quantiles?
i.e.
0-25%
25-50%
50-75%
75-100%

Many thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Returning a vector from by

2008-11-03 Thread Daniel Brewer
Hello,

I am trying to return a vector from a simply by but I cannot get it
working, even using simplify=TRUE.

res <- data.frame(ID=c("a","a","a","b","b"),Score=c(0,1,2,0,1))
yoda <- by(res$Score,res$ID,max,simplify=T)
class(yoda)
[1] "by"

I would like it to return a vector with the names as the ID column.  The
only way I could work out how to do this was

result <- as.vector(yoda)
names(result) <- names(yoda)
result
a b
2 1

Is there a better way?

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] pwr.2p2n.test when the ratio of n1/n2 is known

2008-10-24 Thread Daniel Brewer
Hi,

I am trying to do a power calculation for a difference in proportions
test where I want to estimate the sample size required.  I know (well
estimate) that group one (n1) is 10% of the population and group 2 (n2)
is 90% of the population.  I know the effect size (h).  pwr.2p2n.test
only allows one variable to be left null whereas I would like both n1
and n2 to be determined where I know there relative proportions.  Any
ideas how to do this?  Is there a different function?

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Capturing coxph warnings and errors

2008-06-18 Thread Daniel Brewer
Hi,

I have enclosed the data load("coxtest.rdata") to get it into R.  Here
is the command line to produce the error

coxph(Surv(RecFollowUpTime,Rec)~values,data=test)

As you can see the values are almost all the same value, which is
probably causing the problem.

Dan

Terry Therneau wrote:
> Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
>   NA/NaN/Inf in foreign function call (arg 6)
> In addition: Warning message:
> In fitter(X, Y, strats, offset, init, control, weights = weights,  :
>   Ran out of iterations and did not converge
> 
> ---
> 
>   The warning message could be ignored.  However, I am very interested in the 
> error message; it is one I have not seen before.  If you could recreate the 
> data 
> set that produces it and send it to be that would be useful.
>   
>   Terry Therneau
>   (author of coxph)
>   
> 

-- 
**********
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**


The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addressee only.  If the 
message is received by anyone other than the addressee, please return the 
message to the sender by replying to it and then delete the message from your 
computer and network.__
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] Capturing coxph warnings and errors

2008-06-17 Thread Daniel Brewer
Hi,

I have a script that takes a subset of genes on a microarray and tries
to fit a coxph model to the expression values for each gene.  This seems
to work fine but in some cases it produces warnings and/or errors.

For example:
Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
  NA/NaN/Inf in foreign function call (arg 6)
In addition: Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights,  :
  Ran out of iterations and did not converge

In this situation I would like to:
1) Deal with it so that it the scripts result data.frame the p value etc
are set to NA.
2) Suppress the Error and Warning messages

What is the best way to do this?

Thanks

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Ancova: formula with a common intercept

2008-06-02 Thread Daniel Brewer
I have some data with two categorises plus/minus (p53) and a particular
time (Time) and the outcome is a continuous vairable (Result).  I set up
a maximum model.
ancova <- lm(Result~Time*p53)
> summary(ancova)
..
Coefficients:
 Estimate Std. Error t value Pr(>|t|)
(Intercept)   0.059190.55646   0.1060.916
Time -0.021340.01785  -1.1950.241
p53plus   0.170590.78696   0.2170.830
Time:p53plus  0.118870.02524   4.709 4.62e-05 ***
..

>From a plot of the data and the result of the linear model it looks like
the two categories share the same intercept.  How do I define this?  I
tried this:
> ancova2<-update(ancova,~.-1)
> summary(ancova2)
Call:
lm(formula = Result ~ Time + p53 + Time:p53 - 1)
..
Coefficients:
 Estimate Std. Error t value Pr(>|t|)
Time -0.021340.01785  -1.1950.241
p53minus  0.059190.55646   0.1060.916
p53plus   0.229770.55646   0.4130.682
Time:p53plus  0.118870.02524   4.709 4.62e-05 ***

But I do not think that is doing what I want.

Many thanks
-- 
**********
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] cpower and censoring

2008-05-08 Thread Daniel Brewer
I would like to do some power estimations for a log-rank two sample test
and cpower seems to fit the bill.  I am getting confused though by the
man page and what the arguments actually mean. I am also not sure
whether cpower takes into account censoring or not.

Could anyone provide a simple example of how I would get the power for a
set control/non-control clinical trial where censoring occurs at an
estimated rate with an estimated drop out rate.

Quite confused about this.

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Adding name labels to x-axis of matplot

2008-03-26 Thread Daniel Brewer
Hello,

I have a gene expression matrix with columns being samples and rows
being genes.  I would like to display the expression values for each
gene.  I have two groups which I colour differently.  The aim is to see
if there is any difference between the two groups consistently across genes.

So the following works well:

matplot(as.matrix(nonormexpr),pch=16,col=c(rep(1,length(left)),rep(2,length(right))),cex=0.4)

The only thing is that the x-axis has numbers 1 ... 10, whereas I would
like to give them the names of the genes.  I have tried using the
"labels" parameter but I get:

Error in axis(side, at, as.graphicsAnnot(labels), tick, line, pos,
outer,  :
'labels' is supplied and not 'at'

Any ideas?  Is there are a more appropriate plot type?

-- 
******
Daniel Brewer, Ph.D.
Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Equal vertical spaced labels on plot with log="y"

2008-03-20 Thread Daniel Brewer
Hello,

I have a series of labels that I want to place on a plot with a log
scale y axis.  I want these labels to be equally spaced vertically as
seen on the plot.

I have been trying this:

ylab <- 160 - log2(1:length(labels))

but that does not seem to work (where 160 is basically the top of the plot).

Any ideas?

Thanks

-- 
**
Daniel Brewer, Ph.D.
Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Best way to strsplit a column

2008-03-04 Thread Daniel Brewer
Hello,

I have a data.frame with a column that I would like to split into based 
around the delimiter ":".  This is a useful feature in Excel.  I cannot 
work out the best way to do it in R.  I am sure you need to use 
strsplit, but that returns a list.  The problem is that some values in 
the column do not contain a ":" so should have a "NA" in the second 
column of the result, and this makes doing an unlist a non-starter.

Any ideas?

Many thanks

Daniel Brewer

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Log rank test power calculations

2008-01-31 Thread Daniel Brewer
Does anyone have any ideas how I could do a power calculation for a log
rank test.  I would like to know what the suggested sample sizes would
be to pick a difference when the control to active are in a ratio of 80%
to 20%.

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: [EMAIL PROTECTED]
**


The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] grep with "|" character

2007-10-23 Thread Daniel Brewer
Hi,

I am having a problem searching for the "|" character in a string.

> grep("|",stringvector)
Gives all the strings in a vector but when I try to escape it
> grep("\|",stringvector)
It comes up with the error
Warning messages:
1: '\|' is an unrecognized escape in a character string
2: unrecognized escape removed from "\|"


Anyone know how to solve this?

Dan

-- 
**********
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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 expression for Italics and object evaluation in plot title

2007-10-10 Thread Daniel Brewer
Thanks.  That works great if I do this:
title(sub=bquote(italic(p)-value == .(p.val)))

But if I add text to the beginning e.g.
title(sub=bquote(Log rank test italic(p)-value == .(p.val)))
I get an error message saying,
Error: syntax error, unexpected SYMBOL, expecting ',' in
"title(sub=bquote(Log rank"

Dan

Gabor Grothendieck wrote:
> Try bquote as in:
> 
> http://tolstoy.newcastle.edu.au/R/e2/help/07/09/26353.html
> 
> On 10/10/07, Daniel Brewer <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I am trying to get a title on a plot that contains both some formatting
>> and prints the value of an object.  What I have been using to get the
>> italics is:
>>
>> title(sub=expression(paste("Log-rank test ",italic("p"),"-value = ",p.val)))
>>
>> But this prints "p.val" rather than the object value.  I have tried
>> various combinations of paste and expression but it seems that to get
>> the italic expression function has to be called first.
>>
>> Any ideas on how to get round this problem?
>>
>> Thanks
>>
>> Dan
-- 
**
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Using expression for Italics and object evaluation in plot title

2007-10-10 Thread Daniel Brewer
Hi,

I am trying to get a title on a plot that contains both some formatting
and prints the value of an object.  What I have been using to get the
italics is:

title(sub=expression(paste("Log-rank test ",italic("p"),"-value = ",p.val)))

But this prints "p.val" rather than the object value.  I have tried
various combinations of paste and expression but it seems that to get
the italic expression function has to be called first.

Any ideas on how to get round this problem?

Thanks

Dan
-- 
**********
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
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] Calculate difference between dates in years

2007-09-24 Thread Daniel Brewer
Hello,

I would like to be able to calculate the age of someone at a particular
date.  Both dates are date objects.  Here is what I have come up with:

floor(as.numeric(sampleInfo$Date.of.DIAGNOSIS-sampleInfo$Date.of.birth)/365.25)

Is this the best approach? or is there an inbuilt function?  I have
looked at difftime but that does not seem to allow output in years.

Many thanks

Dan

-- 
**
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addre...{{dropped}}

__
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] Cox regression and p-values

2007-09-18 Thread Daniel Brewer
Hello,
I might be barking up the wrong tree here, but I want to make sure I
have a full understanding of this.  What I would like to know is what
tests are performed to give the p-values for each variable in the table
that is the result of coxph regression when the variables are
categorical only.

More specifically, when expected counts are less than 5 is the Fisher's
exact test used instead of the Chi^2 test?

Many thanks
Dan
-- 
**
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addre...{{dropped}}

__
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.