简体   繁体   English

在r中的数据框上方或下方附加文本行

[英]Append lines of text above or below the dataframe in r

I have a huge data frame (dimension:600000 X 6). 我有一个巨大的数据框(尺寸:600000 X 6)。 All 6 columns are integer values representing different features for each row. 所有6列都是整数值,代表每一行的不同功能。 I would like to add three lines of text either above or below the data frame which are common to all the rows. 我想在所有行共有的数据框的上方或下方添加三行文本。 Is it possible to insert some lines of text below or above the data frame? 是否可以在数据框的上方或下方插入一些文本行?

For example: Given a dataframe, 例如:给定一个数据框,

    name<-letters[1:10]
    length<-c(140,50,25,120,156,146,180,98,120,110)
    quality<-c(20,25,35,20,15,28,32,35,29,25)
    df<-data.frame(name,length,quality)

how to insert three lines of text either above or below the data frame,df: 如何在数据框df的上方或下方插入三行文本:

    No. of reads = 10
    %AT=32
    %GC=30

The output should look like: 输出应如下所示:

      name length quality
   1     a    140      20
   2     b     50      25
   3     c     25      35
   4     d    120      20
   5     e    156      15
   6     f    146      28
   7     g    180      32
   8     h     98      35
   9     i    120      29
   10    j    110      25
   No. of reads = 10
   %AT=32
   %GC=30

Are you looking for something like this? 您是否正在寻找这样的东西?

prettyprint <- function() {
  print(df)
  cat("No. of reads = 10",
      "\n%AT=32",
      "\n%GC=30")
 }
 prettyprint()

The output looks something like this: 输出看起来像这样:

   name length quality
1     a    140      20
2     b     50      25
3     c     25      35
4     d    120      20
5     e    156      15
6     f    146      28
7     g    180      32
8     h     98      35
9     i    120      29
10    j    110      25
No. of reads = 10 
%AT=32 
%GC=30

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何 append dataframe 的第 2 列低于 dataframe 在 ZE1E36EEZ3D4005E7321 中的相同 dataframe - How to append column 2 of a dataframe below column 1 of the same dataframe in R? 返回r数据帧中特定行的上下行 - Returning above and below rows of specific rows in r dataframe R闪亮改变表格上方和下方文本元素的颜色 - R Shiny change color of text elements above and below the table 使用线连接所有点,并使用R在其上方书写文本 - Connect all points using lines and write text above it using R 正则表达式 R:在满足另一个正则表达式条件的同时选择正则表达式选择的上方或下方行 - Regular Expression R: Select the above or below lines of a regexp selection while meeting another regexp criteria R dataframe:在满足条件的情况下填写上下行数 - R dataframe: filling specific number of rows above and below where conditions are met 如何从R数据框中的特定行的上方和下方提取行? - How can I extract rows from above and below a specific row in an R dataframe? 填充图中水平线上方和下方的区域 - Fill area above and below horizontal lines in plot 复制并追加到R中的数据框 - Replicate and append to dataframe in R R ggplot2 geom_ribbon:当没有线在下方且没有线在上方时,由两侧的两条交叉线界定的阴影/着色区域 - R ggplot2 geom_ribbon: shade/coloring area bounded by two crossing lines on the sides when no line is below and no line is above
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM