Hello everyone. I am new to R, so please bear with me. I am trying to find an easy way to export descriptive statistics and other information about my data frame to a LaTeX format. I have found the describe function in PrettyR to be very helpful in producing results in the exact format I'm looking for. However, the value of the describe function is a LIST (rather than a data frame) which I am then unable to convert to LaTeX using the xtable package or the latex function of Hmisc. When I try to convert the list to a data frame, I get an error that says "arguments imply differing number of rows." If that didn't make any sense...ultimately, here is what I'm trying (and failing) to produce as a LaTeX document... MALES FEMALES Q10 Med Q90 Q10 Med Q90 AGE xx xx xx xx xx xx BMI xx xx xx xx xx xx etc. xx xx xx xx xx xx Any help or guidance would be appreciated! Thank you in advanced! J. -- View this message in context: http://www.nabble.com/Using-PrettyR-to-produce-LaTeX-output-tp18618195p18618195.html Sent from the R help mailing list archive at Nabble.com.
You might look at the summary method in Dr. Harrell's Hmisc package, I believe this would give you almost exactly what you want. latex(summary(gender ~ age + bmi, data=yourdata, method='reverse')) This will get you quartiles, but if you read the documentation (?summary.formula) you can see how to create custom summaries. --Matt Matt Austin Global Statistical Leader, denosumab PMO Director, Biostatistics Amgen, Inc -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of jcarmichael Sent: Wednesday, July 23, 2008 12:46 PM To: r-help at r-project.org Subject: [R] Using PrettyR to produce LaTeX output Hello everyone. I am new to R, so please bear with me. I am trying to find an easy way to export descriptive statistics and other information about my data frame to a LaTeX format. I have found the describe function in PrettyR to be very helpful in producing results in the exact format I'm looking for. However, the value of the describe function is a LIST (rather than a data frame) which I am then unable to convert to LaTeX using the xtable package or the latex function of Hmisc. When I try to convert the list to a data frame, I get an error that says "arguments imply differing number of rows." If that didn't make any sense...ultimately, here is what I'm trying (and failing) to produce as a LaTeX document... MALES FEMALES Q10 Med Q90 Q10 Med Q90 AGE xx xx xx xx xx xx BMI xx xx xx xx xx xx etc. xx xx xx xx xx xx Any help or guidance would be appreciated! Thank you in advanced! J. -- View this message in context: http://www.nabble.com/Using-PrettyR-to-produce-LaTeX-output-tp18618195p18618195.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Using the built in BOD data frame: library(prettyR) str(describe(BOD)) # note Numeric component BOD.describe.df <- as.data.frame(describe(BOD)$Numeric) library(xtable) xtable(BOD.describe.df) On Wed, Jul 23, 2008 at 3:46 PM, jcarmichael <whattheheli at yahoo.com> wrote:> > Hello everyone. I am new to R, so please bear with me. I am trying to find > an easy way to export descriptive statistics and other information about my > data frame to a LaTeX format. > > I have found the describe function in PrettyR to be very helpful in > producing results in the exact format I'm looking for. However, the value > of the describe function is a LIST (rather than a data frame) which I am > then unable to convert to LaTeX using the xtable package or the latex > function of Hmisc. When I try to convert the list to a data frame, I get an > error that says "arguments imply differing number of rows." > > If that didn't make any sense...ultimately, here is what I'm trying (and > failing) to produce as a LaTeX document... > > MALES FEMALES > Q10 Med Q90 Q10 Med Q90 > AGE xx xx xx xx xx xx > BMI xx xx xx xx xx > xx > etc. xx xx xx xx xx > xx > > Any help or guidance would be appreciated! Thank you in advanced! > > J. > -- > View this message in context: http://www.nabble.com/Using-PrettyR-to-produce-LaTeX-output-tp18618195p18618195.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
On Wed, 2008-07-23 at 12:46 -0700, jcarmichael wrote:> Hello everyone. I am new to R, so please bear with me. I am trying to find > an easy way to export descriptive statistics and other information about my > data frame to a LaTeX format. > > I have found the describe function in PrettyR to be very helpful in > producing results in the exact format I'm looking for. However, the value > of the describe function is a LIST (rather than a data frame) which I am > then unable to convert to LaTeX using the xtable package or the latex > function of Hmisc. When I try to convert the list to a data frame, I get an > error that says "arguments imply differing number of rows." > > If that didn't make any sense...ultimately, here is what I'm trying (and > failing) to produce as a LaTeX document... > > MALES FEMALES > Q10 Med Q90 Q10 Med Q90 > AGE xx xx xx xx xx xx > BMI xx xx xx xx xx > xx > etc. xx xx xx xx xx > xx >Hi J, You can reduce the list produced by "describe" to a variety of text formats using the "delim.table" function. However, you seem to want something like a hierarchical table format. If I had to do this, I would probably write a function something like "delim.table" to massage the data into a format that can be read by the "latex" function. Jim
Thank you all for your input! I was able to create my descriptive table as well as a few other things I was having trouble with. Thanks again! J. jcarmichael wrote:> > Hello everyone. I am new to R, so please bear with me. I am trying to > find an easy way to export descriptive statistics and other information > about my data frame to a LaTeX format. > > I have found the describe function in PrettyR to be very helpful in > producing results in the exact format I'm looking for. However, the value > of the describe function is a LIST (rather than a data frame) which I am > then unable to convert to LaTeX using the xtable package or the latex > function of Hmisc. When I try to convert the list to a data frame, I get > an error that says "arguments imply differing number of rows." > > If that didn't make any sense...ultimately, here is what I'm trying (and > failing) to produce as a LaTeX document... > > MALES FEMALES > Q10 Med Q90 Q10 Med Q90 > AGE xx xx xx xx xx > xx > BMI xx xx xx xx xx > xx > etc. xx xx xx xx xx > xx > > Any help or guidance would be appreciated! Thank you in advanced! > > J. >-- View this message in context: http://www.nabble.com/Using-PrettyR-to-produce-LaTeX-output-tp18618195p18695124.html Sent from the R help mailing list archive at Nabble.com.