Re: [R] Adding dash-lines in R tables
moreover: library(ascii) M - matrix(letters[1:10], 2) M [,1] [,2] [,3] [,4] [,5] [1,] a c e g i [2,] b d f h j ascii(M) | | a | c | e | g | i | b | d | f | h | j | print(ascii(M), rest) +---+---+---+---+---+ | a | c | e | g | i | +---+---+---+---+---+ | b | d | f | h | j | +---+---+---+---+---+ print(ascii(M), pandoc) --- --- --- --- --- a c e g i b d f h j --- --- --- --- --- You could also try t2t, org, or textile, and then set a global option: options(asciiType = youroutputtype) david 2011/5/22 Ista Zahn iz...@psych.rochester.edu: Axel, you may also be interested in the ascii function (in the ascii package). The ascii version of David's example is library(ascii) #may need install.packages(ascii) first ascii(M) ascii(table(sample(1:10, 100, replace=TRUE))) Best, Ista On Sun, May 22, 2011 at 9:52 AM, David Winsemius dwinsem...@comcast.net wrote: On May 22, 2011, at 7:47 AM, Axel Urbiz wrote: is it possible to add dash lines to tables or matrices when they are printed? An example of what I'm looking for is this: library(Design) y - sample(c(0,1),100, replace = TRUE) x - rnorm(100) summary(y ~ x) There is a method for summary on formula objects found by typing methods(summary) # didn't find the answer looking at code of summary.formula. Then there is a print method for summary.formula objects methods(print) # examine the 3 print.summary. methods # didn't find the answer there, either, but did notice that the # function `print.char.matrix` was being used near the end of the code M - matrix(letters[1:10], 2) print.char.matrix(M) +-+-+-+-+-+ |a|c|e|g|i| +-+-+-+-+-+ |b|d|f|h|j| +-+-+-+-+-+ It is in package Hmisc and its behavior is documented: ?print.char.matrix print.char.matrix( table(sample(1:10, 100, replace=TRUE) ) ) +--+--+ | 1|12| +--+--+ | 2| 6| +--+--+ | 3|11| +--+--+ | 4|13| +--+--+ | 5|12| +--+--+ | 6| 7| +--+--+ | 7| 8| +--+--+ | 8| 8| +--+--+ | 9|14| +--+--+ |10| 9| +--+--+ -- 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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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] [R-pkgs] ascii package updated
Hi, I have uploaded a new version of the ascii package, it should be availble on CRAN soon. Major new features are: - pandoc support (http://johnmacfarlane.net/pandoc/) - an alternative to the Sweave way to create reports: see ?Report. This feature needs a working installation of asciidoc, txt2tags and/or pandoc. It becomes increasingly difficult for me to maintain and test all the available markup languages (asciidoc, txt2tags, org, textile, restructeredtext and pandoc for this version), and I would be very pleased for any comments, suggestions or bug reports. Best, David [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] descriptive statistics
Another way is the remix function of the remix package. On Monday, December 13, 2010, justin bem justin_...@yahoo.fr wrote: A nice way to obtain summary for data is to use summary.formula in Hmisc package. Justin BEM BP 1917 Yaoundé Tél (237) 76043774 De : Jim Lemon j...@bitwrit.com.au À : effeesse scarpin...@gmail.com Cc : r-help@r-project.org Envoyé le : Lun 13 décembre 2010, 11h 23min 15s Objet : Re: [R] descriptive statistics On 12/13/2010 09:04 PM, effeesse wrote: Hi. In a data set I have a variable that takes values from 1 to 14. For each subgroup of values of this variable, I would like to obtain some descriptive statistics of other variables present in the data set. I've been trying with a for loop but I couldn't get nothing. Could you please suggest me some lines? Hi effeesse, Sure: testmat-data.frame(sample(1:14,50,TRUE),rnorm(50),runif(50)) by(testmat[,-1],testmat[,1],mean) Jim __ r-h...@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] LaTeX, MiKTeX, LyX: A Guide for the Perplexed
Hello, You could also be interested by the ascii package, which allows to use Sweave with more simple markup languages such as asciidoc, txt2tages or restructuredtext. An asciidoc based Rnw file is in my opinion more readable and sharable than a latex based. Best. On Wednesday, December 8, 2010, bill.venab...@csiro.au wrote: A new fortune is born? Sharing LaTeX documents with people using word processors only is no more difficult than giving driving directions to someone who is blindfolded and has all 4 limbs tied behind their back. Collaboration with people who insist on using programs that process their words much like a food processor processes food is the one legitimate reason to not use LaTeX (but untying them and removing the blindfold is much better). Gets my vote. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Greg Snow Sent: Wednesday, 8 December 2010 2:24 PM To: Paul Miller; r-help@r-project.org Subject: Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed See inline below -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Paul Miller Sent: Tuesday, December 07, 2010 4:29 PM To: r-help@r-project.org Subject: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed Hello Everyone, Been learning R over the past several months. Read several books and have learned a great deal about data manipulation, statistical analysis, and graphics. Now I want to learn how to make nice looking documents and about literate programming. My understanding is that R users normally do this using LaTeX, MiKTeX, LyX, etc. in conjuction with Sweave. An alternative might be to use the R2wd package to create Word documents. So I guess I have four questions: 1. How do I choose between the various options? Why would someone decide to use LaTeX instead of MiKTeX or vice versa for example? MikTeX is a flavor of LaTeX for windows, so there is not much to decide between them, MikTeX is LaTeX (though there are other implementations on windows) 2. What are the best sources of information about LaTeX, MiKTeX, LyX, etc.? There are many documents about LaTeX, including books. But I would suggest starting with the Not So Short Introduction to LaTeX that is free and comes with MikTeX (and probably the others). LyX should have its own docs with it. There are several other guides that come free that would be good to read after that. If you want a paper book then I would suggest the original by Lamport. 3. What is the learning curve like for each of these? What do you get for the time you put in learning something that is more difficult? That depends on your background, if you have never worked from the command line or with a markup language, then it is pretty steep, if you have worked with those types of tools then it is not as bad. But either way it is worth it. When I first learned LaTeX I was tempted to go back and rewrite my master's thesis in it instead of the word processor. I did not, but my dissertation was in LaTeX. 4. How do people who use LaTeX, MiKTeX, LyX, etc. share documents with people who are just using Word? How difficult does using LaTeX, MiKTeX, LyX, etc. make it to collaborate on projects with others? Sharing LaTeX documents with people using word processors only is no more difficult than giving driving directions to someone who is blindfolded and has all 4 limbs tied behind their back. Collaboration with people who insist on using programs that process their words much like a food processor processes food is the one legitimate reason to not use LaTeX (but untying them and removing the blindfold is much better). If you just need basic input or approval then give them a paper version or pdf file and then you make the changes. If they are going to be writing major portions or doing a lot of editing, then using LaTeX without all people understanding it will be a headache. Some other packages to consider are odfWeave (odf is the opensource office suite, it can read and write MSWord documents, but still sweave with R); R2HTML works with sweave where the base document is in html; sword is a tool from the same group as rexcel that gives the same general idea as sweave but using MSWord (windows only). Thanks, Paul -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 __ r-h...@r-project.org mailing list __ 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] LaTeX, MiKTeX, LyX: A Guide for the Perplexed
Two more cents: pandoc support is in my todo list... But I don't have the time actually. On Wednesday, December 8, 2010, Patrick Hausmann patrick.hausm...@uni-bremen.de wrote: Hi Paul, I am using Sweave and MiKTeX and the results are really impressive, but it's often quite complicated (or impossible) to share the rnw-files with my colleagues/clients. So it depends with/for whom you are working. Perhaps as an alternative you could use a simpler markup format e.g. Markdown (with the ascii package). To convert between different markup languages Pandoc [1] looks very promising. HTH Patrick [1] http://johnmacfarlane.net/pandoc Am 08.12.2010 00:29, schrieb Paul Miller: Hello Everyone, � Been learning R over the past several months. Read several books and have learned a great deal about data manipulation, statistical analysis, and graphics. � Now I want to learn how to make nice looking documents and�about literate programming. My understanding is that R users normally do this using LaTeX, MiKTeX, LyX, etc. in conjuction with Sweave.�An alternative might be to use the R2wd package to create Word documents. � So I guess I have�four questions: � 1. How do I choose between the various options? Why would someone decide to use LaTeX instead of MiKTeX or vice versa for example? � 2. What are the best sources of information about LaTeX, MiKTeX, LyX, etc.? � 3. What is the learning curve like for each of these? What do you get�for the time you put in learning something that is more difficult? � 4. How do people who use LaTeX, MiKTeX, LyX, etc. share documents with people who are just using Word? How difficult does using LaTeX, MiKTeX, LyX, etc. make it to collaborate on projects with others? � Thanks, � Paul [[alternative HTML version deleted]] __ r-h...@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-h...@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] Reproducible research
Hello David, You could also have a look to the ascii package : http://eusebe.github.com/ascii/ With asciidoc (http://www.methods.co.nz/asciidoc/), or one of other markup languages supported (restructuredtext, txt2tags, or textile), you can obtain good results. For example, vignettes of the book Analysis and Interpretation of Freshwater Fisheries Data (http://www.ncfaculty.net/dogle/fishR/bookex/AIFFD/AIFFD.html) are made with asciidoc and ascii package. If you are an emacs user, you might also be interested in org-mode and org-babel: http://orgmode.org/worg/org-contrib/babel/ Best, david 2010/9/9 David Scott d.sc...@auckland.ac.nz: I am investigating some approaches to reproducible research. I need in the end to produce .html or .doc or .docx. I have used hwriter in the past but have had some problems with verbatim output from R. Tables are also not particularly convenient. I am interested in R2HTML and R2wd in particular, and possibly odfWeave. Does anyone have sample documents using any of these approaches which they could let me have? David Scott _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142, NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ 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] print method for str?
Hello useRs and guRus, I was trying to add the support of str() in the ascii package, and I realized that str() does not have a print method. It uses cat() from inside the function and returns nothing. Since it is not usual in R, I wonder why? Is there a particular reason? Thank you very much for your attention on... well, this unimportant question. david [[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] print method for str?
Exact, efficiency, I didn't see that. Thank you very much. 2010/8/26 Gavin Simpson gavin.simp...@ucl.ac.uk: On Thu, 2010-08-26 at 10:42 +0200, David Hajage wrote: Hello useRs and guRus, I was trying to add the support of str() in the ascii package, and I realized that str() does not have a print method. It uses cat() from inside the function and returns nothing. Since it is not usual in R, I wonder why? Is there a particular reason? The Value section of ?str has a (the?) reason. Efficiency. str is an S3 generic though, so you can write your own methods for it. HTH G Thank you very much for your attention on... well, this unimportant question. david [[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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.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.
Re: [R] R reports
2010/8/21 Donald Winston satchwins...@yahoo.com I know how to program in a dozen languages. I have a B.A. in mathematics, and an M.S. in operations research and statistics. I just don't care, I would try to answer you even if you had no formation. I can figure out how to write reports in R. The point is I don't want to. There should be a function that generates a report just like there is a function that generates a plot without using loops or if statements. The question is: what do you want? What is the result of this fictive function? I am sure you don't need loop to do that. I've read R IN A NUTSHELL from cover to cover. The word report does not even appear in the index. Just ask Joseph Adler. On Aug 21, 2010, at 11:39 AM, David Hajage wrote: I must repeat: just show us what is the kind of report you want to do, and you will perhaps get a solution to reproduce it We still don't know what is the output of your report() function. This, is ridiculous. On Saturday, August 21, 2010, Frank Harrell f.harr...@vanderbilt.edu wrote: On Sat, 21 Aug 2010, Donald Paul Winston wrote: Good grief. Adding a report function is not going to make R less flexible. Don't you want to use a tool that's relevant to the rest of the world? That world is much bigger then your world. This is ridiculous. Looks like some people are complaining about me criticizing R and the people who defend it. Good grief again. I think your philosophy is now more clear Donald. People who don't like learning new things place themselves at a competitive disadvantage. The R community, where learning is highly valued, may be fundamentally incompatible with your philosophy. You may do well to stay with SAS. Frank From: David Hajage-2 [via R] ml-node+248-1227050197-138...@n4.nabble.comml-node%2b248-1227050197-138...@n4.nabble.com Sent: Sat, August 21, 2010 4:54:12 AM Subject: Re: R reports Just show us what is the kind of report you want to do, and you will perhaps get a solution to reproduce it. Then, if you don't like the way to do that, write your own code or don't use R, noone force you. The majority of R users are satisfied with the way to generate reports, because it is flexible. There is ABSOLUTELY *NO WARRANTY with R, this means also you have no warranty to find exactly what you want, and what you can find in SAS. Just deal with it.* 2010/8/21 Donald Paul Winston [hidden email] Sweave and LaTex is way to much overhead to deal with. There should be a built in standard report() function analogous to plot(). Something like the following is necessary if you want real people to take R seriously: report(data=aDataFrame, vars=vectorOfColumnNames, label=vectorOfColumnNames, by=vectorOfColumnNames, sum=vectorOfColumnNames, title=vectorOfStrings, footer=vectorOfStrings, pageBy=vectorOfColumnNames, sumBy=vectorOfColumnNames, filename=string, fileType=text|csv|pdf.etc) Did I say real people? I've been Palinized. -- View this message in context: http://r.789695.n4.nabble.com/R-reports-tp2330733p2333264.html?by-user=t Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] R reports
Just show us what is the kind of report you want to do, and you will perhaps get a solution to reproduce it. Then, if you don't like the way to do that, write your own code or don't use R, noone force you. The majority of R users are satisfied with the way to generate reports, because it is flexible. There is ABSOLUTELY *NO WARRANTY with R, this means also you have no warranty to find exactly what you want, and what you can find in SAS. Just deal with it.* 2010/8/21 Donald Paul Winston satchwins...@yahoo.com Sweave and LaTex is way to much overhead to deal with. There should be a built in standard report() function analogous to plot(). Something like the following is necessary if you want real people to take R seriously: report(data=aDataFrame, vars=vectorOfColumnNames, label=vectorOfColumnNames, by=vectorOfColumnNames, sum=vectorOfColumnNames, title=vectorOfStrings, footer=vectorOfStrings, pageBy=vectorOfColumnNames, sumBy=vectorOfColumnNames, filename=string, fileType=text|csv|pdf.etc) Did I say real people? I've been Palinized. -- View this message in context: http://r.789695.n4.nabble.com/R-reports-tp2330733p2333264.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] R reports
I must repeat: just show us what is the kind of report you want to do, and you will perhaps get a solution to reproduce it We still don't know what is the output of your report() function. This, is ridiculous. On Saturday, August 21, 2010, Frank Harrell f.harr...@vanderbilt.edu wrote: On Sat, 21 Aug 2010, Donald Paul Winston wrote: Good grief. Adding a report function is not going to make R less flexible. Don't you want to use a tool that's relevant to the rest of the world? That world is much bigger then your world. This is ridiculous. Looks like some people are complaining about me criticizing R and the people who defend it. Good grief again. I think your philosophy is now more clear Donald. People who don't like learning new things place themselves at a competitive disadvantage. The R community, where learning is highly valued, may be fundamentally incompatible with your philosophy. You may do well to stay with SAS. Frank From: David Hajage-2 [via R] ml-node+248-1227050197-138...@n4.nabble.com Sent: Sat, August 21, 2010 4:54:12 AM Subject: Re: R reports Just show us what is the kind of report you want to do, and you will perhaps get a solution to reproduce it. Then, if you don't like the way to do that, write your own code or don't use R, noone force you. The majority of R users are satisfied with the way to generate reports, because it is flexible. There is ABSOLUTELY *NO WARRANTY with R, this means also you have no warranty to find exactly what you want, and what you can find in SAS. Just deal with it.* 2010/8/21 Donald Paul Winston [hidden email] Sweave and LaTex is way to much overhead to deal with. There should be a built in standard report() function analogous to plot(). Something like the following is necessary if you want real people to take R seriously: report(data=aDataFrame, vars=vectorOfColumnNames, label=vectorOfColumnNames, by=vectorOfColumnNames, sum=vectorOfColumnNames, title=vectorOfStrings, footer=vectorOfStrings, pageBy=vectorOfColumnNames, sumBy=vectorOfColumnNames, filename=string, fileType=text|csv|pdf.etc) Did I say real people? I've been Palinized. -- View this message in context: http://r.789695.n4.nabble.com/R-reports-tp2330733p2333264.html?by-user=t Sent from the R help mailing list archive at Nabble.com. __ r-h...@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] Latex no where to be seen
It amazes me that there's not a built in report function that can produce the same kinds of reports that every report writer and data analysis software in the whole word can do. (see SAS, Crystal Reports, SPSS, Oracle Reports, Actuate, Hyperion, Cognos, ..etc) To do some reports, most of R users use Sweave and other Sweave-like systems that have been already listed in another mail. Why don't you try what is currently existing? What is the kind of report you want, that you can't produce with Sweave? david 2010/8/20 Donald Paul Winston satchwins...@yahoo.com I'm experimenting using R as a report writer. I'm told LaTex is the destination for my quest. But ?latex() gives me an error. The package manager does not have it. The package installer can't find it. Where is it? It amazes me that there's not a built in report function that can produce the same kinds of reports that every report writer and data analysis software in the whole word can do. (see SAS, Crystal Reports, SPSS, Oracle Reports, Actuate, Hyperion, Cognos, ..etc) -- View this message in context: http://r.789695.n4.nabble.com/Latex-no-where-to-be-seen-tp2332139p2332139.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] R reports
and: - brew - HTMLUtils - ascii - odfWeave - R2HTML - hwriter - ... 2010/8/19 ONKELINX, Thierry thierry.onkel...@inbo.be Dear Donald, I'm not sure what the meaning of '3G' and '4G' is. You should take a look at Sweave() which is a very powerfull tool for generating reports in R. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Donald Paul Winston Verzonden: donderdag 19 augustus 2010 8:53 Aan: r-help@r-project.org Onderwerp: [R] R reports I don't see much in the way of an ability to write reports in R the way you can with SAS. You basically have to write a program with R in a 3G way unlike SAS with it's 4G proc print and proc report. Are there similar R functions and packages? -- View this message in context: http://r.789695.n4.nabble.com/R-reports-tp2330733p2330733.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] R reports
I'm not sure I understand what is 3GL or 4GL, but R is on the list of fourth-generation languages : Data manipulation, analysis, and reporting languageshttp://en.wikipedia.org/wiki/Fourth-generation_programming_language#Some_fourth-generation_languages on wikipedia. I don't know a function like that (nervertheless, I know nothing about proc report, and I don't understand how it works). But if you don't want a Sweave-like process, hwriter can automatically generate (html) reports: # from http://www.ebi.ac.uk/~gpau/hwriter/ library(hwriter) hwrite(iris[1:2,1:2], 'test.html', row.bgcolor='#ffdc98') browseURL(paste(file://, getwd(), /test.html, sep = )) In all case, to generate the report, you must first create the results, and then display it into a report. Or perhaps you're looking for something like rreport package (in development): http://biostat.mc.vanderbilt.edu/wiki/Main/Rreport (never tried) david 2010/8/19 Donald Paul Winston satchwins...@yahoo.com Oops, I meant 4GL. Part of SAS involves more or less declarative coding where SAS figures out how to process the information and you don't have to. Sweave and html generators in R are not what I'm looking for. I'm looking for a function whose arguments are data, column names, grouping variables, summary stats, titles, footnotes, etc. Sort of like what plot does except the function will generate a report. I suppose you could specify an output format or printer device as plain text, rich text, pdf, or html. -- View this message in context: http://r.789695.n4.nabble.com/R-reports-tp2330733p2331037.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] mtext coordinates
Hello, I am using mtext to write some text below a graph: plot(1) mtext(foo, side = 1, line = 2, at = seq(0.6, 1.6, 0.2)) I would like to draw something near the foo texts, for example a segment. For this, I need to know the coordinates of the text ploted by mtext function. I spent a few hours to try different combination, using the option xpd = TRUE and trying to convert between graphics coordinate system using grconvertX and grconvertY... But I can't make it. Is there a way to know the coordinates of the text produce by mtext, particularly vertical coordinates? For example, how can you draw some segments to underline each foo in my example? Thank you very much for any help. david [[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] mtext coordinates
Thank, it is quite what I was looking for. But with your code, when I tried to change the size of the plot window, the segments are moving... I don't know if you see what I want, just try to expand the height of the window. Is there any solution for this ? 2010/8/18 Jim Lemon j...@bitwrit.com.au On 08/18/2010 08:40 PM, David Hajage wrote: Hello, I am using mtext to write some text below a graph: plot(1) mtext(foo, side = 1, line = 2, at = seq(0.6, 1.6, 0.2)) I would like to draw something near the foo texts, for example a segment. For this, I need to know the coordinates of the text ploted by mtext function. I spent a few hours to try different combination, using the option xpd = TRUE and trying to convert between graphics coordinate system using grconvertX and grconvertY... But I can't make it. Is there a way to know the coordinates of the text produce by mtext, particularly vertical coordinates? For example, how can you draw some segments to underline each foo in my example? Hi David, You can get the X coordinates of the beginning and end of the text by using the strwidth function: # this is inefficient, but easy to follow begintext-at-strwidth(foo)*par(adj) endtext-at+strwidth(foo)*(1-par(adj)) the strheight function can be used to get the Y coordinates: bottomtext-par(usr)[1]-(line+0.5)*strheight(Ug) You will probably have to fiddle with the constant (0.5) to get the line in the correct place on a particular device, then: par(xpd=TRUE) segments(begintext,bottomtext,endtext,bottomtext) par(xpd=FALSE) Jim [[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] Calculating Summaries for each level of a Categorical variable
You could try the remix function in remix package. David Le 27 juin 2010 à 06:48, RaoulD raoul.t.dso...@gmail.com a écrit : Hi Christos, Thanks for this. I had a look at Summary.Forumla in the Hmisc package and it is extremely complicated for me. Still trying to decipher how I could use it. Regards, Raoul -- View this message in context: http://r.789695.n4.nabble.com/Calculating-Summaries-for-each-level-of-a-Categorical-variable-tp2269349p2269816.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the best way to have R output tables in an MS Word format?
Another option is to use ascii package http://eusebe.github.com/ascii/. Just choose your favorite markup language (asciidochttp://www.methods.co.nz/asciidoc/, txt2tags http://txt2tags.sourceforge.net/, restructuredtexthttp://docutils.sourceforge.net/rst.html, org-mode http://orgmode.org/ or textilehttp://textism.com/tools/textile/). They all have several output options (html, latex, xml...). ascii package provides a new generic function to format R output to all these markup languages, and corresponding Sweave drivers. For example: - http://www.ncfaculty.net/dogle/fishR/bookex/AIFFD/AIFFD.html (using asciidoc) - http://learnr.wordpress.com/ (using asciidoc) - http://mpastell.com/2010/03/25/create-odf-pdf-and-html-report-from-a-single-sweave-document/ (using restructuredtext) I am using ascii package with asciidoc, html output can be converted to .doc or .odf with microsoft word or openoffice, but you can also obtain xml output. Best, david 2010/5/1 Gabor Grothendieck ggrothendi...@gmail.com On Sat, May 1, 2010 at 3:41 AM, Chris Evans chrish...@psyctc.org wrote: It's interesting to see this coming up quite soon after my posting asking for light formatting (tabs, simple tables, one day embedded graphics) in a default output pane in R. Greg Snow kindly pointed me to sword and I've tried it and it seems to work and is a bit friendlier than ODFweave or the xtable, hwriter and R2HTML options that I also know. Sweave and the whole transition to TeX/LaTeX, though I'd love it, just isn't a realistic option for me as my statistical/numerical work is done in a world in which pretty literally no-one uses TeX and I and many others who are part time with R will never have time to learn to go that way. (I promise myself I'll give it one determined try when I retire but even then all papers I submit to journals will have to be in Word or RTF.) Greg also kindly pointed me to the R-Plus GUI by Xlsolutions corp (http://www.youtube.com/watch?v=1qsv1MdB4tk) (thanks Greg) and that clearly has some of the formatted table output I'd like but it is also a huge shift towards the whole SPSS style pull down menus for everything and I really don't want that (and can't justify the price!) Come on R core team: I am sure there are a large number of users like Max Gunther and myself who would find this a huge help and I'm equally sure there are an even larger number of potential users who would change to R if we had formatted tables in the output window and the option to save that to HTML, TeX, ODF and ideally RTF. I think three quarters of the export/save primitives needed are there in these various add ons to R that alread exist and all that's needed on top of them is a simple screen rendering that would handle tables. (Graphics later or even never would be fine by me.) Yours in hope and huge appreciation for what we already have which I have been using a bit this last week and, as ever, marvelling at its power and simplicity ... and I didn't need tables from it for once! Regarding RTF, note that the Microsoft document that defines RTF was actually the subject of a dispute with competitors of Microsoft who claimed that it is so vague that it effectively imposes too high a barrier for others to climb to realistically interface to Word via RTF. One can only do it by supplementing the spec with substantial trial and error so its not so straight forward to develop RTF software. Having written such software for my commercial R package, RTFgen, which generates RTF from R I am quite aware of the problems. Since other commercial packages are being mentioned here I will add some info on this one too. The package is similar in concept to the hwriter and R2HTML packages on CRAN except that instead of generating HTML like those packages do it generates RTF that is directly readable by Word. Its single pass, i.e. it generates RTF directly so there is no intermediate document that might otherwise need to debugged during the development of a report. It is written in 100% R and requires no non-R software, not even Word, to generate reports making it trivial to deploy. __ 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] ggplot2 : bug in coord_equal() ?
Hello, I think there is a bug in coord_equal when x s a factor : ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar() ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar() + coord_equal(1/2) David __ 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] Random center effect
Hello R users, I'm trying to take into acount the center effect in a clinical study comparing 3 treatments (data from the book Applied Mixed Models in Medicine Statistics by Helen Brown and Robin Prescott): - dbp: diastolic blood pressure at 8 weeks - dbp0: diastolic blood pressure at inclusion - treat: three treatments A, B and C - centre: centres of the study First, I have fitted a marginal model with gls (nlme package), with a compound symmetry structure: require(nlme) gls1 - gls(dbp ~ factor(centre) + treat + dbp0, data = tension1, correlation = corCompSymm(form = ~ 1 | centre)) summary(gls1) anova(gls1) Denom. DF: 224 numDF F-value p-value (Intercept)1 33349.45 .0001 factor(centre)28 2.38 0.0003 treat 2 1.79 0.1700 dbp0 1 2.61 0.1075 Second, I tried to fit a random effect model with lme: lme1 - lme(dbp ~ factor(centre) + treat + dbp0, random = ~ 1 | centre, data = tension1) anova(lme1) numDF denDF F-value p-value (Intercept)1 224 3753.228 .0001 factor(centre)28 00.335 NaN treat 2 2241.786 0.1700 dbp0 1 2242.612 0.1075 Message d'avis : In pf(q, df1, df2, lower.tail, log.p) : production de NaN I thought this two models equivalent, and I don't understand why the fixed center effect produced NaN in lme model. I also tried with lmer (from lme4 package): require(lme4) lmer1 - lmer(dbp ~ factor(centre) + treat + dbp0 + (1 | centre), data = tension1) anova(lmer1) Analysis of Variance Table Df Sum Sq Mean Sq F value factor(centre) 28 1214.42 43.372 0.7026 treat 2 220.52 110.262 1.7862 dbp01 161.23 161.231 2.6118 F values for centre effect are very different in the 3 models. It is surely a naive question, but does someone could to me explain what happens here? Thank you very much in advance. Here the data : tension1 - structure(list(patient = c(1L, 3L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 13L, 14L, 15L, 18L, 19L, 23L, 24L, 25L, 28L, 30L, 31L, 32L, 34L, 35L, 36L, 37L, 38L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 60L, 63L, 64L, 70L, 71L, 72L, 73L, 74L, 80L, 81L, 82L, 84L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 116L, 117L, 118L, 119L, 120L, 122L, 124L, 125L, 127L, 128L, 129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 150L, 157L, 158L, 160L, 161L, 162L, 165L, 166L, 167L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 180L, 181L, 182L, 183L, 185L, 186L, 187L, 189L, 190L, 191L, 192L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 212L, 213L, 214L, 216L, 217L, 218L, 219L, 220L, 221L, 223L, 224L, 225L, 226L, 227L, 228L, 229L, 230L, 237L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L, 251L, 252L, 255L, 256L, 258L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L, 271L, 272L, 273L, 274L, 275L, 279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 290L, 291L, 292L, 293L, 294L, 301L, 302L, 303L, 304L, 305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 319L, 320L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 332L, 333L, 334L, 335L, 337L, 338L, 339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 350L, 352L, 355L, 357L, 361L, 362L, 363L, 364L, 365L, 366L), centre = c(29L, 5L, 5L, 29L, 3L, 3L, 3L, 3L, 3L, 36L, 36L, 36L, 36L, 5L, 5L, 5L, 15L, 15L, 15L, 4L, 4L, 4L, 4L, 4L, 23L, 23L, 7L, 7L, 7L, 7L, 7L, 7L, 30L, 30L, 30L, 30L, 30L, 18L, 18L, 18L, 18L, 18L, 24L, 23L, 35L, 35L, 35L, 27L, 27L, 1L, 1L, 1L, 1L, 26L, 26L, 26L, 26L, 26L, 14L, 14L, 14L, 14L, 14L, 14L, 11L, 11L, 11L, 11L, 11L, 11L, 7L, 7L, 7L, 7L, 7L, 7L, 6L, 6L, 6L, 6L, 6L, 32L, 32L, 32L, 25L, 25L, 25L, 25L, 25L, 25L, 31L, 31L, 31L, 31L, 31L, 14L, 14L, 14L, 14L, 14L, 14L, 37L, 37L, 37L, 37L, 31L, 31L, 31L, 31L, 31L, 13L, 13L, 13L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 9L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 31L, 31L, 31L, 31L, 31L, 31L, 8L, 8L, 8L, 8L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 36L, 36L, 36L, 36L, 36L, 36L, 40L, 40L, 41L, 14L, 14L, 14L, 14L, 14L, 14L, 4L, 4L, 4L, 4L, 4L, 4L, 36L, 36L, 36L, 1L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 25L, 26L, 26L, 26L, 26L, 12L, 12L, 12L, 12L, 12L, 15L, 15L, 15L, 15L, 15L, 15L, 1L, 1L, 1L, 1L, 1L, 1L, 36L, 36L, 36L, 36L, 36L, 31L, 31L, 31L, 31L, 31L, 31L, 1L, 1L, 1L, 1L, 14L, 14L, 14L, 14L, 14L, 14L, 31L, 31L, 31L, 31L, 31L, 31L, 1L, 1L, 36L, 36L, 31L, 31L, 31L, 31L, 31L, 31L), treat = structure(c(3L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 3L, 2L, 1L, 3L, 1L, 2L, 1L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 1L, 3L, 3L, 3L, 2L, 1L, 1L, 3L, 3L, 2L, 2L, 3L, 3L, 2L, 1L, 2L, 1L, 3L, 3L, 2L, 3L, 1L, 3L, 2L, 1L, 2L, 3L, 2L, 3L, 1L, 3L, 3L, 1L, 1L, 2L, 3L, 2L, 1L, 1L, 3L, 2L, 3L, 3L, 2L, 3L, 2L, 1L, 1L, 3L, 2L, 1L, 3L, 1L, 2L, 3L, 1L, 3L, 2L, 1L, 1L, 2L,
Re: [R] How to: highlight R syntax on webpages ?
Hello, ascii package provides a alternative to org-babel/R. it allows to use Sweave with org files (many thanks to Erik and his blog for this...). http://eusebe.github.com/ascii/#_other_outputs http://eusebe.github.com/ascii/org.html#undefined david 2009/11/20 Thomas S. Dye t...@tsdye.com Hi Erik, Interesting blog. I was pleased to see the reference to org-babel, a language-agnostic alternative to Sweave. Org-babel is a software masterpiece that anyone using emacs, LaTeX and R should know about, especially if they also use python, ruby, clojure, etc. All the best, Tom On Nov 20, 2009, at 10:02 AM, Erik Iverson wrote: Hello, I wrote a Wordpress blog entry about not only highlighting R syntax, but embedding R commands within an entry and using Sweave to produce the R output, all within Emacs. The output of the process is ready to paste Wordpress HTML, and a few other R blogs have started using it to generate their content. Disclaimer, the following is a link to my blog, but it describes a process you might be interested in: http://blogisticreflections.wordpress.com/2009/09/20/welcome-to-blogistic-reflections/ Best, Erik -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili Sent: Friday, November 20, 2009 12:27 PM To: r-help@r-project.org Subject: [R] How to: highlight R syntax on webpages ? My question if in the Subject, but if to extend: I am specifically curious about WordPress blogs. But any solution will give me a lead. Thanks, Tal -- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com/ (English) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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] [R-pkgs] ascii package updated
Hello, ascii package has been updated to version 0.3.2. ascii is a R package for writing asciidoc, txt2tags, sphinx or org documents with embeded R code. See http://eusebe.github.com/ascii/ for some examples. News since version 0.2 are: - new sphinx driver and output (see http://sphinx.pocoo.org/) - new org driver and output (see http://orgmode.org/) - ascii.simple.list method - ftable method - packageDescription method - sessionInfo method - new option label for list.type argument - new rownames and colnames arguments - cgroup argument works with txt2tags output - improve col alignment in txt2tags output - improve row and col span (cgroup and rgroup) - remove SweaveAscii() function - new Asciidoc(), T2t(), Sphinx() and Org() functions (wrapper for Sweave(file.Rnw, RweaveXxx)) Best, David Hajage [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] AsciiDoc and R
Hello, There is a webpage showing examples of asciidoc and R here : http://eusebe.github.com/ascii/ The package works with Sweave() function : Sweave(yourfile.Rnw, driver = RweaveAsciidoc) where youfile.Rnw is a text file with asciidoc markup and embedded R code. About asciidoc markup, the documentation is very complete: http://www.methods.co.nz/asciidoc/userguide.html For Mac OS X installation, I really have no idea, but perhaps this page may help you : http://www.lco.cl/Members/geychaner/Install%20instructions.html#asciidoc Best, David 2009/9/30 johannes rara johannesr...@gmail.com I would like to learn AsciiDoc. Is there any good examples how to use AsciiDoc with R? I know that there is packages called ascii to do this, but it would be nice to see some examples how AsciiDoc works with R. Is there an AsciiDoc distribution for Max OS X? -Johannes __ 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] latex code in R - convert to pdf
Hello, You could try : - odfWeave : to generate odf (open office...) report - R2HTML and hwriter : to generate html report - ascii : to generate asciidoc http://www.methods.co.nz/asciidoc/ report and then convert it to html, xml, pdf and more. 2009/9/17 Philipp Pagel p.pa...@wzw.tum.de On Thu, Sep 17, 2009 at 10:08:57AM +0200, Philipp Pagel wrote: is it possible to convert latex code to pdf in R (like a latex-program would do it)? Is there a package that comes with this capabilities? My problem is that I want to generate tables automatically - and I can't use a latex editor at that computer ... Besides latex ... are there good ways to generate tables in R? Have a look at Sweave and xtable - I think that's what you want. Charlies post made me aware that by latex editor you may mean that there is no LaTeX installation on your machine. In that case Sweave and xtable will obviously be of little use. If you have Openoffice on that computer package odfWeave may be the solution. If openoffice is not available, either, maybe package HTMLUtils would be another option (I haven't used it so far, so I may be wrong here). cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/http://webclu.bio.wzw.tum.de/%7Epagel/ __ 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] comma as decimal separator in xtable
Perhaps with the dcolumn package ? http://newton.ex.ac.uk/research/qsystems/people/latham/LaTeX/dcolumn.pdf David 2009/9/16 Jakson A. Aquino jaksonaqu...@gmail.com On Wed, Sep 16, 2009 at 07:11:46AM +0200, Schalk Heunis wrote: This might be of help, first applies the formatting:print(xtable(prettyNum(d, decimal.mark=,))) Thanks! Your solution works for the example that I gave. However, I failed to provide an example that really represent my problem because I'm passing a lm object to xtable. Currently, I'm using the following function, which also puts the table header in bold font: tabprint - function(x, ...) { colsani - function(x){paste({\\bf , x, }, sep = )} p - capture.output(print(x, caption.placement = top, sanitize.colnames.function = colsani, ...)) writeLines(p, /tmp/xtableOutPut) system(sed -i -e 's/\\([0-9]\\)\\.\\([0-9]\\)/\\1,\\2/g' /tmp/xtableOutPut) p - readLines(/tmp/xtableOutPut) cat(p, sep = \n) } tabprint(xtable(lm.model)) I could call gsub() if I knew the perl regular expression equivalent to the sed one that I'm using. On Tue, Sep 15, 2009 at 5:06 PM, Jakson A. Aquino jaksonaqu...@gmail.comwrote: Hello, How can I make xtable print a comma as decimal separator? Setting the option OutDec isn't enough for xtable: library(xtable) options(OutDec = ,) x - c(1.1, 1.2, 1.3) y - c(2.3, 2.2, 2.1) d - data.frame(x, y) d print(xtable(d)) Thanks! Jakson Aquino __ 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-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] comma as decimal separator in xtable
But, it seems that dcolumn can change the decimal separator too (see the table on the first page of the pdf document). For example: \documentclass{article} \usepackage{dcolumn} \newcolumntype{d}[1]{D{.}{,}{#1}} \begin{document} results=tex= x - matrix(rnorm(4), 2, 2) library(xtable) xtable(x, align = c(l, |, d{2}, |, c, |)) @ \end{document} 2009/9/16 Jakson A. Aquino jaksonaqu...@gmail.com On Wed, Sep 16, 2009 at 01:59:29PM +0200, David Hajage wrote: Perhaps with the dcolumn package ? http://newton.ex.ac.uk/research/qsystems/people/latham/LaTeX/dcolumn.pdf Thanks for the suggestion, but the problem isn't of alignment. When I have commas as decimal separators, the values are aligned because all values of each column were formated with the same number of digits. __ 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] tranform a table?
I think you could use reshape and ascii package here. Create a file (code.Rnw) with this code : John and Jane = = df - data.frame(names = c(John, Jane), field1 = c(value1, value2), field2 = c(value3, value4)) library(reshape) cdf - cast(melt(df, id = names), variable ~ . | names) @ results=ascii= library(ascii) ascii(cdf$Jane) ascii(cdf$John) @ Then from R, run : Sweave(code.Rnw, RweaveAsciidoc) Finally, use asciidoc http://www.methods.co.nz/asciidoc/ to convert the new file code.txt into html : asciidoc code.txt David On Thu, Sep 10, 2009 at 15:10, bbimber bim...@wisc.edu wrote: hello everyone, i'm new to R, so i hope you dont mind a fairly basic R question. we're using R to manipulate the results of SQL queries and create an HTML output. I'm starting with a table that looks essentially like this: NameField1 Field2 John value1 value2 Jane value3 value4 My table is stored as a dataframe. I'd like to efficiently produce an output that iterates through each row, transposes it and outputs an HTML table (one per row). like this: Name: John Field1: value1 Field2: value2 Name: Jane Field1: value3 Field2: value4 I can accomplish this by looping through each row, then outputting that row's table. This gets the job done, but it seems there must be a better way. I'm going to need to do this sort of conversion a lot, so the simpler the better. is there a better way to approach it than the code below? is there a more general term for the sort of transformation i'm trying to make that might help guide my searching? i realize i need to look into better methods of outputting HTML tables (like r2html). here's the basic idea. 'labkey.data' is the data frame produced by my SQL query: D-labkey.data H-colnames(D) T-t(D) L-length(D$id) output - for(i in 1:L) { R-my.row - D[i, ] R-t(R) Len-length(R) output - paste(output, table border=0) for(j in 1:Len) { output - paste(output,trtd, H[j],:/tdtd, R[j], /td) } output - paste(output, /tablep) } write(output, file=${htmlout:output}) Thanks for any help. -- View this message in context: http://www.nabble.com/tranform-a-table--tp25382806p25382806.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sweave and R. Searching for a document that will get me started
Sweave/LaTeX is the most powerfull tool to write document with embedded R code. The hard task is to learn LaTeX. But you could also have a look to packages: - R2HTML or hwriter if you prefer HTML markup, - odfWeave if you prefer write document with OpenOffice for example, - or ascii, if you want to write document with a very simple markup and multiple outputs (html, pdf...). 2009/8/7 Renaud Lancelot renaud.lance...@gmail.com Sweave was designed to embed R code within LaTeX documents. You REALLY need to learn a bit of LaTeX before using Sweave. There are many available documents on the Internet, e.g.: http://www.ctan.org/tex-archive/info/beginlatex/ http://tug.ctan.org/tex-archive/info/lshort/ 2009/8/7 John Sorkin jsor...@grecc.umaryland.edu: windows XP R 2.8.1 I would like to learn to use Sweave with R. I have no experience using Latex. I have looked at the sweave manual ( http://www.statistik.lmu.de/~leisch/Sweave/Sweave-manual.pdfhttp://www.statistik.lmu.de/%7Eleisch/Sweave/Sweave-manual.pdf) and have found it difficult to understand, probably because I don't know Latex. Can someone recommend a document that will get me started with Sweave? Thanks John Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ 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. -- Renaud Lancelot EDEN Project, coordinator http://www.eden-fp6project.net/ EDEN International Conference, Montpellier, 10-12 May 2010 http://international-conference2010.eden-fp6project.net/ UMR CIRAD-INRA Contrôle des maladies animales exotiques et émergentes Joint research unit Control of emerging and exotic animal diseases CIRAD, Campus International de Baillarguet TA A-DIR / B F34398 Montpellier http://www.cirad.fr http://bluetongue.cirad.fr/ Tel. +33 4 67 59 37 17 - Fax +33 4 67 59 37 95 Secr. +33 4 67 59 37 37 - Cell. +33 6 77 52 08 69 __ 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] storing output in html or pdf table format.
Or you can have a look to ascii package (examples here http://eusebe.github.com/ascii/or herehttp://www.ncfaculty.net/dogle/fishR/bookex/AIFFD/AIFFD.html ). david 2009/7/28 ONKELINX, Thierry thierry.onkel...@inbo.be Have a look at Sweave (in the utils package) or the R2HTML package. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Albert EINstEIN Verzonden: dinsdag 28 juli 2009 6:56 Aan: r-help@r-project.org Onderwerp: [R] storing output in html or pdf table format. Hi every one, Thanks for every one who are all supporting to us. we want some clarification on output in R. I have generated summary statistics output for dataset (E.g. sales) in output window. Now i want to store that output in a html or pdf in a table format. if possible can any one provide code for this one. Thanks in advance. -- View this message in context: http://www.nabble.com/storing-output-in-html-or-pdf-table-format.-tp2469 2508p24692508.htmlhttp://www.nabble.com/storing-output-in-html-or-pdf-table-format.-tp2469%0A2508p24692508.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] SAS-like method of recoding variables?
You can also use if (cond) then {something} if you don't like ifelse() function. See ?Control. David 2009/6/23 Peter Flom peterflomconsult...@mindspring.com Dieter Menne wrote: IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2); vehicles - ifelse(TYPE=='TRUCK' count=12, TRUCK+((CAR+BIKE)/2.2), NA) Read both versions to an audience, and you will have to admit that this is one of the cases where SAS is superior. And Peter Dalgaard replied That's not entirely clear. For instance, SAS is not being clear about what happens when the condition is FALSE. Well, OK, but then it is easy to add an ELSE, and I do find a structure such as IF X = 1 THEN ELSE IF X = 2 THEN ... ELSE X = quite a lot easier to both read and write than the equivalent in R. I also find the DO loops in SAS clear. SAS is also not distinguishing comparison and assignment, but then again you don't accidentally do count=12 when you mean count==12 As a generic matter, SAS (the DATA step) is generally good at things that are done by sequential sweeps through a data file. The shortcomings come in when you do things that can't be done sequentially, or require substantial rearranging of data first. x - ave(x,g,median) is an example which IIRC requires proc sort proc means by group (saving medians to data set) data step (merge and subtract) True. But two points: 1) Speaking only for me, but I use an IF THEN ELSE type structure a lot more often then I have to do something like the second example. 2) Again, speaking for me, the second sort of thing seems like it OUGHT to be hard, while IF THEN seems like it ought to be easy. This may be because I learned SAS before R Peter Peter L. Flom, PhD Statistical Consultant www DOT peterflomconsulting DOT com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Using package exams and xtable
Hello, \Sexpr only displays one value. Why don't you print your vector into a verbatim environment ? echo=F,results=verbatim print(rx) @ But if you want to generate a table with xtable, one solution : echo=F,results=tex print(xtable(as.data.frame(t(rx))), include.rownames = F, include.colnames = F) @ David On Tue, May 26, 2009 at 11:36 PM, M Berg dber...@gmail.com wrote: Hello, I am trying to use the package exams to construct problem sets. I have constructed an exercise which generates a list of integers and asks the student to compute the median. rx is the vector of n numbers str(rx) num [1:16] 21 9 8 18 4 12 17 2 9 7 ... I want to print out the entire vector as part of the problem. When I use \Sexpr(rx) only the first value (in this case 21) is printed out. I have been trying to get xtable to work. xtable(rx) Error in UseMethod(xtable) : no applicable method for xtable methods(xtable) [1] xtable.anova* xtable.aov* xtable.aovlist* [4] xtable.coxph* xtable.data.frame* xtable.glm* [7] xtable.lm* xtable.matrix* xtable.prcomp* [10] xtable.summary.aov* xtable.summary.aovlist* xtable.summary.glm* [13] xtable.summary.lm* xtable.summary.prcomp* xtable.table* [16] xtable.ts* xtable.zoo* Non-visible functions are asterisked I am new to R and would appreciate any suggestions. What is the best way to get exams/Sweave to print out the entire vector? Thanks in advance. DBerg [[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. [[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] RweaveHTML (R2HTML) Help
Hello Derek, Unfortunately, I can't help you with R2HTML. But if you want to generate html output of R commands, you could also try ascii package http://eusebe.github.com/ascii/ (available on CRAN). Here an example file (example.Rnw, with asciidoc http://www.methods.co.nz/asciidocmarkup) : Example === :Author:Your Name :Email: n...@whatever.com = data(iris) summary(iris) @ Then, you can use RweaveAsciidoc driver : library(ascii) Le chargement a nécessité le package : proto Sweave(example.Rnw, RweaveAsciidoc) Writing to file example.txt Processing code chunks ... 1 : echo term verbatim You can now run asciidoc on 'example.txt' And then use asciidoc to generate your html file (see asciidoc homepagehttp://www.methods.co.nz/asciidocfor installation and use). asciidoc example.txt You'll find the html file produced in attachement. Best. david 2009/4/29 Derek Ogle do...@northland.edu I have found Sweave() to be great for producing PDF documents. I have been experimenting with RweaveHTML (from the R2HTML) package and have had moderate success. My main issue has been that I simply want the R output to be shown verbatim in the HTML document but RweaveHTML tends to convert most output to a table, for example. So, is there a way to force the RweaveHTML driver to simply provide the output of a function exactly as it would appear in the R console window? Thanks in advance for any help. A minimal reproducible example of my .rnw file is below ... html body pThis is an example/p = data(iris) summary(iris) @ /body /html which if I saved as test.rnw I would use ... library(R2HTML) sweave(test.rnw,driver=RweaveHTML()) ... which will produce test.html which looks like ... html link rel=stylesheet type=text/css href=R2HTML.cssbody pThis is an example/p !-- begin{Schunk} !-- !-- begin{Sinput} !-- pxmp class=command data(iris)/xmp/p pxmp class=command summary(iris)/xmp/p !-- end{Sinput} !-- p align= center table cellspacing=0 border=1caption align=bottom class=captiondataframe/captiontrtd table border=0 class=dataframe tbody tr class= firstline th/thth Sepal.Length/thth Sepal.Width/thth Petal.Length/thth Petal.Width/thth Species/th /tr trtd class=firstcolumn/tdtd class=cellinsideMin. :4.300 /tdtd class=cellinsideMin. :2.000 /tdtd class=cellinsideMin. :1.000 /tdtd class=cellinsideMin. :0.100 /tdtd class=cellinsidesetosa:50 /td/tr trtd class=firstcolumn/tdtd class=cellinside1st Qu.:5.100 /tdtd class=cellinside1st Qu.:2.800 /tdtd class=cellinside1st Qu.:1.600 /tdtd class=cellinside1st Qu.:0.300 /tdtd class=cellinsideversicolor:50 /td/tr trtd class=firstcolumn/tdtd class=cellinsideMedian :5.800 /tdtd class=cellinsideMedian :3.000 /tdtd class=cellinsideMedian :4.350 /tdtd class=cellinsideMedian :1.300 /tdtd class=cellinsidevirginica :50 /td/tr trtd class=firstcolumn/tdtd class=cellinsideMean :5.843 /tdtd class=cellinsideMean :3.057 /tdtd class=cellinsideMean :3.758 /tdtd class=cellinsideMean :1.199 /tdtd class=cellinsideNA /td/tr trtd class=firstcolumn/tdtd class=cellinside3rd Qu.:6.400 /tdtd class=cellinside3rd Qu.:3.300 /tdtd class=cellinside3rd Qu.:5.100 /tdtd class=cellinside3rd Qu.:1.800 /tdtd class=cellinsideNA /td/tr trtd class=firstcolumn/tdtd class=cellinsideMax. :7.900 /tdtd class=cellinsideMax. :4.400 /tdtd class=cellinsideMax. :6.900 /tdtd class=cellinsideMax. :2.500 /tdtd class=cellinsideNA /td/tr /tbody /table /td/table br !--\end{Schunk}!-- /body /html Session Info R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods base other attached packages: [1] pda_1.2-3 MASS_7.2-46lme4_0.999375-28 Matrix_0.999375-22 lattice_0.17-20car_1.2-12 NCStats_0.1-1 [8] sciplot_1.0-4 plotrix_2.5-4 nortest_1.0 svSocket_0.9-5 TinnR_1.0.2R2HTML_1.59Hmisc_3.5-2 loaded via a namespace (and not attached): [1] cluster_1.11.12 gdata_2.4.2 gplots_2.6.0 grid_2.8.0 gtools_2.5.0-1svMisc_0.9-5 TeachingDemos_2.3 tools_2.8.0 [[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. Example Your Name [1]n...@whatever.com data(iris) summary(iris) Sepal.LengthSepal.Width Petal.Length
Re: [R] plot confidence intervals as shaded band
Perhaps you'll be interested in denstrip package : http://cran.r-project.org/web/packages/denstrip/index.html Examples : http://www.mrc-bsu.cam.ac.uk/personal/chris/papers/denstrip.pdf 2009/4/22 BARRES-DE-ALMEIDA U. u.b.alme...@durham.ac.uk Hi, does anyone know how do I plot confidence intervals as a shaded band around a curve, rather than as errors bars? many thanks, ulisses. [[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. [[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] rbind on a list
I have two lists (and possibly more): col.prop - structure(list(B = structure(c(0.5, 0.5, 0.6, 0.4, 0.556, 0.444), class = c(cast_matrix, matrix), .Dim = 2:3, .Dimnames = list( NULL, NULL)), D = structure(c(1, 0, 0.667, 0.333, 0.8, 0.2), class = c(cast_matrix, matrix), .Dim = 2:3, .Dimnames = list( NULL, NULL))), .Names = c(B, D)) n - structure(list(B = c(4, 5, 9), D = c(4, 6, 10)), .Names = c(B, D)) col.prop $B [,1] [,2] [,3] [1,] 0.5 0.6 0.556 [2,] 0.5 0.4 0.444 $D [,1] [,2] [,3] [1,]1 0.667 0.8 [2,]0 0.333 0.2 n $B [1] 4 5 9 $D [1] 4 6 10 I would like to rbind each element with the corresponding element of each list ($B with $B and $D with $D): res $B [,1] [,2] [,3] [1,] 0.5 0.6 0.556 [2,] 0.5 0.4 0.444 [3,]45 9 $D [,1] [,2] [,3] [1,]1 0.667 0.8 [2,]0 0.333 0.2 [3,]4 6 10 I've made an ugly loop to do this... Is there an easier way? Thank you very much. David [[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] rbind on a list
Thank you, it is working. David 2009/4/23 Henrique Dallazuanna www...@gmail.com Try this: lapply(names(col.prop), function(idx)rbind(col.prop[[idx]], n[[idx]])) On Thu, Apr 23, 2009 at 7:33 AM, David Hajage dhajag...@gmail.com wrote: I have two lists (and possibly more): col.prop - structure(list(B = structure(c(0.5, 0.5, 0.6, 0.4, 0.556, 0.444), class = c(cast_matrix, matrix), .Dim = 2:3, .Dimnames = list( NULL, NULL)), D = structure(c(1, 0, 0.667, 0.333, 0.8, 0.2), class = c(cast_matrix, matrix), .Dim = 2:3, .Dimnames = list( NULL, NULL))), .Names = c(B, D)) n - structure(list(B = c(4, 5, 9), D = c(4, 6, 10)), .Names = c(B, D)) col.prop $B [,1] [,2] [,3] [1,] 0.5 0.6 0.556 [2,] 0.5 0.4 0.444 $D [,1] [,2] [,3] [1,]1 0.667 0.8 [2,]0 0.333 0.2 n $B [1] 4 5 9 $D [1] 4 6 10 I would like to rbind each element with the corresponding element of each list ($B with $B and $D with $D): res $B [,1] [,2] [,3] [1,] 0.5 0.6 0.556 [2,] 0.5 0.4 0.444 [3,]45 9 $D [,1] [,2] [,3] [1,]1 0.667 0.8 [2,]0 0.333 0.2 [3,]4 6 10 I've made an ugly loop to do this... Is there an easier way? Thank you very much. David [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] cast function in package reshape
Hello R useRs, I have a function which returns a list of functions : freq1 - function(x) { lev - unique(x[!is.na(x)]) nlev - length(lev) args - alist(x=) if (nlev == 1) { body - c({, sum(!is.na(x)), }) f - function() {} formals(f) - as.pairlist(args) body(f) - parse(text = body) namef - paste(freq, as.character(nlev), sep = _) assign(namef, f) res - list(get(namef)) names(res) - namef } if (nlev 1) { res - NULL namesf - NULL for (i in 1:nlev) { body - c({, paste(sum(x[!is.na(x)] ==, as.character(lev[i]), ), sep = ), }) f - function() {} formals(f) - as.pairlist(args) body(f) - parse(text = body) namef - paste(freq, as.character(lev[i]), sep = _) assign(namef, f) namesf - c(namesf, namef) res - c(res, get(namef)) } names(res) - namesf } return(res) } df - data.frame(id = 1:50, x = sample(c(NA, 1), 50, T), y = sample(1:2, 50, T), z = sample(letters[1:2], 50, T)) freq1(df$x) $freq_1 function (x) { sum(!is.na(x)) } environment: 0x03d99684 freq1(df$y) $freq_2 function (x) { sum(x[!is.na(x)] == 2) } environment: 0x03d6c930 $freq_1 function (x) { sum(x[!is.na(x)] == 1) } environment: 0x03d6c930 I would like to use this list of functions with cast function (in package reshape by Hadley Wickham) : cast(melt(df, id = c(id, z), measure = c(x, y)), variable + result_variable ~ z, fun = function(x) freq1(x), margins = grand_col) Erreur dans freq1(x) : objet res non trouvé Here the result I would like to have : variable a b (all) 1x freq_1 10 1424 2y freq_1 18 3250 3y freq_2 9 1423 I admit it is a bit far-fetched, but is this actually possible ? Thank you very much. David [[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] Presenting R Results in Webpages
You could perhaps use asciidoc http://www.methods.co.nz/asciidoc/and ascii http://eusebe.github.com/ascii/package (but I'm not sure you could obtain exactly the layout you describe...). 2009/4/17 Jim Lemon j...@bitwrit.com.au Jason Rupert wrote: I apologize in advance that this question is not specific to R, but I thought some R users may be using this in their work process flow. I would like to be able to have a tool (prefer scriptable) that will take two images and some pre-written text and put it on an simple webpage. That is, it would look something like the following: |-| |Title| | | | || || Some basic txt | | | Image1 | | Image2 | ... | | || || ... | |_| R comes in because I have R scripts creating the images I would like to import. There will be 14-18 pages of these type of slides, but the key is we will be producing these over and over. I tried doing something like this in PowerPoint, but not impressed with the linking capability or Macros. Thanks for any feedback and again appologize that this is not exactly a specific R question. Hi Jason, You could do something similar with htmlize in the prettyR package, and get exactly what you want with a bit of HTML editing. Get an R script that will generate the two images, then the text. Then insert a few tags like this: (All of the HTML before the first image) table tr td img src=Image1.png td img src=Image2.png td Text that you want in the right hand cell /table (the rest of the HTML) Jim __ 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] Presenting R Results in Webpages
and also R2HTML. 2009/4/17 David Hajage dhajag...@gmail.com You could perhaps use asciidoc http://www.methods.co.nz/asciidoc/and ascii http://eusebe.github.com/ascii/package (but I'm not sure you could obtain exactly the layout you describe...). 2009/4/17 Jim Lemon j...@bitwrit.com.au Jason Rupert wrote: I apologize in advance that this question is not specific to R, but I thought some R users may be using this in their work process flow. I would like to be able to have a tool (prefer scriptable) that will take two images and some pre-written text and put it on an simple webpage. That is, it would look something like the following: |-| |Title| | | | || || Some basic txt | | | Image1 | | Image2 | ... | | || || ... | |_| R comes in because I have R scripts creating the images I would like to import. There will be 14-18 pages of these type of slides, but the key is we will be producing these over and over. I tried doing something like this in PowerPoint, but not impressed with the linking capability or Macros. Thanks for any feedback and again appologize that this is not exactly a specific R question. Hi Jason, You could do something similar with htmlize in the prettyR package, and get exactly what you want with a bit of HTML editing. Get an R script that will generate the two images, then the text. Then insert a few tags like this: (All of the HTML before the first image) table tr td img src=Image1.png td img src=Image2.png td Text that you want in the right hand cell /table (the rest of the HTML) Jim __ 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] performing function on data frame
Hi Karin, I'm not sure I understand... Is this what you want ? d$y - mean(d$y)/sd(d$y) 2009/4/15 Karin Lagesen karin...@ifi.uio.no Hi! First, pardon me if this is a faq. I think I should be using some sort of apply, but I am not managing to figure those out. I have a data frame similar to this: d - data.frame(x = LETTERS[1:5], y = rnorm(5), z = rnorm(5)) d x y z 1 A 0.1605464 -0.2719820 2 B -0.9258660 1.2623117 3 C -0.3602656 1.5470351 4 D 1.2621797 1.2996500 5 E 0.6021728 0.5027095 From this I want to get a new data frame which contains the z scores based on the values found in each row. For instance for element [C,y], I would like to calculate (-0.3602656 - mean(column y)/stddev(column y)). Thanks! -- Karin Lagesen, Ph.D. karin.lage...@medisin.uio.no http://folk.uio.no/karinlag __ 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] [R-pkgs] New package: ascii version 0.1
Hi, ascii is a new R package for writing asciidoc or txt2tags document with embeded R commands. It provides: - a generic method for common R objects: ascii(). Default argument depends of R object. - two Sweave drivers: Sweave(yourfile.Rnw, RweaveAsciidoc) or Sweave(yourfile.Rnw, RweaveT2t). This package is very similar to xtable or R2HTML. It is very interesting if you want to produce multiple output from one source. You could find some examples on http://eusebe.github.com/ascii/. Comments and suggestions are welcome ! Best, David [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] Insert value in a Vector Alternately
2009/2/19 baptiste auguie ba...@exeter.ac.uk Perhaps you can try this, d - c(0.00377467, 0.00377467, 0.00377467, 0.00380083, 0.00380083, 0.00380083, 0.00380959, 0.00380959, 0.00380959, 0.00380083, 0.00380083, 0.00380083) c( t( cbind(matrix(d, ncol=3, byrow=T), 0))) I don't know how to avoid the transpose operation that might slow things down in large cases Like that ? c(rbind(matrix(dat, nrow = 3), 0)) david Hope this helps, baptiste On 19 Feb 2009, at 12:47, jim holtman wrote: How about this: dat-c(0.00377467,0.00377467,0.00377467,0.00380083,0.00380083,0.00380083,0.00380959, + 0.00380959,0.00380959,0.00380083,0.00380083,0.00380083) dat[seq(1, by=3, to=length(dat))] - 0 dat [1] 0. 0.00377467 0.00377467 0. 0.00380083 0.00380083 0. 0.00380959 0.00380959 0. 0.00380083 [12] 0.00380083 On Thu, Feb 19, 2009 at 1:47 AM, Gundala Viswanath gunda...@gmail.com wrote: Hi, I have a vector that look like this: dat V1 V2 V3 V4 V5 V6 0.00377467 0.00377467 0.00377467 0.00380083 0.00380083 0.00380083 V7 V8 V9V10V11V12 0.00380959 0.00380959 0.00380959 0.00380083 0.00380083 0.00380083 what I want to do is to insert 0 (zero) for every 3 position yielding: V1 V2 V3V4 V5V6 V7 V8 0 0.00377467 0.00377467 0.00377467 0 0.00380083 0.00380083 0.00380083 V9 V10 V11V12 V13V14 V15 V16 0 0.00380959 0.00380959 0.00380959 0 .00380083 0.00380083 0.00380083 Is there a quick way to do it in R? - Gundala Viswanath Jakarta - Indonesia __ 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. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ 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] table with 3 variables
And I would like to group the Subject by Quarter using as a result in the table the value of the third variable (Boolean). The final result would give: Subjet Q1 Q2 Q3 Q4 1100 Y Y Y Y 2101 N N N N Are you sure that this is the final result you want ? You could use the reshape package (and not reshape function) : library(reshape) truc - data.frame(Subject=rep(100:101, each=4), Quarter=rep(paste(Q,1:4,sep=),2), Boolean = rep(c(Y,N),4)) mtruc - melt(truc, id = c(Subject, Quarter)) cast(mtruc, Subject ~ Quarter) Final result : Subject Q1 Q2 Q3 Q4 1 100 Y N Y N 2 101 Y N Y N 2009/2/19 Pascal Candolfi pcando...@gmail.com I have the initial matrice: *data.frame(Subject=rep(100:101, each=4), Quarter=rep(paste(Q,1:4, sep=),2), Boolean = rep(c(Y,N),4))* Subject Quarter Boolean 1100 Q1 Y 2100 Q2 N 3100 Q3 Y 4100 Q4 N 5101 Q1 Y 6101 Q2 N 7101 Q3 Y 8101 Q4 N ... And I would like to group the Subject by Quarter using as a result in the table the value of the third variable (Boolean). The final result would give: Subjet Q1 Q2 Q3 Q4 1100 Y Y Y Y 2101 N N N N ... I started using the *table(Subject, Quarter)* but can't find a way to correspond the Boolean information in the table Thanks in advance for the ideas... Pascal Candolfi [[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. [[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] table with 3 variables
Sorry, you don't need 'melt' : cast(truc, Subject ~ Quarter) 2009/2/19 David Hajage dhajag...@gmail.com And I would like to group the Subject by Quarter using as a result in the table the value of the third variable (Boolean). The final result would give: Subjet Q1 Q2 Q3 Q4 1100 Y Y Y Y 2101 N N N N Are you sure that this is the final result you want ? You could use the reshape package (and not reshape function) : library(reshape) truc - data.frame(Subject=rep(100:101, each=4), Quarter=rep(paste(Q,1:4,sep=),2), Boolean = rep(c(Y,N),4)) mtruc - melt(truc, id = c(Subject, Quarter)) cast(mtruc, Subject ~ Quarter) Final result : Subject Q1 Q2 Q3 Q4 1 100 Y N Y N 2 101 Y N Y N 2009/2/19 Pascal Candolfi pcando...@gmail.com I have the initial matrice: *data.frame(Subject=rep(100:101, each=4), Quarter=rep(paste(Q,1:4, sep=),2), Boolean = rep(c(Y,N),4))* Subject Quarter Boolean 1100 Q1 Y 2100 Q2 N 3100 Q3 Y 4100 Q4 N 5101 Q1 Y 6101 Q2 N 7101 Q3 Y 8101 Q4 N ... And I would like to group the Subject by Quarter using as a result in the table the value of the third variable (Boolean). The final result would give: Subjet Q1 Q2 Q3 Q4 1100 Y Y Y Y 2101 N N N N ... I started using the *table(Subject, Quarter)* but can't find a way to correspond the Boolean information in the table Thanks in advance for the ideas... Pascal Candolfi [[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. [[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] error message with roxygen
I have found something there : https://lists.r-forge.r-project.org/pipermail/roxygen-devel/2009-January/16.html In order to do static callgraphs, the package itself has to be loadable; that's unfortunate in the sense that you may have to install the package before generating the docs. But I can't understand what I must do in my short example... Thank you for any help. david 2009/1/30 David Hajage dhajag...@gmail.com Hello useRs, I'm trying to use the Roxygen package. Here my code file : #' A packge to check Roxygen's sanity #' @name helloRoxygen-package #' @docType package NA And my R code to generate the package : library(roxygen) package.skeleton(helloRoxygen, code_files = roxy.r, force = T) roxygenize(helloRoxygen, helloRoxygen, copy.package = F, unlink.target = F, overwrite = T) I obtain this error message : Writing helloRoxygen-package to helloRoxygen/man/helloRoxygen-package.Rd Writing namespace directives to helloRoxygen/NAMESPACE Merging collate directive with helloRoxygen/DESCRIPTION to helloRoxygen/DESCRIPTION *Avis dans load.dependencies() : Package(s) 'helloRoxygen' wouldn't load; callgraphs might be incomplete. * I don't understand what this means. I'm doing something wrong? Thank you for your help. Best regards, david [[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] error message with roxygen
Thank you Hadley! 2009/2/2 hadley wickham h.wick...@gmail.com On Fri, Jan 30, 2009 at 3:49 AM, David Hajage dhajag...@gmail.com wrote: Hello useRs, I'm trying to use the Roxygen package. Here my code file : #' A packge to check Roxygen's sanity #' @name helloRoxygen-package #' @docType package NA And my R code to generate the package : library(roxygen) package.skeleton(helloRoxygen, code_files = roxy.r, force = T) roxygenize(helloRoxygen, helloRoxygen, copy.package = F, unlink.target = F, overwrite = T) I obtain this error message : Writing helloRoxygen-package to helloRoxygen/man/helloRoxygen-package.Rd Writing namespace directives to helloRoxygen/NAMESPACE Merging collate directive with helloRoxygen/DESCRIPTION to helloRoxygen/DESCRIPTION *Avis dans load.dependencies() : Package(s) 'helloRoxygen' wouldn't load; callgraphs might be incomplete.* I don't understand what this means. I'm doing something wrong? That's not an error - just a warning. You can't get complete call graphs (if you need them) unless you've already installed your helloRoxygen package. If you're not using the call graphs, don't worry about it. Hadley -- http://had.co.nz/ [[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] sub question
Thank you, it's perfect. david 2009/1/30 Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no David Hajage wrote: Hello R users, I have a string, for example: x - \t\tabc\t def This string can contain any number of tabulations. I want to replace each tabulation of the begining of the string by the same number of space: abc\t def I'm trying to do this with gsub : gsub(\t, , x) # replace every \t [1] abc def sub(^\t, , x) # replace only the first \t [1] \tabc\t def sub(^\t*, , x) # replace all beginning \t, but only one space [1] abc\t def How can I do this ? there may be better solutions, but this should do: strings = c('pure', '\t- 1 removed', '\t\t- 2 removed, 1 left -\t') gsub('\t|(*COMMIT)(*FAIL)', ' ', strings, perl=TRUE) # pure - 1 removed - 2 removed, 1 left -\t vQ [[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] error message with roxygen
Hello useRs, I'm trying to use the Roxygen package. Here my code file : #' A packge to check Roxygen's sanity #' @name helloRoxygen-package #' @docType package NA And my R code to generate the package : library(roxygen) package.skeleton(helloRoxygen, code_files = roxy.r, force = T) roxygenize(helloRoxygen, helloRoxygen, copy.package = F, unlink.target = F, overwrite = T) I obtain this error message : Writing helloRoxygen-package to helloRoxygen/man/helloRoxygen-package.Rd Writing namespace directives to helloRoxygen/NAMESPACE Merging collate directive with helloRoxygen/DESCRIPTION to helloRoxygen/DESCRIPTION *Avis dans load.dependencies() : Package(s) 'helloRoxygen' wouldn't load; callgraphs might be incomplete.* I don't understand what this means. I'm doing something wrong? Thank you for your help. Best regards, david [[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] sub question
Hello R users, I have a string, for example: x - \t\tabc\t def This string can contain any number of tabulations. I want to replace each tabulation of the begining of the string by the same number of space: abc\t def I'm trying to do this with gsub : gsub(\t, , x) # replace every \t [1] abc def sub(^\t, , x) # replace only the first \t [1] \tabc\t def sub(^\t*, , x) # replace all beginning \t, but only one space [1] abc\t def How can I do this ? Thank you very much. david [[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] connecting boxplots
Or with package ggplot2 : library(ggplot2) c - qplot(cyl, mpg, data=mtcars) c + geom_boxplot(aes(group = factor(cyl))) + stat_summary(fun = median, geom = line, colour = red) + stat_summary(fun = function(x) min(x), geom = line, colour = blue) + stat_summary(fun = function(x) max(x), geom = line, colour = green) 2009/1/11 johnhj jhar...@web.de Hii, I created some boxplots with this commands: x -read.table(file=test.txt) x$group - rep(1:8, each=5) boxplot(V3~gruppe, data=x) Now, I will connect the boxplots to each other to the min, max and median values. Can anybody help me how to do it ? greetings, J -- View this message in context: http://www.nabble.com/connecting-boxplots-tp21405459p21405459.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] grep : escape *
Dear R useRs, Sorry for this foolish question, but I can't find how to escape the * character when using grep : grep(-, c(/3, 2*3, 4-4)) [1] 3 grep(/, c(/3, 2*3, 4-4)) [1] 1 grep(*, c(/3, 2*3, 4-4)) Erreur dans grep(*, c(/3, 2*3, 4-4)) : expression régulière incorrecte '*' De plus : Warning message: In grep(*, c(/3, 2*3, 4-4)) : erreur rgcomp : 'Expression régulière précédente incorrecte' grep(\*, c(/3, 2*3, 4-4)) Erreur dans grep(*, c(/3, 2*3, 4-4)) : expression régulière incorrecte '*' De plus : Warning messages: 1: '\*' est un code escape non reconnu dans une chaîne de caractères 2: code escape non reconnu éliminé de \* 3: In grep(*, c(/3, 2*3, 4-4)) : erreur rgcomp : 'Expression régulière précédente incorrecte' Best regards, david [[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] grep : escape *
oooups. Thank you very much. 2009/1/9 Duncan Murdoch murd...@stats.uwo.ca On 1/9/2009 10:38 AM, David Hajage wrote: Dear R useRs, Sorry for this foolish question, but I can't find how to escape the * character when using grep : You use a backslash to escape the *. Unfortunately, to enter a backslash in an R string, you need to escape it. So the pattern is \\*. Duncan Murdoch grep(-, c(/3, 2*3, 4-4)) [1] 3 grep(/, c(/3, 2*3, 4-4)) [1] 1 grep(*, c(/3, 2*3, 4-4)) Erreur dans grep(*, c(/3, 2*3, 4-4)) : expression régulière incorrecte '*' De plus : Warning message: In grep(*, c(/3, 2*3, 4-4)) : erreur rgcomp : 'Expression régulière précédente incorrecte' grep(\*, c(/3, 2*3, 4-4)) Erreur dans grep(*, c(/3, 2*3, 4-4)) : expression régulière incorrecte '*' De plus : Warning messages: 1: '\*' est un code escape non reconnu dans une chaîne de caractères 2: code escape non reconnu éliminé de \* 3: In grep(*, c(/3, 2*3, 4-4)) : erreur rgcomp : 'Expression régulière précédente incorrecte' Best regards, david [[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. [[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] Problem with ggplot2 - facet_wrap and boxplot
Hello R users and Hadley, Back again with a little problem in ggplot2 =o) (ggplot 0.8.1, R 2.8.0) Here the problem : library(ggplot2) df - data.frame(id = 1:100, x1 = c(rnorm(50), rnorm(50, 1)), x2 = c(rnorm(50), rnorm(50, 1.5)), x3 = c(rnorm(50, 0.5), rnorm(50, 2.5)), group = as.factor(rep(c(a, b), each = 50))) df.melt - melt(df, id = c(id, group)) head(df.melt) p - ggplot(df.melt, aes(variable, value)) p + geom_boxplot(aes(fill = group)) # This graph is great, but I would like to have two panels, one for group 'a', and one for group 'b' # With this code, I can't have one boxplot for each variable x1, x2 and x3 p + geom_boxplot(aes(fill = group)) + facet_wrap(~group) # but it's working with geom_point p + geom_point(aes(color = group)) + facet_wrap(~group) Best regards. david [[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] Problem with ggplot2 - facet_wrap and boxplot
o. Well, it's working (replace 'group' by 'trt') Thank you very much Hadley. david 2009/1/7 hadley wickham h.wick...@gmail.com Hi David, Here the problem : library(ggplot2) df - data.frame(id = 1:100, x1 = c(rnorm(50), rnorm(50, 1)), x2 = c(rnorm(50), rnorm(50, 1.5)), x3 = c(rnorm(50, 0.5), rnorm(50, 2.5)), group = as.factor(rep(c(a, b), each = 50))) df.melt - melt(df, id = c(id, group)) head(df.melt) p - ggplot(df.melt, aes(variable, value)) p + geom_boxplot(aes(fill = group)) # This graph is great, but I would like to have two panels, one for group 'a', and one for group 'b' # With this code, I can't have one boxplot for each variable x1, x2 and x3 p + geom_boxplot(aes(fill = group)) + facet_wrap(~group) # but it's working with geom_point p + geom_point(aes(color = group)) + facet_wrap(~group) This is an annoying bug I haven't figure out how to fix yet. The basic problem is that if you facet by a variable that has the same name as an aesthetic, it overrides that aesthetic (group in this case). Unfortunately, currently the only work around is call the variable something other than group. Regards, Hadley -- http://had.co.nz/ [[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] Calculating Sensitivity, Specificity, and Agreement from Logistics Regression Model
Deer Meir, You could take a look at lroc() from epicalc package. Or calculate all that yourself : the linear fit of the model are in yourmodel$linear.predicators Best regards, david 2008/12/18 Meir Preiszler pm...@itamar-medical.com Hi, Assume I have a variable Y having two discrete values and two predictor variables x1 and x2. I then do a logistic regression model fit as: fit-glm(Y~x1+x2,family=binomial). Are there functions in R than calculate the Sensitivity, Specificity , and Agreement of the model fit? Thanks Meir Meir Preiszler - Research Engineer I t a m a r M e d i c a l Ltd. Caesarea, Israel: Tel: +(972) 4 617 7000 ext 232 Fax: +(972) 4 627 5598 Cell: +(972) 54 699 9630 Email: pm...@itamar-medical.com Web: www.Itamar-medical.com * 88---8--- This E-mail is confidential information of Itamar medical Ltd. It may also be legally privileged. If you are not the addressee you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return E-mail. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. Before printing this email , kindly think about the environment. Itamar Medical Ltd. MIS Yan Malgin. 88---8--- [[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. [[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] merging data.frames columnwise (rbind with different variables, lengths)
Dear Stefan, You could use rbind.fill() from reshape package : install.packages(reshape) library(reshape) df1 - data.frame(A = c(1,2), B = c(m,f), C = c(at home, away)) df2 - data.frame(A = c(2), C = c(at home)) rbind.fill(df1, df2) AB C 1 1m at home 2 2faway 3 2 NA at home 2008/12/11 Stefan Uhmann [EMAIL PROTECTED] Dear List, I have two dataframes with overlapping colnames and want to merge them. Actually, what I want is more similar to rbind, but the dataframes differ in their columns. Here are the examples: df1 - data.frame(A = c(1,2), B = c(m,f), C = c(at home, away)) df2 - data.frame(A = c(2), C = c(at home)) Here the desired result: A BC 1 1 m at home 2 2 f away 3 2 NA at home Thanks for any help, Stefan __ 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] How to add accuracy, sensitivity, specificity to logistic regression output?
You could calculate this yourself, with the result object ( yourobject$linear.predicators). 2008/12/9 pufftissue pufftissue [EMAIL PROTECTED] Hi, Is there a way when doing logistic regression for the output to spit out accuracy, sensitivity, and specificity? I would like to know these basic measures for my model. Thanks! [[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. [[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] ggplot2 - suggestion for facet_wrap/grid
Hello R users (and Hadley), facet_wrap and facet_grid function are both very usefull. But they are perhaps a bit redundant. I probably don't see the advantage of two separate functions, but what do you think of this suggestion : add 'nrow' and 'ncol arguments to facet_grid. These arguments would have an effect only if user draws a 1d ribbon of panels (~ var1+ ...). Thank you very much for this wonderfull package. Best regards. david [[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] ggplot2 facet_wrap problem
yes, I think this is the bug that will be fixed in the next release : http://github.com/hadley/ggplot2/tree/master/NEWS 2008/12/3 ONKELINX, Thierry [EMAIL PROTECTED] Hi Stephen, It looks like a bug in facet_wrap which seems to mix up the factor labels (by sorting only the labels but not the plots?). HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: stephen sefick [mailto:[EMAIL PROTECTED] Verzonden: woensdag 3 december 2008 1:09 Aan: ONKELINX, Thierry CC: hadley wickham; R-help Onderwerp: Re: [R] ggplot2 facet_wrap problem If you look at the TSS graph in the faceted example and then look at the plot of just the GPP vs. TSS. They are different graphs all together. The one that is not faceted is correct. On Tue, Dec 2, 2008 at 6:36 PM, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Hi Stephen, I think you will need to clarify what your problem is with the second plot. HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] namens stephen sefick Verzonden: di 2-12-2008 22:52 Aan: hadley wickham; R-help Onderwerp: [R] ggplot2 facet_wrap problem Hadley, I don't know if I am doing something wrong or if it is ggplot please see the two graphs at the bottom of the page (code). melt.nut - (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L,
[R] Fwd: ggplot2 - suggestion for facet_wrap/grid
2008/12/3 hadley wickham [EMAIL PROTECTED] Hi David, facet_wrap and facet_grid function are both very usefull. But they are perhaps a bit redundant. I disagree ;) I was sure :-) Conceptually they are rather different: facet_wrap is essentially a 1d layout, while facet_grid is a 2d layout. This has implications for how you specify the faceting, how the facets are labelled, and how the scales can vary. While I could probably force both into a single function, this is rather against the philosophy of ggplot2, which strives towards small objects which only do one thing. This tends to make things a little more verbose, but I think it makes things easier to understand. OK. I thought that facet_wrap was created to control the layout of facet_grid plot with one-side formula, since a facet_grid plot with one-side formula should be (almost?) identical with a facet_wrap plot with nrow (or ncol) = 1. By the way, I've just test this thing to see the diffences between the two plots : d - ggplot(diamonds, aes(carat, price, fill = ..density..)) + xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1) ## from official documentation d + facet_grid(~ color) d + facet_wrap(~ color) d + facet_wrap(~ color, nrow = 1) Erreur dans rep(list(nullGrob()), nrow * ncol - length(vec)) : argument 'times' incorrect Is this error normal ? facet_wrap must always give a 2d ribbon of panels ? Thank you very much for your patience. david __ 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] ggplot2 - facet_grid and facet_wrap
Thank you Hadley. I've just discovered an another bug (perhaps ?) : qplot(mpg, wt, data=mtcars)# works qplot(mpg, wt, data=mtcars, geom = line) # works qplot(mpg, wt, data=mtcars) + facet_grid(cyl ~ vs) # works qplot(mpg, wt, data=mtcars, geom = line) + facet_grid(cyl ~ vs) Erreur dans grobs[[i, j]] - layer$make_grob(layerd[[i, j]], details, coord) : types (de NULL a list) incompatibles dans l'affectation [[ david 2008/11/23 hadley wickham [EMAIL PROTECTED] Hi David, That looks like a bug! I'll look into it. Regards, Hadley On Sat, Nov 22, 2008 at 1:07 PM, David Hajage [EMAIL PROTECTED] wrote: Hello R users (and Hadley) I have another question about ggplot2 :-) (version 0.8) `dat` - structure(list(D = c(a, b, c, d), G = c(1.5152071520, 1.88812208268440, -6.60521862, 0.55968739), E = c(1.3592256404, 1.39366168665589, 1.22509259382058, 1.36617701059296), I = c(6.92634958902857, 6.94416045215158, 13.2179488828556, 10.1993799972675), B = c(7.04367258675502, 7.41361056949868, 16.3459547875, 12.968224445), F = c(1.52045742504008, 1.51361354379038, 1.77077549933584, 1.64580736760918), A = c(2.33837047498186, 2.33805720845022, 2.20591935275643, 2.26866576271907), J = c(4.33205802184905, 4.41713317075078, 11.091251405, 7.21690806), H = c(2.35434145263158, 2.35434145263158, 2.00170987368421, 2.26486776842105), C = c(6.9118223461127, 6.92991088926983, 16.1293054123787, 10.2251608535304)), .Names = c(D, G, E, I, B, F, A, J, H, C), row.names = c(NA, 4L), class = data.frame) mdat - melt(dat, id = D) qplot(D, value, data = mdat, fill = D, geom = bar) + facet_grid(~ variable) qplot(D, value, data = mdat, fill = D, geom = bar) + facet_wrap(~ variable) The first plot is good, but I think there is a problem in the second plot : the barplots are not in the correct order (compare G in the first plot and in the second plot for example). I join a pdf file showing the two graphs. Something is wrong in my code ? Thank you very much. david __ 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/ [[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] ggplot2 - Problem with geom_abline()
Hello, Sorry to ask again something with ggplot2... I detect something, perhaps a bug (but more probably a syntax error, I'm learning...) : # This is working : x = wt, y = mpg, abline with intercept = 20 and slope = 1 qplot(wt, mpg, data = mtcars) + geom_abline(intercept = 20, slope = 1) # This is not working : x = mpg, y = wt, abline with intercept = 3 and slope = 1 qplot(mpg, wt, data = mtcars) + geom_abline(intercept = 3, slope = 1) There is only points, no line, on the second graph. (R 2.8.0, ggplot2 0.7, windows 2000) Many thanks. david [[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] Problem with ggplot2
Hello R users, I have an error with package ggplot2 under linux (ubuntu 8.10), R 2.8.0 and ggplot2 0.7, everything up to date : library(ggplot2) Le chargement a nécessité le package : grid Le chargement a nécessité le package : reshape Le chargement a nécessité le package : plyr Le chargement a nécessité le package : proto Le chargement a nécessité le package : RColorBrewer Le chargement a nécessité le package : splines Le chargement a nécessité le package : MASS Attachement du package : 'ggplot2' The following object(s) are masked from package:grid : nullGrob qplot(mpg, wt, data=mtcars) Erreur dans gList(...) : Only 'grobs' allowed in 'gList' I don't understand : this code is working on my work computer (windows 2000). I forgot something ? Thank you very much. david [[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] ggplot2 - two or more axis
Thank you very much for the answer. I have seen very often the number of subject at risk on survival graph (see my pdf file). It is very easy to plot the curve with geom_step(), but is there a better way to show the number of subjects at risk at each time ? Thank you for your advice. 2008/11/14 hadley wickham [EMAIL PROTECTED] Hi David, I'm trying to learn how to make a plot with the amazing package ggplot2. I was wondering if it was possible to draw 2 (or more) x (or y) axis in the same graph. For example : - I want to show two informations at each x coordinate : a survival curve, I want to show the time (0, 12 and 24 months) and the number of subject at risk at each time. - I want to draw two curves that don't have the same unit Unfortunately, the capability is currently unavailable in ggplot2 and is unlikely to ever be available because I believe it is a fundamentally inaccurate means of presenting data. However, in the next version it will be much easier to created faceted displays with varying scales, which should be a better solution for many of these types of problems. Regards, Hadley -- http://had.co.nz/ surv.pdf Description: Adobe PDF document __ 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] ggplot2 - two or more axis
Hello R users, I'm trying to learn how to make a plot with the amazing package ggplot2. I was wondering if it was possible to draw 2 (or more) x (or y) axis in the same graph. For example : - I want to show two informations at each x coordinate : a survival curve, I want to show the time (0, 12 and 24 months) and the number of subject at risk at each time. - I want to draw two curves that don't have the same unit Thank you very much. david [[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] Combining all possible values of variables into a new...
or if x, y and z are factors : dbis - as.data.frame(apply(d, 2, as.factor) dbis$x:dbis$y:dbis$z [1] 1:1:1 0:3:2 0:2:1 1:3:2 0:2:1 0:1:2 1:2:1 0:3:2 0:2:1 1:3:2 12 Levels: 0:1:1 0:1:2 0:2:1 0:2:2 0:3:1 0:3:2 1:1:1 1:1:2 1:2:1 ... 1:3:2 and for your results : as.numeric(dbis$x:dbis$y:dbis$z) [1] 7 6 3 12 3 2 9 6 3 12 2008/10/20 Dimitris Rizopoulos [EMAIL PROTECTED] try this: x - c(1,0,0,1,0,0,1,0,0,1) y - c(1,3,2,3,2,1,2,3,2,3) z - c(1,2,1,2,1,2,1,2,1,2) d - data.frame(x, y, z) ind - do.call(paste, c(expand.grid(1:2, 1:3, 0:1)[3:1], sep = \r)) trg - do.call(paste, c(d, sep = \r)) d$myvar - match(trg, ind) I hope it helps. Best, Dimitris [EMAIL PROTECTED] wrote: I'm trying to create a new column in my data.frame where subjects are categorized depending on values on four other columns. In any other case I would just nest a few ifelse statements, however, in this case i have 4*6*2*3=144 combinations and i get weird 'context overflow' errors. So I wonder if there is a more efficient way of doing this. For illustrational purposes, let's say i have: x-c(1,0,0,1,0,0,1,0,0,1) y-c(1,3,2,3,2,1,2,3,2,3) z-c(1,2,1,2,1,2,1,2,1,2) d-as.data.frame(cbind(x,y,z)) and i do: d$myvar - ifelse(d$x == 0 d$y==1 d$z==1 , d$myvar - 1, ifelse(d$x == 0 d$y==1 d$z==2 , d$myvar - 2, ifelse(d$x == 0 d$y==2 d$z==1 , d$myvar - 3, ifelse(d$x == 0 d$y==2 d$z==2 , d$myvar - 4, ifelse(d$x == 0 d$y==3 d$z==1 , d$myvar - 5, ifelse(d$x == 0 d$y==3 d$z==2 , d$myvar - 6, ifelse(d$x == 1 d$y==1 d$z==1 , d$myvar - 7, ifelse(d$x == 1 d$y==1 d$z==2 , d$myvar - 8, ifelse(d$x == 1 d$y==2 d$z==1 , d$myvar - 9, ifelse(d$x == 1 d$y==2 d$z==2 , d$myvar - 10, ifelse(d$x == 1 d$y==3 d$z==1 , d$myvar - 11, ifelse(d$x == 1 d$y==3 d$z==2 , d$myvar - 12, NA Suggestions? __ 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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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] How to create functions with new defaults?
I can't test it right now, but is this ok ? t.test.new - function(x, y = NULL, alternative = c(two.sided, less, greater), mu = 0, paired = TRUE, var.equal = FALSE, conf.level = 0.95, ...) { t.test(x, y, alternative, mu, paired, var.equal, conf.level, ...) } 2008/9/2 Prabhanjan Tattar [EMAIL PROTECTED] Hi R! I attempt to clear my question through this example. We know that the default functions for t.test is t.test(x, y = NULL, alternative = c(two.sided, less, greater), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, ...) Suppose, I want to create a new function where paired=TRUE. What is the simpler way of creating such functions? I did try, but without much success. Thanks in advance -- Prabhanjan N. Tattar Lead Statistician CustomerXPS Bangalore [[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. [[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] drop unused levels in sqldf
If you want to suppress the unused level of Species, you can use factor() : table(base$Species) table(factor(base$Species)) 2008/8/28 glaporta [EMAIL PROTECTED] Hi, sqldf is a fantastic package, but when the SELECT procedure runs unused levels remain in the output. I tried with the drop function, but without success. Do you have any suggestions? Thanx, Gianandrea data(iris) require(sqldf) base-sqldf(select * from iris where Species 'setosa') str(base) # Species with 3 levels! -- View this message in context: http://www.nabble.com/drop-unused-levels-in-sqldf-tp19196464p19196464.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Using lme, how to specify: (1) repeated measures, and (2) Toeplitz covariance structure?
1) I think that the repeated measure is not years, but, as you said, the count of birds. If you are interested with the effect of the time variable (years), perhaps you need to introduce it as a fixed effect ? 2) See ?corARMA. 2008/8/22 mtb954 [EMAIL PROTECTED] We are attempting to use nlme to fit a linear mixed model to explain bird abundance as a function of habitat: lme(abundance~habitat-1,data=data,method=ML,random=~1|sampleunit) The data consist of repeated counts of birds in sample units across multiple years, and we have two questions: 1) Is it necessary (and, if so, how) to specify the repeated measure (years)? 2) How can we specify a Toeplitz heterogeneous covariance structure for this model? We have searched the help file for lme, and the R-help archives, but cannot find any pertinent information. Any help would be appreciated. Thanks, Mark [[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. [[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] Between the values
But is there a way to construct a S4 method with this syntax : 0 C 1 ? Apparently, it's not possible with S4 group generics Compare(e1, e2). 2008/8/12 Ravi Varadhan [EMAIL PROTECTED] Here is how you check whether a x b without using the `' condition: is.between - function(x, a, b) { (x - a) * (b - x) 0 } Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Tuesday, August 12, 2008 9:46 AM To: Ravi Varadhan; Dan Davison; Ravi Varadhan; Dan Davison; Ravi Varadhan; Dan Davison; Ravi Varadhan; Dan Davison Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [R] Between the values Thanks Ravi... But was just wondering if there existed a simple tricky command for that without using the condition Also was thinking on my second question that how do we define an interval between 0 and 1 which contains all the values between 0 and 1. Thanks, Shubha Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com -Original Message- From: Ravi Varadhan [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2008 7:12 PM To: Shubha Vishwanath Karanth; 'Dan Davison' Cc: [EMAIL PROTECTED] Subject: RE: [R] Between the values Hi Shubaa, Here is one way to do this: is.between - function(x, a, b) { x a x b } set.seed(123) x - rnorm(5) is.between(x, -1, 1) is.between(x, -1, 1) [1] TRUE TRUE FALSE TRUE TRUE Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shubha Vishwanath Karanth Sent: Tuesday, August 12, 2008 9:25 AM To: Dan Davison Cc: [EMAIL PROTECTED] Subject: Re: [R] Between the values Or at least anyways of defining a vector/(or something like that) which has all values between 0 and 1? For example: C(0,1) is incorrect, seq(0,1,0.2) is also incorrect, seq(0,1,0.1) is also incorrect How does one specify this? Thanks, Shubha -Original Message- From: Dan Davison [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2008 5:54 PM To: Shubha Vishwanath Karanth Cc: [EMAIL PROTECTED] Subject: Re: [R] Between the values On Tue, Aug 12, 2008 at 05:16:01PM +0530, Shubha Vishwanath Karanth wrote: Hi R, This is a very trivial one C=0.1 I want to check whether my value of C is between 0 and 1 exclusively I don't want to use (C0 C1). And I can't use a single statement like (0C1). Is there a between function? Or how do we specify from 0 to 1? Does %in% help me? If you don't like (C 0 C 1), then just write your own function is.between(x, low, high) (NB1 you've basically written it already; NB2 single '' for the vectorised version 'are.between'). People's personal tastes about what's desirable will vary, and anyway it's good practice to build up your own personal library of functions. Ultimately if you have a high quality collection of related functions for working on a particular sort of problem, then you should publish them as an R package on CRAN. Dan Many Thanks, Shubha This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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. -- www.stats.ox.ac.uk/~davison http://www.stats.ox.ac.uk/%7Edavison This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ 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. This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ 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. [[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] produce variable on the fly
vect = c(10:20) for (i in 1:10) { + assign(paste(VAR,i,sep=), vect[i]) + } VAR1 [1] 10 VAR2 [1] 11 2008/8/12 jimineep [EMAIL PROTECTED] Hi guys, I want to create variable on the fly: for example for (i in 1:10) { cat(paste(VAR,i,sep=)) } Will print VAR1, VAR2 etc up to VAR10. However I want to make these into variables, and then give them a value, for example: vect = c(10:20) for (i in 1:10) { cat(paste(VAR,i,sep=)) = vect[i] } THis doesnt work but I hope it demonstrates what I'm trying to do: I'm trying to produce 10 variables, from VAR1 to VAR10, which have the numbers 11...20 respectively, so I would end up with VAR1 = 11 VAR2 = 12 ... VAR10 = 20 Hope this makes sense!! Does anyone have any ideas? -- View this message in context: http://www.nabble.com/produce-variable-on-the-fly-tp18943749p18943749.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] sampling
I'm not sure I understand, but is this what you want ? quant - seq(0,1,0.05) perc-c(1:234/234) rows - sapply(quant, function(x){which.min(abs(x - perc))}) perc[rows] 2008/8/11 Duncan Murdoch [EMAIL PROTECTED] Gareth Campbell wrote: Hello, I have a matrix and I want to sample 20 rows that are the the percentiles of 0-100 in 0.05 increments. I have a vector of my sequence (0, 0.05, 0.10, 0.15,1.0) and also That's actually 21 entries, but that probabl doesn't matter... a normalised vector of rownumbers. That is, there are 234 rows (for example) so I do perc-c(1:234/234) which looks like a bunch of numbers from 0 - 1. In Excel (which I try not to use at every possible occaison) you can use a VLOOKUP function to say choose the rows from the perc vector that are the closest match to the sequence vector - i.e. you can specify to choose the closest match, it doesn't have to be an exact match. In R, I'd normally use the grep command when I know it's an exact match. Does anyone know how to achieve this in R? You could do it with approx. That is: rownum - approxfun( (1:234 - 0.5)/234, 1:234, method=constant, rule=2) Then rownum(0.05) will give 12, rownum(0.1) will give 23, etc. Duncan Murdoch Also, I've been getting heaps of help from everyone on this mailing list - if I reply to the respondent and R Help again, will it show up in the correct thread? I haven't been able to say thankyou as I wasn't sure it would show up in the thread. Thanks __ 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] is this a bug (apply and class) ?
Hello R users, I run this code under windows XP and R 2.7.1 : head(esoph) agegp alcgptobgp ncases ncontrols 1 25-34 0-39g/day 0-9g/day 040 2 25-34 0-39g/day10-19 010 3 25-34 0-39g/day20-29 0 6 4 25-34 0-39g/day 30+ 0 5 5 25-34 40-79 0-9g/day 027 6 25-34 40-7910-19 0 7 class(esoph$agegp) [1] ordered factor class(esoph$alcgp) [1] ordered factor class(esoph$tobgp) [1] ordered factor class(esoph$ncases) [1] numeric class(esoph$ncontrols) [1] numeric apply(esoph, 2, class) agegp alcgp tobgp ncases ncontrols character character character character character I don't understand why the result is all character... Thanks a lot. [[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] Newbie question: How to use tapply() on several vectors simultaneously
something like that should work : aggregate(test, list(test[,1]), mean) 2008/8/1 Bertolt Meyer [EMAIL PROTECTED] Dear R users, I have a newbie-question that I couldn't resolve after reading through several pieces of documentation and searching the archive. I have a data.frame containing experimental data from a group experiment in psychology. Each line represents a single participant, but participants were assigned to groups of three or four persons. One variable indicates each participants' group number (groupID). For a large number of variables, I would like to obtain the mean group value. I figured I use tapply() in the fashion of tapply(variable, groupID, mean), but that would be a tiresome task for my 150 variables. I am thus looking for a way to obtain a data.frame that contains one row for each group with the group-mean variables as columns. Example: test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID test groupID V2 V3 11 -0.82990860 -0.61778919 21 -0.01379452 0.64609053 31 -2.64990839 -1.00570627 41 -0.07903878 -0.70864441 51 0.61483071 -1.32039565 62 -0.18913937 1.38490710 72 -0.60017953 0.15893421 82 -0.99901931 0.05963436 92 -1.46759515 0.35040283 10 2 -0.44650422 -0.08713162 tapply(test$V2, test$groupID, mean) 1 2 -0.5915639 -0.7404875 tapply(test$V3, test$groupID, mean) 1 2 -0.6012890 0.3733494 I am now looking for something that gives me groupID V2V3 1 1 -0.5915639-0.6012890 2 2 -0.74048750.3733494 Any ideas? Thank you very much, Bertolt -- Bertolt Meyer Oberassistent Sozialpsychologie, Psychologisches Institut der Universität Zürich Binzmühlestr. 14, Box 15 CH-8050 Zürich [EMAIL PROTECTED] tel: +41446357282 fax: +41446357279 mob: +41788966111 __ 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] speeding up loop and dealing wtih memory problems
Is it what you want ? x - matrix(c(1:3, NA, NA, 4, 1:2, NA), 3, 3) x [,1] [,2] [,3] [1,]1 NA1 [2,]2 NA2 [3,]34 NA x[is.na(x)] - 0 x [,1] [,2] [,3] [1,]101 [2,]202 [3,]340 2008/7/28 Denise Xifara [EMAIL PROTECTED] Dear All and Mark, Given a dataset that I have called dat, I was hoping to speed up the following loop: for(i in 1:835353){ for(j in 1:86){ if (is.na(dat[i,j])==TRUE){dat[i,j]-0 }}} Actually I am also having a memory problem. I get the following: Error: cannot allocate vector of size 3.2 Mb In addition: Warning messages: 1: In dat[i, j] - 0 : Reached total allocation of 1535Mb: see help(memory.size) 2: In dat[i, j] - 0 : Reached total allocation of 1535Mb: see help(memory.size) 3: In dat[i, j] - 0 : Reached total allocation of 1535Mb: see help(memory.size) 4: In dat[i, j] - 0 : Reached total allocation of 1535Mb: see help(memory.size) If I try and apply the loop just to a particular column, rather than the whole dataset, so that I dont have the memory problem, ie for(i in 1:835353){ if (is.na(dat[i,4])==TRUE){dat[i,4]-0 }} it takes ridiculously long to process, so I was hoping that there would be a quicker way to do this. Thank you all very much for the help, Denise [[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. [[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] Package Hmisc, functions summary.formula() and latex(), options pdig, pctdig, eps and prmsd
Oh... No, I don't need to read the documentation again. I just need to wake up... 2008/7/25 Frank E Harrell Jr [EMAIL PROTECTED] David Hajage wrote: 2008/7/25 Frank E Harrell Jr [EMAIL PROTECTED] mailto: [EMAIL PROTECTED] David Hajage wrote: Hello R users, I have several problems with the functions summary.formula and latex in package Hmisc. Here an example : library(Hmisc) sex - factor(sample(c(m,f, ?), 50, rep=TRUE)) age - rnorm(50, 50, 5) treatment - factor(sample(c(Drug,Placebo), 50, rep=TRUE)) symp - c('Headache','Stomach Ache','Hangnail', 'Muscle Ache','Depressed') symptom1 - sample(symp, 50,TRUE) symptom2 - sample(symp, 50,TRUE) symptom3 - sample(symp, 50,TRUE) Symptoms - mChoice(symptom1, symptom2, symptom3, label='Primary Symptoms') f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = T) latex(f, long = T, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F, file = ) ### Here the problems : - The first print(f, ...) doesn't replace all p-value 0.5 by P0.5 : ++-+-+-+ ||Drug |Placebo | Test | ||(N=31) |(N=19) |Statistic| ++-+-+-+ |age | 45.926/48.750/54.019| 47.344/50.728/53.696|F=0.9 d.f.=1,48 P0.5| ++-+-+-+ |sex : ? | 25.806% ( 8)| 26.316% ( 5)| Chi-square=0.3 d.f.=2 P=0.86| ++-+-+-+ |f | 38.710% (12)| 31.579% ( 6)| | ++-+-+-+ |m | 35.484% (11)| 42.105% ( 8)| | ++-+-+-+ |Primary Symptoms : Depressed| 41.935% (13)| 63.158% (12)| Chi-square=2.12 d.f.=1 P0.5| ++-+-+-+ |Hangnail| 48.387% (15)| 42.105% ( 8)|Chi-square=0.19 d.f.=1 P=0.67| ++-+-+-+ |Stomach Ache| 45.161% (14)| 68.421% (13)| Chi-square=2.57 d.f.=1 P0.5| ++-+-+-+ |Muscle Ache | 54.839% (17)| 26.316% ( 5)| Chi-square=3.89 d.f.=1 P0.5| ++-+-+-+ |Headache| 51.613% (16)| 36.842% ( 7)| Chi-square=1.03 d.f.=1 P0.5| ++-+-+-+ I did not see an instance of P 0.5 that was not replaced by P0.5. This is an unusual cutoff, and you are printing many more digits of precision than offered by the data. For example 'Hangnail', p-value is printed as 'P=0.67' instead of 'P0.5'. I know this is an unusual cutoff, I don't remember why I chose that for this example... But 0.67 is not less than 0.5. Please read the documentation again. Frank [[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] Package Hmisc, functions summary.formula() and latex(), options pdig, pctdig, eps and prmsd
Hello R users, I have several problems with the functions summary.formula and latex in package Hmisc. Here an example : library(Hmisc) sex - factor(sample(c(m,f, ?), 50, rep=TRUE)) age - rnorm(50, 50, 5) treatment - factor(sample(c(Drug,Placebo), 50, rep=TRUE)) symp - c('Headache','Stomach Ache','Hangnail', 'Muscle Ache','Depressed') symptom1 - sample(symp, 50,TRUE) symptom2 - sample(symp, 50,TRUE) symptom3 - sample(symp, 50,TRUE) Symptoms - mChoice(symptom1, symptom2, symptom3, label='Primary Symptoms') f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F) print(f, digits = 5, pdig = 2, pctdig = 3, eps = 0.5, prmsd = T) latex(f, long = T, pdig = 2, pctdig = 3, eps = 0.5, prmsd = F, file = ) ### Here the problems : - The first print(f, ...) doesn't replace all p-value 0.5 by P0.5 : ++-+-+-+ ||Drug |Placebo | Test | ||(N=31) |(N=19) |Statistic| ++-+-+-+ |age | 45.926/48.750/54.019| 47.344/50.728/53.696|F=0.9 d.f.=1,48 P0.5| ++-+-+-+ |sex : ? | 25.806% ( 8)| 26.316% ( 5)| Chi-square=0.3 d.f.=2 P=0.86| ++-+-+-+ |f | 38.710% (12)| 31.579% ( 6)| | ++-+-+-+ |m | 35.484% (11)| 42.105% ( 8)| | ++-+-+-+ |Primary Symptoms : Depressed| 41.935% (13)| 63.158% (12)| Chi-square=2.12 d.f.=1 P0.5| ++-+-+-+ |Hangnail| 48.387% (15)| 42.105% ( 8)|Chi-square=0.19 d.f.=1 P=0.67| ++-+-+-+ |Stomach Ache| 45.161% (14)| 68.421% (13)| Chi-square=2.57 d.f.=1 P0.5| ++-+-+-+ |Muscle Ache | 54.839% (17)| 26.316% ( 5)| Chi-square=3.89 d.f.=1 P0.5| ++-+-+-+ |Headache| 51.613% (16)| 36.842% ( 7)| Chi-square=1.03 d.f.=1 P0.5| ++-+-+-+ - The second print(f, ..., prmsd = T) has the same problem for p-value. There is also 4 decimals in the first line instead of 3 : ++--+--++ ||Drug |Placebo | Test | ||(N=31) |(N=19) |Statistic | ++--+--++ |age |45.9263/48.7501/54.0194 49.1817+/- 5.2751|47.3436/50.7276/53.6963 51.1313+/- 5.5868| F=0.9 d.f.=1,48 P0.5| ++--+--++ |sex : ? | 25.806% ( 8) | 26.316% ( 5) | Chi-square=0.3 d.f.=2 P=0.86 | ++--+--++ |f | 38.710% (12) | 31.579% ( 6) || ++--+--++ |m | 35.484% (11) | 42.105% ( 8) ||
Re: [R] unstructured correlation matrix in lme
I answer my own question. I was disturbed by the syntax of the SAS code for proc mixed, which uses the same procedure for mixed or non mixed effect model. Moreover, the type of variance-covariance structure is indicate by one parameter. R is more intuitive and supple : there is two different functions (gls and lme), and two parameters (one for variance structure, one for correlation structure). I needed too much time to understand this. My mistake. david 2008/6/25 David Hajage [EMAIL PROTECTED]: I would like to make clear that the SAS unstructured correlation matrix in the second model was : Estimated R Correlation Matrix for id 1 1 1. 0.8575 0.6984 0.4657 0.3165 2 0.8575 1. 0.8557 0.5670 0.4039 3 0.6984 0.8557 1. 0.8717 0.7551 4 0.4657 0.5670 0.8717 1. 0.9333 5 0.3165 0.4039 0.7551 0.9333 1. which seems to be equal to : cov2cor(cov(datares)) [,1] [,2] [,3] [,4] [,5] [1,] 1.000 0.8574841 0.6984365 0.4657120 0.3165061 [2,] 0.8574841 1.000 0.8557224 0.5670489 0.4038805 [3,] 0.6984365 0.8557224 1.000 0.8716642 0.7550925 [4,] 0.4657120 0.5670489 0.8716642 1.000 0.9333166 [5,] 0.3165061 0.4038805 0.7550925 0.9333166 1.000 but not to : cov2cor(extract.lme.cov(fm2,rats)[1:5, 1:5]) # corClasses in fm2 : corSymm 1 2 3 4 5 1 1.000 0.9153199 0.8424135 0.6222813 0.2125583 2 0.9153199 1.000 0.9344902 0.6960017 0.3115286 3 0.8424135 0.9344902 1.000 0.8709635 0.5573176 4 0.6222813 0.6960017 0.8709635 1.000 0.8218556 5 0.2125583 0.3115286 0.5573176 0.8218556 1.000 2008/6/25 David Hajage [EMAIL PROTECTED]: Hello R users, I'm student and I'm actually having a lecture introducing repeated mesures analysis. Unfortunately, all examples use SAS system... I'm working with lme function (package nlme), and I'm using extract.lme.cov (package mgcv) to extract covariance structure of models. One example is about weight evolution of rats (3 treatment groups) : summary(rats) id trt y s 1 : 5 1:50 Min. : 46.0 0:27 10 : 5 2:50 1st Qu.: 71.0 1:27 11 : 5 3:35 Median :100.0 2:27 12 : 5 Mean :100.8 3:27 13 : 5 3rd Qu.:122.5 4:27 14 : 5 Max. :189.0 (Other):105 id : subjects trt : treatment groups (1, 2 or 3) y : weights s : weeks (Week 0 to Week 4) There are 5 mesearements of weight (on week 0, 1, 2, 3 and 4) for each rat. I first fit a model with a compound symmetry correlation structure : library(nlme) library(mgcv) fm1 - lme(y ~ as.factor(s) * as.factor(trt), data = rats, random = ~ 1|id, correlation = corCompSymm()) summary(fm1) ... Fixed effects: y ~ as.factor(s) * as.factor(trt) Value Std.Error DF t-value p-value (Intercept)54.0 3.469019 96 15.56636 0. as.factor(s)1 24.5 3.125974 96 7.83756 0. as.factor(s)2 52.0 3.125974 96 16.63481 0. as.factor(s)3 76.1 3.125974 96 24.34441 0. as.factor(s)4 106.6 3.125974 96 34.10137 0. as.factor(trt)2 0.7 4.905934 24 0.14268 0.8877 as.factor(trt)3 1.57143 5.406076 24 0.29068 0.7738 as.factor(s)1:as.factor(trt)2 -2.9 4.420795 96 -0.65599 0.5134 as.factor(s)2:as.factor(trt)2 -10.9 4.420795 96 -2.46562 0.0155 as.factor(s)3:as.factor(trt)2 -22.6 4.420795 96 -5.11220 0. as.factor(s)4:as.factor(trt)2 -37.3 4.420795 96 -8.43740 0. as.factor(s)1:as.factor(trt)3 -4.21429 4.871479 96 -0.86509 0.3891 as.factor(s)2:as.factor(trt)3 -2.71429 4.871479 96 -0.55718 0.5787 as.factor(s)3:as.factor(trt)3 1.04286 4.871479 96 0.21407 0.8309 as.factor(s)4:as.factor(trt)3 0.68571 4.871479 96 0.14076 0.8884 ... extract.lme.cov(fm1,rats)[1:5, 1:5] 1 2 3 4 5 1 120.34095 71.48238 71.48238 71.48238 71.48238 2 71.48238 120.34095 71.48238 71.48238 71.48238 3 71.48238 71.48238 120.34095 71.48238 71.48238 4 71.48238 71.48238 71.48238 120.34095 71.48238 5 71.48238 71.48238 71.48238 71.48238 120.34095 As you can see, I obtain exactly the same solutions for fixed parameters and estimated covariance matrix in SAS : proc mixed data = rat ; class id trt s ; format trt ftrt. s fs. ; model y = trt s trt * s / solution ddfm = satterth ; repeated s / type = cs subject = id r rcorr; run ; Erreur Effettrt s Estimationstandard DF Valeur du test tPr |t| Intercept 54. 3.4690 49.8 15.57
[R] unstructured correlation matrix in lme
Hello R users, I'm student and I'm actually having a lecture introducing repeated mesures analysis. Unfortunately, all examples use SAS system... I'm working with lme function (package nlme), and I'm using extract.lme.cov (package mgcv) to extract covariance structure of models. One example is about weight evolution of rats (3 treatment groups) : summary(rats) id trt y s 1 : 5 1:50 Min. : 46.0 0:27 10 : 5 2:50 1st Qu.: 71.0 1:27 11 : 5 3:35 Median :100.0 2:27 12 : 5 Mean :100.8 3:27 13 : 5 3rd Qu.:122.5 4:27 14 : 5 Max. :189.0 (Other):105 id : subjects trt : treatment groups (1, 2 or 3) y : weights s : weeks (Week 0 to Week 4) There are 5 mesearements of weight (on week 0, 1, 2, 3 and 4) for each rat. I first fit a model with a compound symmetry correlation structure : library(nlme) library(mgcv) fm1 - lme(y ~ as.factor(s) * as.factor(trt), data = rats, random = ~ 1|id, correlation = corCompSymm()) summary(fm1) ... Fixed effects: y ~ as.factor(s) * as.factor(trt) Value Std.Error DF t-value p-value (Intercept)54.0 3.469019 96 15.56636 0. as.factor(s)1 24.5 3.125974 96 7.83756 0. as.factor(s)2 52.0 3.125974 96 16.63481 0. as.factor(s)3 76.1 3.125974 96 24.34441 0. as.factor(s)4 106.6 3.125974 96 34.10137 0. as.factor(trt)2 0.7 4.905934 24 0.14268 0.8877 as.factor(trt)3 1.57143 5.406076 24 0.29068 0.7738 as.factor(s)1:as.factor(trt)2 -2.9 4.420795 96 -0.65599 0.5134 as.factor(s)2:as.factor(trt)2 -10.9 4.420795 96 -2.46562 0.0155 as.factor(s)3:as.factor(trt)2 -22.6 4.420795 96 -5.11220 0. as.factor(s)4:as.factor(trt)2 -37.3 4.420795 96 -8.43740 0. as.factor(s)1:as.factor(trt)3 -4.21429 4.871479 96 -0.86509 0.3891 as.factor(s)2:as.factor(trt)3 -2.71429 4.871479 96 -0.55718 0.5787 as.factor(s)3:as.factor(trt)3 1.04286 4.871479 96 0.21407 0.8309 as.factor(s)4:as.factor(trt)3 0.68571 4.871479 96 0.14076 0.8884 ... extract.lme.cov(fm1,rats)[1:5, 1:5] 1 2 3 4 5 1 120.34095 71.48238 71.48238 71.48238 71.48238 2 71.48238 120.34095 71.48238 71.48238 71.48238 3 71.48238 71.48238 120.34095 71.48238 71.48238 4 71.48238 71.48238 71.48238 120.34095 71.48238 5 71.48238 71.48238 71.48238 71.48238 120.34095 As you can see, I obtain exactly the same solutions for fixed parameters and estimated covariance matrix in SAS : proc mixed data = rat ; class id trt s ; format trt ftrt. s fs. ; model y = trt s trt * s / solution ddfm = satterth ; repeated s / type = cs subject = id r rcorr; run ; Erreur Effettrt s Estimationstandard DFValeur du test tPr |t| Intercept 54. 3.4690 49.8 15.57 .0001 trt A.trt31.5714 5.4061 49.80.29 0.7725 trt B.trt20.7000 4.9059 49.80.14 0.8871 trt C.trt1 0 . . . . s A.S4106.60 3.1260 96 34.10 .0001 s B.S3 76.1000 3.1260 96 24.34 .0001 s C.S2 52. 3.1260 96 16.63 .0001 s D.S1 24.5000 3.1260 967.84 .0001 s E.S0 0 . . . . trt*sA.trt3A.S40.6857 4.8715 960.14 0.8884 trt*sA.trt3B.S31.0429 4.8715 960.21 0.8309 trt*sA.trt3C.S2 -2.7143 4.8715 96 -0.56 0.5787 trt*sA.trt3D.S1 -4.2143 4.8715 96 -0.87 0.3891 trt*sA.trt3E.S0 0 . . . . trt*sB.trt2A.S4 -37.3000 4.4208 96 -8.44 .0001 trt*sB.trt2B.S3 -22.6000 4.4208 96 -5.11 .0001 trt*sB.trt2C.S2 -10.9000 4.4208 96 -2.47 0.0155 trt*sB.trt2D.S1 -2.9000 4.4208 96 -0.66 0.5134 trt*sB.trt2E.S0 0 . . . . trt*sC.trt1A.S4 0 . . . . trt*sC.trt1B.S3 0 . . . . trt*sC.trt1C.S2 0
Re: [R] unstructured correlation matrix in lme
I would like to make clear that the SAS unstructured correlation matrix in the second model was : Estimated R Correlation Matrix for id 1 1 1. 0.8575 0.6984 0.4657 0.3165 2 0.8575 1. 0.8557 0.5670 0.4039 3 0.6984 0.8557 1. 0.8717 0.7551 4 0.4657 0.5670 0.8717 1. 0.9333 5 0.3165 0.4039 0.7551 0.9333 1. which seems to be equal to : cov2cor(cov(datares)) [,1] [,2] [,3] [,4] [,5] [1,] 1.000 0.8574841 0.6984365 0.4657120 0.3165061 [2,] 0.8574841 1.000 0.8557224 0.5670489 0.4038805 [3,] 0.6984365 0.8557224 1.000 0.8716642 0.7550925 [4,] 0.4657120 0.5670489 0.8716642 1.000 0.9333166 [5,] 0.3165061 0.4038805 0.7550925 0.9333166 1.000 but not to : cov2cor(extract.lme.cov(fm2,rats)[1:5, 1:5]) # corClasses in fm2 : corSymm 1 2 3 4 5 1 1.000 0.9153199 0.8424135 0.6222813 0.2125583 2 0.9153199 1.000 0.9344902 0.6960017 0.3115286 3 0.8424135 0.9344902 1.000 0.8709635 0.5573176 4 0.6222813 0.6960017 0.8709635 1.000 0.8218556 5 0.2125583 0.3115286 0.5573176 0.8218556 1.000 2008/6/25 David Hajage [EMAIL PROTECTED]: Hello R users, I'm student and I'm actually having a lecture introducing repeated mesures analysis. Unfortunately, all examples use SAS system... I'm working with lme function (package nlme), and I'm using extract.lme.cov (package mgcv) to extract covariance structure of models. One example is about weight evolution of rats (3 treatment groups) : summary(rats) id trt y s 1 : 5 1:50 Min. : 46.0 0:27 10 : 5 2:50 1st Qu.: 71.0 1:27 11 : 5 3:35 Median :100.0 2:27 12 : 5 Mean :100.8 3:27 13 : 5 3rd Qu.:122.5 4:27 14 : 5 Max. :189.0 (Other):105 id : subjects trt : treatment groups (1, 2 or 3) y : weights s : weeks (Week 0 to Week 4) There are 5 mesearements of weight (on week 0, 1, 2, 3 and 4) for each rat. I first fit a model with a compound symmetry correlation structure : library(nlme) library(mgcv) fm1 - lme(y ~ as.factor(s) * as.factor(trt), data = rats, random = ~ 1|id, correlation = corCompSymm()) summary(fm1) ... Fixed effects: y ~ as.factor(s) * as.factor(trt) Value Std.Error DF t-value p-value (Intercept)54.0 3.469019 96 15.56636 0. as.factor(s)1 24.5 3.125974 96 7.83756 0. as.factor(s)2 52.0 3.125974 96 16.63481 0. as.factor(s)3 76.1 3.125974 96 24.34441 0. as.factor(s)4 106.6 3.125974 96 34.10137 0. as.factor(trt)2 0.7 4.905934 24 0.14268 0.8877 as.factor(trt)3 1.57143 5.406076 24 0.29068 0.7738 as.factor(s)1:as.factor(trt)2 -2.9 4.420795 96 -0.65599 0.5134 as.factor(s)2:as.factor(trt)2 -10.9 4.420795 96 -2.46562 0.0155 as.factor(s)3:as.factor(trt)2 -22.6 4.420795 96 -5.11220 0. as.factor(s)4:as.factor(trt)2 -37.3 4.420795 96 -8.43740 0. as.factor(s)1:as.factor(trt)3 -4.21429 4.871479 96 -0.86509 0.3891 as.factor(s)2:as.factor(trt)3 -2.71429 4.871479 96 -0.55718 0.5787 as.factor(s)3:as.factor(trt)3 1.04286 4.871479 96 0.21407 0.8309 as.factor(s)4:as.factor(trt)3 0.68571 4.871479 96 0.14076 0.8884 ... extract.lme.cov(fm1,rats)[1:5, 1:5] 1 2 3 4 5 1 120.34095 71.48238 71.48238 71.48238 71.48238 2 71.48238 120.34095 71.48238 71.48238 71.48238 3 71.48238 71.48238 120.34095 71.48238 71.48238 4 71.48238 71.48238 71.48238 120.34095 71.48238 5 71.48238 71.48238 71.48238 71.48238 120.34095 As you can see, I obtain exactly the same solutions for fixed parameters and estimated covariance matrix in SAS : proc mixed data = rat ; class id trt s ; format trt ftrt. s fs. ; model y = trt s trt * s / solution ddfm = satterth ; repeated s / type = cs subject = id r rcorr; run ; Erreur Effettrt s Estimationstandard DFValeur du test tPr |t| Intercept 54. 3.4690 49.8 15.57 .0001 trt A.trt31.5714 5.4061 49.80.29 0.7725 trt B.trt20.7000 4.9059 49.80.14 0.8871 trt C.trt1 0 . . . . s A.S4106.60 3.1260 96 34.10 .0001 s B.S3 76.1000 3.1260 96 24.34 .0001 s C.S2 52.
Re: [R] Help with coxph object
hello, it is in the summary.coxph object : names(summary(yourcoxobject)) You can see '$coef' summary(yourcoxobject)$coef[,5] 2008/1/21, Eleni Christodoulou [EMAIL PROTECTED]: Hello R community! I am trying to apply the cox model and thus I am creating a coxph object. I would like to retrieve the p-values from this and keep them separately in another vector. I can see them when I give a command for the result to appear. However, the p values are not in the list of values of a coxph object and I don't know how to keep them for future reference. Could anybody help me with this? Thank you very much in advance, Eleni [[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. [[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] odfWeave and xtable
yes, but we loose the possibility to use a 'simple' text editor. For example, I like to use emacs+ess to edit and evaluate R code, and to write my report in the same editor. I like the idea that the input format could be writen with a simple text editor, and the output format be chosen after. I know that the syntax of the input file could be too difficult for newbie users (that's why odfWeave is very usefull), but this can be bypass a specific editor like kile for latex... 2008/1/16, Max Kuhn [EMAIL PROTECTED]: 2008/1/16 David Hajage [EMAIL PROTECTED]: Ps : I would like to know if there is an R project to include all existing format outputs (latex with Sweave, odf with odfWeave, html with rWeaveHTML) and all the wonderful work of their author in a same package or in a same project. All of these use a very similar syntax (foo= R code @), but there is anyway a lot of work to rewrite the R code to make a file writes for Sweave working with odfWeave. A latex file can be convert to latex or rtf, but it depends on external programs not very easy to use. For example, I would imagine an input similar to the syntax of help files (.Rd), but the R code could be include ( foo = R code @), and a When developing odfWeave, I did run into issues that could not be taken into account with Sweave. That is why odfWeave calls Sweave instead of using Sweave directly (as you would with the R2HTML package). It would be nice to have a more uniform/expanded interface in Sweave that can more naturally accommodate other types of markup (beyond writing drivers). Sweave-like function could replace R code with results and convert the file into latex, html or odf. I *think* that odfWeave with OpenOffice/NeoOffice can do that. I think I saw somewhere that newer versions of OO support LaTex, but clearly I haven't looked into it. I do know that using OO as a conversion tool to rtf, doc, pdf and html works very well. -- Max [[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] odfWeave and xtable
It is verry easy with xtable package to make your own xtable.class function, if the class was not implemented in xtable package yet. It would be wonderfull if odfWeave include a framework to make such things. Ps : I would like to know if there is an R project to include all existing format outputs (latex with Sweave, odf with odfWeave, html with rWeaveHTML) and all the wonderful work of their author in a same package or in a same project. All of these use a very similar syntax (foo= R code @), but there is anyway a lot of work to rewrite the R code to make a file writes for Sweave working with odfWeave. A latex file can be convert to latex or rtf, but it depends on external programs not very easy to use. For example, I would imagine an input similar to the syntax of help files (.Rd), but the R code could be include ( foo = R code @), and a Sweave-like function could replace R code with results and convert the file into latex, html or odf. 2008/1/16, ËÎʱ¸è [EMAIL PROTECTED]: Dear Max, If you have plan to add more table making facilities into odfWeave package, I suggest you base your work on Zelig, a R package that tries to provide a unified interface to many existing R statistical libraries, created by Gary King's team at Harvard. I see great potential in this marriage. Best, Shige On Jan 13, 2008 4:09 AM, Max Kuhn [EMAIL PROTECTED] wrote: One thing on my (neglected) to-do list for odfWeave is to create a general class called odf that can be used to create output for common models (lm, glm etc). The nice thing here is that the output from this function could write mixed output. For example, a short paragraph about the specified model, the table for coefficients produced by summary.lm, diagnostic plots etc. Right now, to get the coeffcient table use: #from ?lm ## Annette Dobson (1990) An Introduction to Generalized Linear Models. ## Page 9: Plant Weight Data. ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2,10,20, labels=c(Ctl,Trt)) weight - c(ctl, trt) lm.D9 - lm(weight ~ group) library(odfWeave) coefTable - summary(lm.D9)$coef colnames(coefTable) - odfTranslate(colnames(coefTable), toR = FALSE) odfTable(coefTable) Max On Jan 12, 2008 1:03 PM, Frank E Harrell Jr [EMAIL PROTECTED] wrote: ??? wrote: Dear All, I am new to odfWeave and was wondering if there are something similar to the xtable package that can automatically convert model coefficients into LaTeX/ODT tables? More generally, how do people who use odfWeave transform model results into tables? The odfTable does not seem to be able to do this (maybe I am wrong, and would appreciate some demos). Thanks. Best, Shige This is not related to tables, but see the latex methods in the Design package. There are methods for using LaTeX to typeset various kinds of regression model fits. -- Max __ 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.