如何将不同的表在彼此上方的同一选项卡上保存到一个CSV中?
Let's say I have 4 tables, and I want to put them in a csv file like this:
How would I do that? I want two columns of tables and any number of rows, and I want to be able to define where which table is and keep 1 column between the two columns and two rows between each row of tables as depicted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将您的4个数据帧放入命名列表
L
,例如基于内置BOD
数据框架所示的测试数据。与问题一样,我们假设前两个数据帧中列数的总和等于最后两个数据帧中列数的总和。
定义
fmt
函数,该功能输入列表l
的名称,并输出一个字符TS系列,上面名称为顶部。我们使用TS系列,因为这些系列允许cbind
与具有不同数量的行的参数一起使用。最后,使用write.table
输出结果。我们只是将其输出到控制台,但您可以将write.table.table
语句适当地转换为文件。没有包装。
给予:
Put your 4 data frames into a named list
L
such as the test data shown below based on the built-inBOD
data frame.As in the question, we assume that the sum of the number of columns in the first two data frames equals the sum of the number of columns in the last two data frames.
Define a
fmt
function which inputs a name from the listL
and outputs a character ts series with the name at top. We use ts series because those allowcbind
to be used with arguments having different numbers of rows. Finally usewrite.table
to output the result. We just output it to the console but you can modify thewrite.table
statement appropriately to output to a file.No packages are used.
giving: