[R] Plotting question
Hi All, I am plotting different lines in my graph and the problem I have is that if the first plot has smaller y value than the second plot, I will not be able to see the the top part of the graph. I do the following:plot(p1, avg=vertical, lwd=3, col=red, main =all graphs)plot(p2, avg=vertical, lwd=3, col=pink, add = TRUE) where p1 and p2 are the performance measures from the ROCR package. The problem I have is that for the first plot, the max of y axis is 0.3 and for the second plot is 1, but when I am done with plotting, I can not see the top part of the second plot. So, I was wondering if there is any way to have the max of y axis to be 1 so that I can see the top part of the second plot as well too? Thanks a lot,Andra Thanks a lot,Andra [[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] Plotting question
On Sep 8, 2011, at 6:38 PM, Andra Isan wrote: Hi All, I am plotting different lines in my graph and the problem I have is that if the first plot has smaller y value than the second plot, I will not be able to see the the top part of the graph. I do the following:plot(p1, avg=vertical, lwd=3, col=red, main =all graphs)plot(p2, avg=vertical, lwd=3, col=pink, add = TRUE) where p1 and p2 are the performance measures from the ROCR package. The problem I have is that for the first plot, the max of y axis is 0.3 and for the second plot is 1, but when I am done with plotting, I can not see the top part of the second plot. So, I was wondering if there is any way to have the max of y axis to be 1 so that I can see the top part of the second plot as well too? ?plot # the ylim argument -- David Winsemius, MD West Hartford, CT __ 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] Plotting question
Andrew McCulloch wrote: I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? How about having *10* scatterplots + an identical grid in each plot? Try example(coplot) for an idea about it could look (ignore the marginal plots). Of course, do use the lattice or the ggplot2 package, not the coplot function. Too bad you have 10 groups and not 9 (or 12), BTW ... :-/ -- Karl Ove Hufthammer __ 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] Plotting question
Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? If all else fails I can just remove the graph and give them a table of regression coefficients. Thanks. Yours Sincerely Andrew McCulloch __ 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] Plotting question
On 11-08-01 5:44 AM, Andrew McCulloch wrote: Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? Plot digits or letters or other symbols. Duncan Murdoch If all else fails I can just remove the graph and give them a table of regression coefficients. Thanks. Yours Sincerely Andrew McCulloch __ 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] Plotting question
plot(1:10, pch=letters[1:10]) On Mon, Aug 1, 2011 at 4:44 AM, Andrew McCulloch amccu...@yahoo.co.ukwrote: Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? If all else fails I can just remove the graph and give them a table of regression coefficients. Thanks. Yours Sincerely Andrew McCulloch __ 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.
Re: [R] Plotting question
IMHO: On Mon, Aug 1, 2011 at 7:51 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 11-08-01 5:44 AM, Andrew McCulloch wrote: Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? Plot digits or letters or other symbols. Duncan Murdoch No, this does not work. See Cleveland's books (e.g. Visualizing Data). 10 is too many symbols to constantly refer to a legend to keep straight, and digits or letters do not allow you to readily perceive the pattern. (Caveat: If most of the data are only 2 or 3 of the symbols, then these can work). I think the OP's idea of using gray scales was better. I would dispute the reviewer and refer them to appropriate references. Alternatively, thermometer plots (aka filled rectangle plots) would be best. Again, Cleveland's books provide scientific justification rather than merely the (possibly uninformed) aesthetic opinion of a reviewer. Presumably, the journal editor would accept hard data and psychological research in preference to opinions. If all else fails I can just remove the graph and give them a table of regression coefficients. No. I think your attempt to use a graph is a much better way to go. Try to resist poor practices such as just publishing summary statistics. Cheers, Bert Thanks. Yours Sincerely Andrew McCulloch __ 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. -- Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions. -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics __ 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] Plotting question
On 11-08-01 11:48 AM, Bert Gunter wrote: IMHO: On Mon, Aug 1, 2011 at 7:51 AM, Duncan Murdochmurdoch.dun...@gmail.com wrote: On 11-08-01 5:44 AM, Andrew McCulloch wrote: Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? Plot digits or letters or other symbols. Duncan Murdoch No, this does not work. You have amazing perception to know that it doesn't work in Andrew's graph. But then you go on to suggest that sometimes it does, and then suggest using symbols. Obviously you need to see the graph to know what works. If the 10 categories are ordered, then something like thermometer plots would work. If they are grouped into a small number of variations on a small number of groups, then digits or letters combined with shading might work, especially if the groups are well separated, or there are clear patterns. I'd agree with the reviewer than 10 levels of shading is probably too many to distinguish, and I'd agree with you that digits 0-9 in equal quantities in an unstructured scatterplot are probably not a good presentation, but I wouldn't want to give specific advice about plotting a dataset without seeing it. Duncan Murdoch See Cleveland's books (e.g. Visualizing Data). 10 is too many symbols to constantly refer to a legend to keep straight, and digits or letters do not allow you to readily perceive the pattern. (Caveat: If most of the data are only 2 or 3 of the symbols, then these can work). I think the OP's idea of using gray scales was better. I would dispute the reviewer and refer them to appropriate references. Alternatively, thermometer plots (aka filled rectangle plots) would be best. Again, Cleveland's books provide scientific justification rather than merely the (possibly uninformed) aesthetic opinion of a reviewer. Presumably, the journal editor would accept hard data and psychological research in preference to opinions. If all else fails I can just remove the graph and give them a table of regression coefficients. No. I think your attempt to use a graph is a much better way to go. Try to resist poor practices such as just publishing summary statistics. Cheers, Bert Thanks. Yours Sincerely Andrew McCulloch __ 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. __ 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] Plotting question
Well stated, Duncan, and I plead guilty, though I did try to weasel out with caveats. Perhaps I may plead down to a lesser sentence or probation by saying that I was offering what I still believe to be appropriate advice for a general strategy for handling this sort of plotting issue; but that as always, one's mileage may vary depending on the specifics. Extra inline comments below. Cheers, Bert And to return to R, note that any of these options is easy to implement in any of at least 3 different graphics frameworks (base, trellis, and ggplot). So Duncan and I can spar over what we'd like to do without being limited by what software **allows** us to do. On Mon, Aug 1, 2011 at 1:48 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 11-08-01 11:48 AM, Bert Gunter wrote: IMHO: On Mon, Aug 1, 2011 at 7:51 AM, Duncan Murdochmurdoch.dun...@gmail.com wrote: On 11-08-01 5:44 AM, Andrew McCulloch wrote: Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? Plot digits or letters or other symbols. Duncan Murdoch No, this does not work. You have amazing perception to know that it doesn't work in Andrew's graph. But then you go on to suggest that sometimes it does, and then suggest using symbols. Obviously you need to see the graph to know what works. If the 10 categories are ordered, then something like thermometer plots would work. If they are grouped into a small number of variations on a small number of groups, then digits or letters combined with shading might work, especially if the groups are well separated, or there are clear patterns. I'd agree with the reviewer than 10 levels of shading is probably too many to distinguish, But for ordered categories you may not wish to distinguish so much as give an overall gestalt, for which a gray scale with 10 levels could work quite well. So it depends on the specifics of what's being plotted, no? and I'd agree with you that digits 0-9 in equal quantities in an unstructured scatterplot are probably not a good presentation, but I wouldn't want to give specific advice about plotting a dataset without seeing it. Duncan Murdoch See Cleveland's books (e.g. Visualizing Data). 10 is too many symbols to constantly refer to a legend to keep straight, and digits or letters do not allow you to readily perceive the pattern. (Caveat: If most of the data are only 2 or 3 of the symbols, then these can work). I think the OP's idea of using gray scales was better. I would dispute the reviewer and refer them to appropriate references. Alternatively, thermometer plots (aka filled rectangle plots) would be best. Again, Cleveland's books provide scientific justification rather than merely the (possibly uninformed) aesthetic opinion of a reviewer. Presumably, the journal editor would accept hard data and psychological research in preference to opinions. If all else fails I can just remove the graph and give them a table of regression coefficients. No. I think your attempt to use a graph is a much better way to go. Try to resist poor practices such as just publishing summary statistics. Cheers, Bert Thanks. Yours Sincerely Andrew McCulloch __ 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. -- Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions. -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics __ 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] Plotting question
Why can't you simply draw a 3 - D plot. The third variable being categorical can expressed as a bar. Regards, Indrajit From: Andrew McCulloch amccu...@yahoo.co.uk To: r-help@r-project.org Sent: Monday, August 1, 2011 3:14 PM Subject: [R] Plotting question Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x against y and using gray scales to distinguish the level of the categorical variable for each point. It looks ok to me but a journal reviewer says this is not any use. I cannot afford to pay for colour prints. Any ideas on what is the best way to distinguish 10 groups on an xy scatter plot? If all else fails I can just remove the graph and give them a table of regression coefficients. Thanks. Yours Sincerely Andrew McCulloch __ 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.
[R] Plotting Question
Hello, I would like to produce a series of graphs comparing the probability distributions for 8 factors against a continuous metric. The kind of graph I'm hoping to produce would look like the density comparison graphs (library sm) using the function sm.density.compare. However, instead of calculating the density distributions for comparisons, I'd like this comparison to be based on probabilities. An example of the graph I'm seeking can be seen here: http://www.statmethods.net/graphs/density.html (scroll to the bottom and examine the Comparing Groups via Kernel Density). A graph (attached) produced using my data: attach(SoilVegHydro) vegtype.f - factor(Physiogomy) sm.density.compare(meanAnnualDepthAve, vegtype.f, xlab=Mean Annual Depth) # create color fill patterns colfill - c(2:(2+length(levels(vegtype.f legend(locator(1), levels(vegtype.f), fill=colfill) (See attached file: MeanAnnualDepth_Density.png) Thanks Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147attachment: MeanAnnualDepth_Density.png__ 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] Plotting question
Hi I have a data set that needs to be plotted (see below) When I plot it using the simple plot(read_count ~ Cn), I get box plots for the read_count numbers plotted according to Cn. The Cn's on the x-axis are ordered: 1, 100, 1000, 40, 400, 4000... How do I plot so that Cn is plotted on the x-axis in an ascending order: 40, 60, 80, ...1? Thanks for your help. Anjan ID Cn read_count 1 MJ-2000-79 10,000 6876 2 MJ-2000-80 10,000 23440 3 MJ-2000-87 10,000 18787 4 MJ-2000-100 8000 4775 5 MJ-2000-81 8000 1542 6 MJ-2000-82 8000 1550 7 MJ-2000-101 6000 15322 8 MJ-2000-83 6000 7023 9 MJ-2000-84 6000834 10 MJ-2000-102 4000 4216 11 MJ-2000-85 4000 1174 12 MJ-2000-86 4000404 13 MJ-4000-131 1000 1368 14 MJ-4000-132 1000 2219 15 MJ-4000-125800413 16 MJ-4000-133800 2594 17 MJ-4000-127600 3059 18 MJ-4000-134600 1561 19 MJ-4000-142600848 20 MJ-4000-129400182 21 MJ-4000-130400 1410 22 MJ-4000-135400 2713 23 MJ-7000-182100943 24 MJ-8000-184100318 25 MJ-8000-185 80 92 26 MJ-8000-186 80161 27 MJ-8000-188 60158 28 MJ-8000-191 60103 29 MJ-8000-192 40468 30 MJ-8000-193 40432 -- = anjan purkayastha, phd bioinformatics analyst whitehead institute for biomedical research nine cambridge center cambridge, ma 02142 purkayas [at] wi [dot] mit [dot] edu 703.740.6939 [[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] Plotting question
Your data has commas in the numbers causing them to be read in as factors: x - read.table(textConnection( ID Cn read_count + 1 MJ-2000-79 10,000 6876 + 2 MJ-2000-80 10,000 23440 + 3 MJ-2000-87 10,000 18787 + 4 MJ-2000-100 8000 4775 + 5 MJ-2000-81 8000 1542 + 6 MJ-2000-82 8000 1550 + 7 MJ-2000-101 6000 15322 + 8 MJ-2000-83 6000 7023 + 9 MJ-2000-84 6000834 + 10 MJ-2000-102 4000 4216 + 11 MJ-2000-85 4000 1174 + 12 MJ-2000-86 4000404 + 13 MJ-4000-131 1000 1368 + 14 MJ-4000-132 1000 2219 + 15 MJ-4000-125800413 + 16 MJ-4000-133800 2594 + 17 MJ-4000-127600 3059 + 18 MJ-4000-134600 1561 + 19 MJ-4000-142600848 + 20 MJ-4000-129400182 + 21 MJ-4000-130400 1410 + 22 MJ-4000-135400 2713 + 23 MJ-7000-182100943 + 24 MJ-8000-184100318 + 25 MJ-8000-185 80 92 + 26 MJ-8000-186 80161 + 27 MJ-8000-188 60158 + 28 MJ-8000-191 60103 + 29 MJ-8000-192 40468 + 30 MJ-8000-193 40432), header=TRUE) str(x) # notice that the column is a factor; comma is not recognizable in numbers 'data.frame': 30 obs. of 3 variables: $ ID: Factor w/ 30 levels MJ-2000-100,..: 4 5 12 1 6 7 2 8 9 3 ... $ Cn: Factor w/ 12 levels 10,000,100,..: 1 1 1 12 12 12 9 9 9 6 ... $ read_count: int 6876 23440 18787 4775 1542 1550 15322 7023 834 4216 ... # remove the comma and convert to numeric x$Cn - as.numeric(gsub(,, , as.character(x$Cn))) str(x) 'data.frame': 30 obs. of 3 variables: $ ID: Factor w/ 30 levels MJ-2000-100,..: 4 5 12 1 6 7 2 8 9 3 ... $ Cn: num 1 1 1 8000 8000 8000 6000 6000 6000 4000 ... $ read_count: int 6876 23440 18787 4775 1542 1550 15322 7023 834 4216 ... plot(x$Cn, x$read_count) On Sat, Jul 18, 2009 at 6:18 PM, ANJAN PURKAYASTHAanjan.purkayas...@gmail.com wrote: Hi I have a data set that needs to be plotted (see below) When I plot it using the simple plot(read_count ~ Cn), I get box plots for the read_count numbers plotted according to Cn. The Cn's on the x-axis are ordered: 1, 100, 1000, 40, 400, 4000... How do I plot so that Cn is plotted on the x-axis in an ascending order: 40, 60, 80, ...1? Thanks for your help. Anjan ID Cn read_count 1 MJ-2000-79 10,000 6876 2 MJ-2000-80 10,000 23440 3 MJ-2000-87 10,000 18787 4 MJ-2000-100 8000 4775 5 MJ-2000-81 8000 1542 6 MJ-2000-82 8000 1550 7 MJ-2000-101 6000 15322 8 MJ-2000-83 6000 7023 9 MJ-2000-84 6000 834 10 MJ-2000-102 4000 4216 11 MJ-2000-85 4000 1174 12 MJ-2000-86 4000 404 13 MJ-4000-131 1000 1368 14 MJ-4000-132 1000 2219 15 MJ-4000-125 800 413 16 MJ-4000-133 800 2594 17 MJ-4000-127 600 3059 18 MJ-4000-134 600 1561 19 MJ-4000-142 600 848 20 MJ-4000-129 400 182 21 MJ-4000-130 400 1410 22 MJ-4000-135 400 2713 23 MJ-7000-182 100 943 24 MJ-8000-184 100 318 25 MJ-8000-185 80 92 26 MJ-8000-186 80 161 27 MJ-8000-188 60 158 28 MJ-8000-191 60 103 29 MJ-8000-192 40 468 30 MJ-8000-193 40 432 -- = anjan purkayastha, phd bioinformatics analyst whitehead institute for biomedical research nine cambridge center cambridge, ma 02142 purkayas [at] wi [dot] mit [dot] edu 703.740.6939 [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Plotting question re. cuminc
K F Pearce wrote: Hello everyone, (This is my second question posted today on the R list). and you have still not read the posting guide? It asks you to provide commented, minimal, self-contained, reproducible code which also means that you need to tell which packages you are using. I get, e.g.: cuminc(ftime,fstatus,group) Error: could not find function cuminc ftime Error: object 'ftime' not found fstatus Error: object 'fstatus' not found group Error: object 'group' not found Best, Uwe Ligges I am carrying out a competing risks analysis using the cuminc function...this takes the form: cuminc(ftime,fstatus,group) In my study, fstatus has 3 different causes of failure (1,2,3) there are also censored cases (0). group has two levels (0 and 1). I therefore have 6 different cumulative incidence curves: cause 1, group=0; cause 1 group=1 cause 2, group=0; cause 2 group=1 cause 3, group=0; cause 3 group=1 If I type the following commands: xx-cuminc(ftime,fstatus,group) plot(xx,lty=1,color=1:6) I end up with the 6 curves plotted on the same graph. Is there a way that I can plot a selection of these curves? (say only curves for cause 1, group=0 and cause 1 group=1). Thank you so much, Kind Regards, Kim Dr Kim Pearce CStat Industrial Statistics Research Unit (ISRU) School of Mathematics and Statistics Herschel Building University of Newcastle Newcastle upon Tyne United Kingdom NE1 7RU Tel. 0044 (0)191 222 6244 (direct) Fax. 0044 (0)191 222 8020 Email: k.f.pea...@ncl.ac.uk __ 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.
[R] Plotting question re. cuminc
Hello everyone, (This is my second question posted today on the R list). I am carrying out a competing risks analysis using the cuminc function...this takes the form: cuminc(ftime,fstatus,group) In my study, fstatus has 3 different causes of failure (1,2,3) there are also censored cases (0). group has two levels (0 and 1). I therefore have 6 different cumulative incidence curves: cause 1, group=0; cause 1 group=1 cause 2, group=0; cause 2 group=1 cause 3, group=0; cause 3 group=1 If I type the following commands: xx-cuminc(ftime,fstatus,group) plot(xx,lty=1,color=1:6) I end up with the 6 curves plotted on the same graph. Is there a way that I can plot a selection of these curves? (say only curves for cause 1, group=0 and cause 1 group=1). Thank you so much, Kind Regards, Kim Dr Kim Pearce CStat Industrial Statistics Research Unit (ISRU) School of Mathematics and Statistics Herschel Building University of Newcastle Newcastle upon Tyne United Kingdom NE1 7RU Tel. 0044 (0)191 222 6244 (direct) Fax. 0044 (0)191 222 8020 Email: k.f.pea...@ncl.ac.uk __ 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] plotting question
Greetings all, I have two questions. I have a data set that is arranged in the example below. I wish to obtain a plot of the performance of each ID over Year on v1. It's not clear how I set this up? ID Year V1 1 19801 1 19812 1 19826 1 19834 2 19805 2 19815 2 19825 2 19836 Also,I would like to transpose the data to have the variable across the columns such as ID v1980 v1981 v1982 v1983 1 1 2 6 4 2 5 5 5 6 Is there a straightforward way to do this in R? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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] plotting question
check out the interaction.plot. This *may* be what you are looking for. ?interaction.plot On Mar 15, 8:14 am, David Kaplan dkap...@education.wisc.edu wrote: Greetings all, I have two questions. I have a data set that is arranged in the example below. I wish to obtain a plot of the performance of each ID over Year on v1. It's not clear how I set this up? ID Year V1 1 1980 1 1 1981 2 1 1982 6 1 1983 4 2 1980 5 2 1981 5 2 1982 5 2 1983 6 Also,I would like to transpose the data to have the variable across the columns such as ID v1980 v1981 v1982 v1983 1 1 2 6 4 2 5 5 5 6 Is there a straightforward way to do this in R? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage:http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ r-h...@r-project.org 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. __ 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] plotting question
On Mar 14, 2009, at 5:14 PM, David Kaplan wrote: Greetings all, I have two questions. I have a data set that is arranged in the example below. I wish to obtain a plot of the performance of each ID over Year on v1. It's not clear how I set this up? ID Year V1 1 19801 1 19812 1 19826 1 19834 2 19805 2 19815 2 19825 2 19836 ?xyplot ?formula Also,I would like to transpose the data to have the variable across the columns such as ID v1980 v1981 v1982 v1983 1 1 2 6 4 2 5 5 5 6 ?reshape # or require(reshape) ?cast Is there a straightforward way to do this in R? Thanks in advance, David - David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] plotting question
On Mar 14, 2009, at 5:46 PM, David Winsemius wrote: On Mar 14, 2009, at 5:14 PM, David Kaplan wrote: Greetings all, I have two questions. I have a data set that is arranged in the example below. I wish to obtain a plot of the performance of each ID over Year on v1. It's not clear how I set this up? ID Year V1 1 19801 1 19812 1 19826 1 19834 2 19805 2 19815 2 19825 2 19836 # oops, also need to preface with: library(lattice) ?xyplot ?formula Could also do it separately for each ID group. Something like (untested): with(subset(dta, ID==1), plot(Year,V1, pch=3) ) with(subset(dta, ID==2), points( Year, V1, pch=5)) # but that could get tiring for many ID Also,I would like to transpose the data to have the variable across the columns such as ID v1980 v1981 v1982 v1983 1 1 2 6 4 2 5 5 5 6 ?reshape reshape(dta, idvar=ID, timevar=Year,direction=wide) ID V1.1980 V1.1981 V1.1982 V1.1983 1 1 1 2 6 4 5 2 5 5 5 6 # or require(reshape) ?cast Is there a straightforward way to do this in R? Thanks in advance, David David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] plotting question
Use reshape in the base of R or melt/cast in the reshape package. Using the former: Lines - ID Year V1 1 19801 1 19812 1 19826 1 19834 2 19805 2 19815 2 19825 2 19836 # DF - read.table(myfile.dat, header = TRUE) DF - read.table(textConnection(Lines), header = TRUE) reshape(DF, dir = wide, idvar = ID, timevar = Year) gives for the posted data: reshape(DF, dir = wide, idvar = ID, timevar = Year) ID V1.1980 V1.1981 V1.1982 V1.1983 1 1 1 2 6 4 5 2 5 5 5 6 On Sat, Mar 14, 2009 at 5:14 PM, David Kaplan dkap...@education.wisc.edu wrote: Greetings all, I have two questions. I have a data set that is arranged in the example below. I wish to obtain a plot of the performance of each ID over Year on v1. It's not clear how I set this up? ID Year V1 1 1980 1 1 1981 2 1 1982 6 1 1983 4 2 1980 5 2 1981 5 2 1982 5 2 1983 6 Also,I would like to transpose the data to have the variable across the columns such as ID v1980 v1981 v1982 v1983 1 1 2 6 4 2 5 5 5 6 Is there a straightforward way to do this in R? Thanks in advance, David -- === David Kaplan, Ph.D. Professor Department of Educational Psychology University of Wisconsin - Madison Educational Sciences, Room, 1061 1025 W. Johnson Street Madison, WI 53706 email: dkap...@education.wisc.edu homepage: http://www.education.wisc.edu/edpsych/default.aspx?content=kaplan.html Phone: 608-262-0836 __ 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.
[R] Plotting question: Problem with strwidth in 2.7.1
R users, I have a problem with function strwidth in 2.7.1. I'm trying to set the plot margins in a way that horizontal column labels will fit to the graph. tmp.t is a list of data.frame objects. This code works well in 2.6.0. ...snip.. library(gplots) for (i in names(tmp.t)) { bmp(filename=paste(i, _, Sys.Date(), .bmp, sep=), width=1038, height=820, res=1200) maxim - max(strwidth(as.character(colnames(tmp.t[[i]])), units=inches))*4.5 opar - par(mar=c(3,maxim,2,2), bg=white, cex=1.6, oma = c(0, 0, 2, 0), mgp=c(3,0.5,0), xpd=TRUE) colo - c(red, lightblue1, orange, yellow) xmax - max(unlist(lapply(tmp.t[i], function(x) apply(x, 2, sum))) + 15) bar - barplot2(tmp.t[[i]], horiz=TRUE, names.arg=as.character(colnames(tmp.t[[i]])), las=1, cex.names=0.7, cex.main=0.9, cex.axis=0.7, xlim=c(0, xmax), col=colo, plot.grid = TRUE ) box() dev.off() } ...snip... Now running this script I get an error message Error in plot.new() : figure margins too large I found from http://cran.r-project.org/src/base/NEWS that o Use of strwidth/height(units=user) (the default) is again an error before a user coordinate system has been set on the device, rather than giving nonsensical values (the effect of r31367). Does this have something to do with my problem? How should I modify my code to get it work in R 2.7.1? Thanks Lauri sessionInfo() R version 2.7.1 (2008-06-23) i386-pc-mingw32 locale: LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETARY=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods [8] base other attached packages: [1] TeachingDemos_2.2 tkrplot_0.0-18gplots_2.6.0 gdata_2.4.2 [5] gtools_2.5.0 RODBC_1.2-3 loaded via a namespace (and not attached): [1] tools_2.7.1 __ 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] Plotting question: Problem with strwidth in 2.7.1
Sorry, I found that there is a new bmp() device and when I lower the resolution parameter e.g. to 72, everything works fine. Best Lauri 2008/6/30, Lauri Nikkinen [EMAIL PROTECTED]: R users, I have a problem with function strwidth in 2.7.1. I'm trying to set the plot margins in a way that horizontal column labels will fit to the graph. tmp.t is a list of data.frame objects. This code works well in 2.6.0. ...snip.. library(gplots) for (i in names(tmp.t)) { bmp(filename=paste(i, _, Sys.Date(), .bmp, sep=), width=1038, height=820, res=1200) maxim - max(strwidth(as.character(colnames(tmp.t[[i]])), units=inches))*4.5 opar - par(mar=c(3,maxim,2,2), bg=white, cex=1.6, oma = c(0, 0, 2, 0), mgp=c(3,0.5,0), xpd=TRUE) colo - c(red, lightblue1, orange, yellow) xmax - max(unlist(lapply(tmp.t[i], function(x) apply(x, 2, sum))) + 15) bar - barplot2(tmp.t[[i]], horiz=TRUE, names.arg=as.character(colnames(tmp.t[[i]])), las=1, cex.names=0.7, cex.main=0.9, cex.axis=0.7, xlim=c(0, xmax), col=colo, plot.grid = TRUE ) box() dev.off() } ...snip... Now running this script I get an error message Error in plot.new() : figure margins too large I found from http://cran.r-project.org/src/base/NEWS that o Use of strwidth/height(units=user) (the default) is again an error before a user coordinate system has been set on the device, rather than giving nonsensical values (the effect of r31367). Does this have something to do with my problem? How should I modify my code to get it work in R 2.7.1? Thanks Lauri sessionInfo() R version 2.7.1 (2008-06-23) i386-pc-mingw32 locale: LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETARY=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods [8] base other attached packages: [1] TeachingDemos_2.2 tkrplot_0.0-18gplots_2.6.0 gdata_2.4.2 [5] gtools_2.5.0 RODBC_1.2-3 loaded via a namespace (and not attached): [1] tools_2.7.1 __ 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] Plotting question: Problem with strwidth in 2.7.1
Lauri Nikkinen wrote: R users, I have a problem with function strwidth in 2.7.1. I'm trying to set the plot margins in a way that horizontal column labels will fit to the graph. tmp.t is a list of data.frame objects. This code works well in 2.6.0. I don't think this has to do with stringwidth at all: bmp(filename=foo.bmp,width=1038, height=820, res=1200) plot(0) Error in plot.new() : figure margins too large (width and height are in pixels, so at 1200dpi, the plotting area is less than one inch. What did you intend?) BTW: The fudge factor of 4.5 might be better estimated from par(c(cin,cex,lheight)). ...snip.. library(gplots) for (i in names(tmp.t)) { bmp(filename=paste(i, _, Sys.Date(), .bmp, sep=), width=1038, height=820, res=1200) maxim - max(strwidth(as.character(colnames(tmp.t[[i]])), units=inches))*4.5 opar - par(mar=c(3,maxim,2,2), bg=white, cex=1.6, oma = c(0, 0, 2, 0), mgp=c(3,0.5,0), xpd=TRUE) colo - c(red, lightblue1, orange, yellow) xmax - max(unlist(lapply(tmp.t[i], function(x) apply(x, 2, sum))) + 15) bar - barplot2(tmp.t[[i]], horiz=TRUE, names.arg=as.character(colnames(tmp.t[[i]])), las=1, cex.names=0.7, cex.main=0.9, cex.axis=0.7, xlim=c(0, xmax), col=colo, plot.grid = TRUE ) box() dev.off() } ...snip... Now running this script I get an error message Error in plot.new() : figure margins too large I found from http://cran.r-project.org/src/base/NEWS that o Use of strwidth/height(units=user) (the default) is again an error before a user coordinate system has been set on the device, rather than giving nonsensical values (the effect of r31367). Does this have something to do with my problem? How should I modify my code to get it work in R 2.7.1? Thanks Lauri sessionInfo() R version 2.7.1 (2008-06-23) i386-pc-mingw32 locale: LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETARY=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods [8] base other attached packages: [1] TeachingDemos_2.2 tkrplot_0.0-18gplots_2.6.0 gdata_2.4.2 [5] gtools_2.5.0 RODBC_1.2-3 loaded via a namespace (and not attached): [1] tools_2.7.1 __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] Plotting question: how to plot SNP location data?
Hello, I would like to plot specific SNPs with their exact locations on a chromosome. Based on my genotyping results I would like to separate these SNPs in three different categories: 1, 2 and 3 and use different colours to represent these categories. The script below generates the sample data. I can plot these with the image function using the following: val - 1:3 samp - sample(val, 100, replace=TRUE) z - matrix(samp, nrow=20, ncol=4, byrow=TRUE) SNP - 1:20 siblings - 1:4 opar - par(cex=0.7) image(SNP, siblings, z, col=c(blue, red, black), axes=FALSE, ann=FALSE) axis(1, at=1:20, labels=paste(rep(SNP, 20), 1:20), las=2) axis(2, at=1:4) mtext(sibling, 2, line=3) title(main=Specific SNPs in Chr 1) par(opar) In addition to having the data for the above colour matrix, I also have data including the exact locations of the SNPs on a chromosome (snploc). I would like to plot the SPNs using the colour codes from above (z) and include the exact locations of each SNP. Is it possible to do that using the image-function? Below I have tried to solve the problem using the basic plot function but I cannot include the colors to that plot. How would that be possible? colnames(z) - c(sib1,sib2,sib3,sib4) rownames(z) - paste(rep(SNP, 20), 1:20) z.t - t(z) #snploc$location represents the location of the SNP in the chromosome snploc - data.frame(SNP=paste(rep(SNP, 20), 1:20), location=c(4.2,5.8,6.9,3,8,7,5,4,3.6,4.3,4.6,6.6,5.2,6,9,9.4,12,16,14,12 .3)) snploc$SNP - factor(snploc$SNP, levels=unique(snploc$SNP)) temp - as.data.frame(sapply(levels(snploc$SNP), function(x){ z.t[,x] - snploc$location[snploc$SNP == x]; z.t[,x] })) temp1 - as.list(temp) #Plot the location of the SNP x11() for (i in names(temp1)) { opar - par(new=TRUE) plot(temp1[[i]], 1:4, pch=|, ann=FALSE, col=blue, xlim=c(0, 20), ylim=c(1,4), yaxp=c(1,4,3)) par(opar) } mtext(SNP location, 1, line=3) mtext(sibling, 2, line=3) opar - par(cex=0.7) axis(3, at=snploc$location, labels=snploc$SNP, las=3) par(opar) Originally my z.t data.frame has dimensios 33*4000 so looping through this data.frame is tedious. Thanks, Lauri *** Lauri Nikkinen Finnish Red Cross Blood Service www.bloodservice.fi [[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] Plotting question
I am constructing plots ( regular not lattice ) and my initial command is par(mar=c(3,4,2,2), mfcol=c(5,2)) and then I create 10 plots on the page. It looks great but the plots on the page go in the order 16 27 38 49 510 Where the numbers denote decile breakdowns. Is there an easy way to make them go from left to right so 12 34 56 78 910 I could try to stay with the first way and reorder the deciles but that would be tricky and beyond my current knowledge base. Thanks. This is not an offer (or solicitation of an offer) to bu...{{dropped:22}} __ 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] Plotting question
Have you looked at layout() ? Hadley On 10/12/07, Leeds, Mark (IED) [EMAIL PROTECTED] wrote: I am constructing plots ( regular not lattice ) and my initial command is par(mar=c(3,4,2,2), mfcol=c(5,2)) and then I create 10 plots on the page. It looks great but the plots on the page go in the order 16 27 38 49 510 Where the numbers denote decile breakdowns. Is there an easy way to make them go from left to right so 12 34 56 78 910 I could try to stay with the first way and reorder the deciles but that would be tricky and beyond my current knowledge base. Thanks. This is not an offer (or solicitation of an offer) to bu...{{dropped:22}} __ 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. -- http://had.co.nz/ __ 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.