Hi...... I tried to create a table with borders. But I am not able to create. I tried to use *latex()* function but it showing in a different please help me to create tables? the output comes as follows....> rdatasubject sex condition before after change 1 1 F placebo 10.1 6.9 31.683168 2 2 F placebo 6.3 4.2 33.333333 3 3 M aspirin 12.4 6.3 49.193548 4 4 F placebo 8.1 6.1 24.691358 5 5 M aspirin 15.2 9.9 34.868421 6 6 F aspirin 10.9 7.0 35.779817 7 7 F aspirin 11.6 8.5 26.724138 8 8 M aspirin 9.5 3.0 68.421053 9 9 F placebo 11.5 9.0 21.739130 10 10 M placebo 11.9 11.0 7.563025> tab<-tabular( (condition + 1) ~ (n=1) + Format(digits=2)*+ (before + after)*(mean + sd), data=rdata )> tabbefore after condition n mean sd mean sd aspirin 5 11.9 2.1 6.9 2.6 placebo 5 9.6 2.4 7.4 2.6 All 10 10.8 2.4 7.2 2.5> latex(tab)\begin{tabular}{lccccc} \toprule & & \multicolumn{2}{c}{before} & \multicolumn{2}{c}{after} \\ \cmidrule(lr){3-4}\cmidrule(lr){5-6} condition & n & mean & sd & mean & sd \\ \midrule aspirin & $\phantom{0}5$ & $11.9$ & $\phantom{0}2.1$ & $\phantom{0}6.9$ & $\phantom{0}2.6$ \\ placebo & $\phantom{0}5$ & $\phantom{0}9.6$ & $\phantom{0}2.4$ & $\phantom{0}7.4$ & $\phantom{0}2.6$ \\ All & $10$ & $10.8$ & $\phantom{0}2.4$ & $\phantom{0}7.2$ & $\phantom{0}2.5$ \\ \bottomrule \end{tabular}>-- View this message in context: http://r.789695.n4.nabble.com/How-to-create-a-table-with-borders-tp4645470.html Sent from the R help mailing list archive at Nabble.com.
Thanks arun, But what is the alternative solution in windows. Please reply me................................. -- View this message in context: http://r.789695.n4.nabble.com/How-to-create-a-table-with-borders-tp4645470p4645527.html Sent from the R help mailing list archive at Nabble.com.
HI, Saw your reply in Nabble. For Windows, you can install "MiKTeX" (http://miktex.org/).? Please go through this link (http://educ.jmu.edu/~taalmala/245_2005post/miktex/miktex_setup.html) for setting up MiKTeX .? You can compile the code either from command line or directly from TeXworks? (editor that gets installed along with MiKTeX). Hope this helps. A.K. ----- Original Message ----- From: killerkarthick <karthick.gdi at gmail.com> To: r-help at r-project.org Cc: Sent: Monday, October 8, 2012 1:53 PM Subject: [R] How to create a table with borders? Hi...... ? ? ? ? ? ? I tried to create a table with borders. But I am not able to create. I tried to use *latex()* function but it showing in a different please help me to create tables? the output comes? as follows....> rdata? subject sex condition before after? ? change 1? ? ? ? 1? F? placebo? 10.1? 6.9 31.683168 2? ? ? ? 2? F? placebo? ? 6.3? 4.2 33.333333 3? ? ? ? 3? M? aspirin? 12.4? 6.3 49.193548 4? ? ? ? 4? F? placebo? ? 8.1? 6.1 24.691358 5? ? ? ? 5? M? aspirin? 15.2? 9.9 34.868421 6? ? ? ? 6? F? aspirin? 10.9? 7.0 35.779817 7? ? ? ? 7? F? aspirin? 11.6? 8.5 26.724138 8? ? ? ? 8? M? aspirin? ? 9.5? 3.0 68.421053 9? ? ? ? 9? F? placebo? 11.5? 9.0 21.739130 10? ? ? 10? M? placebo? 11.9? 11.0? 7.563025> tab<-tabular( (condition + 1) ~ (n=1) + Format(digits=2)*+? (before + after)*(mean + sd), data=rdata )> tab? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? before? ? ? after? ? condition n? mean? sd? mean? sd? aspirin? ? 5 11.9? ? 2.1? 6.9? 2.6 placebo? ? 5? 9.6? ? 2.4? 7.4? 2.6 All? ? ? 10 10.8? ? 2.4? 7.2? 2.5> latex(tab)\begin{tabular}{lccccc} \toprule &? & \multicolumn{2}{c}{before} & \multicolumn{2}{c}{after} \\ \cmidrule(lr){3-4}\cmidrule(lr){5-6} condition? & n & mean & sd & mean & sd \\ \midrule aspirin? & $\phantom{0}5$ & $11.9$ & $\phantom{0}2.1$ & $\phantom{0}6.9$ & $\phantom{0}2.6$ \\ placebo? & $\phantom{0}5$ & $\phantom{0}9.6$ & $\phantom{0}2.4$ & $\phantom{0}7.4$ & $\phantom{0}2.6$ \\ All? & $10$ & $10.8$ & $\phantom{0}2.4$ & $\phantom{0}7.2$ & $\phantom{0}2.5$ \\ \bottomrule \end{tabular}>-- View this message in context: http://r.789695.n4.nabble.com/How-to-create-a-table-with-borders-tp4645470.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.
Hi I just had a look at the latex component - \toprule I think is from the booktabs package so you may need \usepackage{booktabs} in the latex preamble to use \toprule and \bottomrule Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mackay at northnet.com.au At 15:04 9/10/2012, you wrote:>HI, > >Saw your reply in Nabble. > > >For Windows, you can install "MiKTeX" (http://miktex.org/). > > >Please go through this link >(http://educ.jmu.edu/~taalmala/245_2005post/miktex/miktex_setup.html) > for setting up MiKTeX . You can compile the code either from >command line or directly from TeXworks? (editor that gets installed >along with MiKTeX). > > >Hope this helps. > >A.K. > > > >----- Original Message ----- >From: killerkarthick <karthick.gdi at gmail.com> >To: r-help at r-project.org >Cc: >Sent: Monday, October 8, 2012 1:53 PM >Subject: [R] How to create a table with borders? > >Hi...... > I tried to create a table with borders. But I am not able to >create. I tried to use *latex()* function but it showing in a different >please help me to create tables? > >the output comes as follows.... > > rdata > subject sex condition before after change >1 1 F placebo 10.1 6.9 31.683168 >2 2 F placebo 6.3 4.2 33.333333 >3 3 M aspirin 12.4 6.3 49.193548 >4 4 F placebo 8.1 6.1 24.691358 >5 5 M aspirin 15.2 9.9 34.868421 >6 6 F aspirin 10.9 7.0 35.779817 >7 7 F aspirin 11.6 8.5 26.724138 >8 8 M aspirin 9.5 3.0 68.421053 >9 9 F placebo 11.5 9.0 21.739130 >10 10 M placebo 11.9 11.0 7.563025 > > tab<-tabular( (condition + 1) ~ (n=1) + Format(digits=2)* >+ (before + after)*(mean + sd), data=rdata ) > > tab > > before after >condition n mean sd mean sd >aspirin 5 11.9 2.1 6.9 2.6 >placebo 5 9.6 2.4 7.4 2.6 >All 10 10.8 2.4 7.2 2.5 > > latex(tab) >\begin{tabular}{lccccc} >\toprule >& & \multicolumn{2}{c}{before} & \multicolumn{2}{c}{after} \\ >\cmidrule(lr){3-4}\cmidrule(lr){5-6} >condition & n & mean & sd & mean & sd \\ >\midrule >aspirin & $\phantom{0}5$ & $11.9$ & $\phantom{0}2.1$ & $\phantom{0}6.9$ & >$\phantom{0}2.6$ \\ >placebo & $\phantom{0}5$ & $\phantom{0}9.6$ & $\phantom{0}2.4$ & >$\phantom{0}7.4$ & $\phantom{0}2.6$ \\ >All & $10$ & $10.8$ & $\phantom{0}2.4$ & $\phantom{0}7.2$ & >$\phantom{0}2.5$ \\ >\bottomrule >\end{tabular} > > > > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/How-to-create-a-table-with-borders-tp4645470.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. > > >______________________________________________ >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.