楼主: oliyiyi
933 3

Getting tables from R output [推广有奖]

版主

泰斗

0%

还不是VIP/贵宾

-

TA的文库  其他...

计量文库

威望
7
论坛币
271951 个
通用积分
31269.3519
学术水平
1435 点
热心指数
1554 点
信用等级
1345 点
经验
383775 点
帖子
9598
精华
66
在线时间
5468 小时
注册时间
2007-5-21
最后登录
2024-4-18

初级学术勋章 初级热心勋章 初级信用勋章 中级信用勋章 中级学术勋章 中级热心勋章 高级热心勋章 高级学术勋章 高级信用勋章 特级热心勋章 特级学术勋章 特级信用勋章

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

Turning plain-text output into well-formatted tables can be a repetitive task, especially when many tests or models are being incorporated into a paper.

For R users, there are several methods that can make this task easier (though not much less repetitive), regardless of what typesetting system you use.

LaTeX tables
The xtable package produces LaTeX-formatted tables. Using xtable, specific kinds of R objects, such as linear model summaries, can be turned into "xtables", which can in turn be output to either LaTeX or HTML.

To use:

  • Install the xtable package: install.packages("xtable")
  • Load the xtable package: library(xtable)
  • Create an xtable for the object that you want to export: newobject<-xtable(object)
  • Export your xtabled object to LaTeX: print.xtable(newobject, type="latex", file="filename.tex")

Options

  • To export to HTML instead of LaTeX, use type="html" and use the .html extension in the filename
  • To have R produce the proper markup in the console (instead of writing in to a file) omit the file=filename option

Other word processors
If, instead of LaTeX, you are using Word, OpenOffice, NeoOffice, etc., there is a way to produce more easily formatted tables. Just follow these steps:

  • Create an xtable, as above, and print the output to an HTML file: print.xtable(newobject, type="html", file="filename.html")
  • Open the generated HTML file in your browser (may I recommend Firefox)
  • Copy the table contents and paste them into your word processor
  • Convert the text to a table: In OpenOffice or NeoOffice: Select the text and go to Tools: Text <-> Table and select "Tabs" as the delimiter. In Word: Select the text and go to Table: Convert: Convert Text to Table, and use separate text at tabs

This technique is somewhat more convoluted than creating pure LaTeX output, but it is probably quicker than entering the output by hand.

Note: An alternative to xtable is the R2HTML package, which works similarly, but does not require xtable objects to be created in order to generate HTML output.


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:getting output tables outpu Table tables

已有 1 人评分学术水平 信用等级 收起 理由
janyiyi + 3 + 3 精彩帖子

总评分: 学术水平 + 3  信用等级 + 3   查看全部评分

缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html
沙发
Kamize 学生认证  发表于 2016-10-19 14:16:29 来自手机 |只看作者 |坛友微信交流群
oliyiyi 发表于 2016-10-19 09:35
Turning plain-text output into well-formatted tables can be a repetitive task, especially when many  ...
谢谢楼主分享的资料

使用道具

藤椅
ddf2002 发表于 2016-11-16 10:40:56 |只看作者 |坛友微信交流群
谢谢了,非常有用。

使用道具

板凳
yuxiangting02 发表于 2016-11-16 11:28:41 |只看作者 |坛友微信交流群

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-26 09:32