[R] A better scales::dollar() ?

2019-12-06 Thread POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) via R-help
I'm writing a quite large document in Rmarkdown which has financial data in it. I format that data using scales::dollar() currently something like this: > > require (scales) > x = 10 > cat (dollar (x, prefix ="£", big.mark=",")) £100,000 But actually, I'd quite like to get £100k out in

Re: [R] I can't get seq to behave how I think it should

2019-01-17 Thread POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) via R-help
it from FAQ 7.31. Cheers Petr > -Original Message- > From: POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION > TRUST) > Sent: Thursday, January 17, 2019 2:56 PM > To: PIKAL Petr ; Ben Tupper > > Cc: r-help@r-project.org > Subject: RE: [R] I can't get s

Re: [R] I can't get seq to behave how I think it should

2019-01-17 Thread POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) via R-help
Tupper > Sent: Thursday, January 17, 2019 2:43 PM > To: POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) > > Cc: r-help@r-project.org > Subject: Re: [R] I can't get seq to behave how I think it should > > Hi, > > This looks like a floating point real

[R] I can't get seq to behave how I think it should

2019-01-17 Thread POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) via R-help
I am using seq with the expression seq(1.4, 2.1, by=0.001) to create a sequence of references from 1.4 to 2.1 in 0.001 increments. They appear to be created correctly. They have a related pair of data which for the purposes of this we will call val. I'm interested in the content on the row

[R] odfWeave - A loop of the "same" data

2017-06-01 Thread POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) via R-help
Before I go and do this another way - can I check if anyone has a way of looping through data in odfWeave (or possibly sweave) to do a repeating analysis on subsets of data? For simplicity lets use mtcars dataset in R to explain. Dataset looks like this: > mtcars mpg cyl disp

Re: [R] ?currency challenge ?knapsack challenge ?probabilities

2015-12-28 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
planation of the problem, to basically say... has anyone come across a function in R that might simplify this? Sent from TypeMail<http://www.typeapp.com/r> On 27 Dec 2015, at 08:00, "Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)" <calum.polw...@nhs.net<m

[R] ?currency challenge ?knapsack challenge ?probabilities

2015-12-27 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
from TypeMail<http://www.typeapp.com/r> On 27 Dec 2015, at 08:00, "Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)" <calum.polw...@nhs.net<mailto:calum.p

[R] Not sure this is something R could do but it feels like it should be.

2013-06-06 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
Some colleagues nationally have developed a system which means they can pick the optimal sets of doses for a drug. The system could apply to a number of drugs. But the actual doses might vary. To try and explain this in terms that the average Joe on the street might understand if you have

[R] Comparing two different 'survival' events for the same subject using survdiff?

2013-04-29 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
I have a dataset which for the sake of simplicity has two endpoints. We would like to test if two different end-points have the same eventual meaning. To try and take an example that people might understand better: Lets assume we had a group of subjects who all received a treatment. The

Re: [R] Comparing two different 'survival' events for the same subject using survdiff?

2013-04-29 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
that the distributions are different is not proof that the distributions are equal. Yes absolutely - however I'm half expecting to detect a difference and so then dismiss using A as a surrogate of B... Thanks -Original Message- From: Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS

[R] matchit - can I weight the parameters?

2012-06-19 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
This may be a really obvious question but I just can't figure out how to do it. I have a small dataset that I am trying to compare to some controls. It is essential that the controls are matched on Cancer Stage (a numerical factor between 1 and 4), and then ideally on Age (integer), Gender

Re: [R] Kaplan Meier - not for dates

2011-11-07 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
2. The answer will be wrong. The reason is that the censoring occurs on a time scale, not a $ scale: you don't stop observing someone because total cost hits a threshold, but because calendar time does. The KM routines assume that the censoring process and the event process are on the

Re: [R] Kaplan Meier - not for dates

2011-11-07 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
2. The answer will be wrong. The reason is that the censoring occurs on a time scale, not a $ scale: you don't stop observing someone because total cost hits a threshold, but because calendar time does. The KM routines assume that the censoring process and the event process are on the

Re: [R] Kaplan Meier - not for dates

2011-11-03 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
November 2011 19:55 To: Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST); r-help@r-project.org Subject: RE: Kaplan Meier - not for dates I think it really depends on what your event of interest is. If your event is that the patient got better and left treatment then I think

[R] Kaplan Meier - not for dates

2011-10-31 Thread Polwart Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST)
I have some data which is censored and I want to determine the median. Its actually cost data for a cohort of patients, many of whom are still on treatment and so are censored. I can do the same sort of analysis for a survival curve and get the median survival... ...but can I just use the

[R] Non-unique Values

2010-05-25 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I might be missing something really obvious, but is there an easy way to locate all non-unique values in a data frame? Example mydata - numeric() mydata$id - 0:8 mydata$unique - c(1:5, 1:4) mydata$result - c(1:3, 1:3, 1:3) mydata $id [1] 0 1 2 3 4 5 6 7 8 $unique [1] 1 2 3 4 5 1 2 3 4

Re: [R] Exporting PDF

2010-04-20 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I run the script and it exports a PDF called version 1. I want it to check if version 1 already exists. If so, then I want the new graphs to be exported as version 2, and so on. Is it possible to do it in R? Someone may know a way. However its certainly possible to execute a command in

[R] odfWeave - merged table cells, and adding information like totals and p-values

2010-02-21 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I'm hoping I'm missing some (probably fundamental basic process) which might make my life easier! Lets assume I have a 3 column table summarizing results from a trial from three arms (Arm A, B and C). For each arm there will be a number of pieces of information to report. The simplest example

[R] Contingency Table - output to odfWeave not working for matrix

2010-02-20 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Hi guys I'm hoping someone can help me with this. It should be easy but it seems to get stuck for no obvious reason! I am trying to set a report up in odfWeave so that we can re-run the same analysis at 3 time points as the data matures and provide an 'instant' report. To simplify the

Re: [R] Contingency Table - output to odfWeave not working for matrix

2010-02-20 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Solved my own problem by using: odfTable.matrix( as.matrix ( with (mydata, table (site_id, reaction)) ) ) This message may contain confidential information. If

[R] ?OT: Probabilistic Simulation

2009-12-18 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Sorry this may well be defined as Off Topic. I apologize in advance. I am interested in performing what I think would be a probabilistic sensitivity simulation. I've done some crude ones before in excel but I'm wondering if R can help me do it more effectively? I have a set of theoretical

Re: [R] Winbugs under R's error message

2009-10-03 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
LinZhongjun wrote: I ran Winbugs under R. I could get the results, but I kept getting the error messages: Error in file(con, wb) : cannot open the connection In addition: Warning messages: 1: In file.create(to[okay]) :

Re: [R] How to set default plotting colors by treatment?

2009-09-14 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
# I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling:

[R] Exporting Numerous Graphs

2009-09-14 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Pretty sure PNG can only cope with

Re: [R] How to set default plotting colors by treatment?

2009-09-14 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
col=c(blue,red)mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... In that case I'd try something like: myplot - function(..., tmnt) { plot(..., pch=19,

[R] Is there an equivalent of echo

2009-09-14 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Sorry I'm having one of those moments where I can't find the answer but I bet its obvious... I'm outputting my results to a file using sink() Is there a command simillar to php's echo command that would allow me to add some text to that file ie: dataFr$a = 1:10 dataFr$b = 2*1:10 sink

[R] Obtaining value of median survival for survfit function to use in calculation

2009-09-08 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Hi, I'm sure this should be simple but I can't figure it out! I want to get the median survival calculated by the survfit function and use the value rather than just be able to print it. Something like this: library(survival) data(lung) lung.byPS = survfit(Surv (time, status) ~ ph.ecog,

Re: [R] Partykit Document

2009-08-25 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Example, data(GlaucomaM, package = ipred) is accepted. Now instead of GlaucomaM, I need to give my own data. But the data format for GlaucomaM is not given. So how can I know that? Not familliar with the packages at all but if you simply enter: data (GlaucomaM, package=ipred) GlaucomaM All

[R] forest (meta) editing text

2009-08-22 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
OK - I've been doing some work on getting a forest plot or two together for a sub-group analaysis. Thats the crucial thing - because its a sub-group analysis rather than a meta-analsysis and all the forest (meta) and forestplot (rmeta) instructions assume you are doing a meta-analysis. I

Re: [R] PowerCut Killed R - is my code retrievable?

2009-08-20 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Rolf Write: If you've been cut-and-pasting from a text editor, then your commands *might* be in the file .Rhistory. Unfortunately this history gets saved only when you exit R (and by default only when you also say ``yes'' to saving the workspace) or if you explicitly savehistory(). Was

[R] PowerCut Killed R - is my code retrievable?

2009-08-19 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I've been tweaking code for several days on and off in R, cut and pasting in from a text editor (I just leave them open all the time). I think I got something that was usable but then a powersurge tripped the fuses and unfortunately the machine I was working on doesn't have a UPS. Does R hold

[R] Odd results with Chi-square test. (Not an R problem, but general statistics, I think)

2009-08-18 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I'm far from an expert on stats but what I think you are saying is if you try and compare Baseline with Version 3 you don't think your p-value is as good as version 1 and 2. I'm not 100% sure you are meant to do that with p-values but I'll let someone else comment on that!.

[R] Using 'field names' of a data.frame in a function

2009-08-06 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I may be doing this wrong! but I have a function which I have simplified a lot below. I want to pass some 'field names' of a data-frame to the function for it to then do some manipulation of. Here's my code: #build a simple dataset mydataset = data.frame (

Re: [R] Superscripts and rounding

2009-07-30 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Duh! did it again! the variables need str in front of them don't they!! sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s Gross Area %s km\UB2 - Effective Area %s km\UB2 ', round( str[['metadata']][['latitude']], digits=4 ), round( str[['metadata']][['longitude']], digits

Re: [R] Summarising Data for Forrest Plots

2009-07-30 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Ah, I think I see what you want. Try this on each pair of exclusive sets: n_total-dim(mydataset)[1] under65-mydataset$age = 65 n_under65-sum(under65) under65row-c(sum(mydataset$dose[under65] == FD), sum(mydataset$dose[under65] == RD), sum(mydataset$vitalstatus[under65] == dead

Re: [R] Summarising Data for Forrest Plots

2009-07-30 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Ah, I think I see what you want. Try this on each pair of exclusive sets: snip Then under65row and over65row should be the first two rows of your result. Can't test this at the moment, but I don't think it's too far wrong. I knew this shouldn't need so much work ;-) Not cracked it yet -

Re: [R] Summarising Data for Forrest Plots

2009-07-29 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Are n.FD and n.RD the number of people who received the full/reduced dose Yes - but I don't have the data structured like that YET - thats what I want to get to because thats what forest plot seems to be wanting. and surv.FD and surv.RD the number of people that survived? Mmm... was more

Re: [R] Summarising Data for Forrest Plots

2009-07-29 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
What I want to do is do a forrest (forest) plot for subgroups within my single dataset as a test of heterogeniety. I have a dataset who received either full dose(FD) or reduced dose(RD) treatment, and a number of characteristics about those subjects: age, sex, renal function, weight,

Re: [R] Superscripts and rounding

2009-07-29 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
library(RODBC) library(HYDAT) You will need to install HYDAT (the zip file) from http://www.geog.ubc.ca/~rdmoore/Rcode.htm Below is my current code - which works. The [[]] is the way i am accessing the columns from the data frame. thanks again for all your help # load HYDAT data

Re: [R] Superscripts and rounding

2009-07-28 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I'm anything but an expert in R however if I'm labeling a graph axis with a superscript I have tended to use: plot (x , y , xlab = expression (label^2)) But when you try to have more than one superscript it fails. Assuming you are in a UTF8 location (Western Europe) you could try: plot (x

[R] Summarising Data for Forrest Plots

2009-07-28 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
I tried to post this a few times last week and it seems to have got stuck somehow so I'm trying from a different email in the hope that works. If somehow this has appeared on the list 20 tiems and I never saw any of them I apologize ;-) I'm basically an R-newbie. But I am VERY computer

Re: [R] Superscripts and rounding

2009-07-28 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
So the issue is something to do with the [['xxx']] construction of your data. Can you explain what thats' all about - as it errors all over the shop when I try using that... You've set me on a mission to find the answer! So I'd really like to recreate a little bit of your data here, and