Hi Everyone, I have data in a long format e.g. there is one row per patient but each follow-up appointment is included in the row. So, a snippet of the data looks like this: TrialNo Drug Sex Rand Adate1 Date1 Dose1 Time1 Adate2 Date2 Dose2 Time2 B1001029 LTG M 15719 30/04/2003 15825 150 106 29/08/2003 15946 200 227 B1117003 LTG M 15734 30/04/2003 15825 200 91 03/09/2003 15951 250 217 B138015 LTG M 14923 06/02/2001 15012 225 89 08/05/2001 15103 300 180 B112003 TPM F 14914 15/01/2001 14990 60 76 05/03/2001 15039 100 125 Of course, not everyone has the same number of follow-up appointments and so there may be some column entries that are NAs. What I'd like to do is a dose profile i.e. a plot of time on the x-axis agaisnt dose on the y-axis for each patient ideally colouring lines according to drug. Does anyone know how I can do this? Someone at work has suggested that I use plot and then loess.smooth but I don't really know what to do. Thank you very much for your help, Laura [[alternative HTML version deleted]]
Why don't you ask your "someone at work" to help, as you appear to have local resources handy? -- Bert Gunter -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Laura Bonnett Sent: Tuesday, October 28, 2008 9:33 AM To: r-help at r-project.org Subject: [R] Dose Profile Hi Everyone, I have data in a long format e.g. there is one row per patient but each follow-up appointment is included in the row. So, a snippet of the data looks like this: TrialNo Drug Sex Rand Adate1 Date1 Dose1 Time1 Adate2 Date2 Dose2 Time2 B1001029 LTG M 15719 30/04/2003 15825 150 106 29/08/2003 15946 200 227 B1117003 LTG M 15734 30/04/2003 15825 200 91 03/09/2003 15951 250 217 B138015 LTG M 14923 06/02/2001 15012 225 89 08/05/2001 15103 300 180 B112003 TPM F 14914 15/01/2001 14990 60 76 05/03/2001 15039 100 125 Of course, not everyone has the same number of follow-up appointments and so there may be some column entries that are NAs. What I'd like to do is a dose profile i.e. a plot of time on the x-axis agaisnt dose on the y-axis for each patient ideally colouring lines according to drug. Does anyone know how I can do this? Someone at work has suggested that I use plot and then loess.smooth but I don't really know what to do. Thank you very much for your help, Laura [[alternative HTML version deleted]] ______________________________________________ R-help at 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.
Laura Bonnett wrote:> Hi Everyone, > > I have data in a long format e.g. there is one row per patient but each > follow-up appointment is included in the row. So, a snippet of the data > looks like this: > TrialNo Drug Sex Rand Adate1 Date1 Dose1 Time1 Adate2 Date2 Dose2 > Time2 B1001029 LTG M 15719 30/04/2003 15825 150 106 29/08/2003 15946 200 > 227 B1117003 LTG M 15734 30/04/2003 15825 200 91 03/09/2003 15951 250 217 > B138015 LTG M 14923 06/02/2001 15012 225 89 08/05/2001 15103 300 180 > B112003 TPM F 14914 15/01/2001 14990 60 76 05/03/2001 15039 100 125 > Of course, not everyone has the same number of follow-up appointments and so > there may be some column entries that are NAs. > > What I'd like to do is a dose profile i.e. a plot of time on the x-axis > agaisnt dose on the y-axis for each patient ideally colouring lines > according to drug. Does anyone know how I can do this? Someone at work has > suggested that I use plot and then loess.smooth but I don't really know what > to do. > >Hi Laura, You can get a basic plot like this: matplot(rbind(lbonnett$Time1,lbonnett$Time2), rbind(lbonnett$Dose1,lbonnett$Dose2),type="l", col=lbonnett$Drug,lty=1) As you can see by running this, you will get a line for each patient, with the color of each line determined by the drug (you can select different colors, I was just being lazy). The problem you are likely to face is that there will be gaps in the lines if you have NAs. You can rejig matplot or write a similar function to get around this so that the lines are just drawn across the gaps if that is what you want. Jim
you 'll may be interested in the drc package (a quick start would be http://www.bioassay.dk), where you get some nice plots and can fit appropriate models as well - very handy if you want to estimate effective doses. hth. Laura Bonnett schrieb:> Hi Everyone, > > I have data in a long format e.g. there is one row per patient but each > follow-up appointment is included in the row. So, a snippet of the data > looks like this: > TrialNo Drug Sex Rand Adate1 Date1 Dose1 Time1 Adate2 Date2 Dose2 > Time2 B1001029 LTG M 15719 30/04/2003 15825 150 106 29/08/2003 15946 200 > 227 B1117003 LTG M 15734 30/04/2003 15825 200 91 03/09/2003 15951 250 217 > B138015 LTG M 14923 06/02/2001 15012 225 89 08/05/2001 15103 300 180 > B112003 TPM F 14914 15/01/2001 14990 60 76 05/03/2001 15039 100 125 > Of course, not everyone has the same number of follow-up appointments and so > there may be some column entries that are NAs. > > What I'd like to do is a dose profile i.e. a plot of time on the x-axis > agaisnt dose on the y-axis for each patient ideally colouring lines > according to drug. Does anyone know how I can do this? Someone at work has > suggested that I use plot and then loess.smooth but I don't really know what > to do. > > Thank you very much for your help, > > Laura > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790
Seemingly Similar Threads
- scale.default gives an incorrect error message when is.numeric() fails on a sparse row matrix (dgeMatrix)
- kernel: dahdi: Master changed to TE2/0/2 --- Is a normal message
- Anyone using gr303?
- Can't get the correct order from melt.data.frame of reshape library.
- Survfit when new data has only 1 row of data