如何从 data.frame 中排除列并保留列之间的空格?

How to exclude columns from a data.frame and keep the spaces between columns?

我有一个 tab.table(如下所示),其中 million340

HanXRQChr00c0001    68062   N    N   N   N   A
HanXRQChr00c0001    68080   N    N   N   N   A
HanXRQChr00c0001    68285   N    N   N   N   A

我想删除 28 。这样做很容易,但在输出文件中,我丢失了列之间的 space。

有什么方法可以排除这些列并仍然像上面那样在它们之间保留 space 吗?

你可以尝试不同的东西。我在下面包括了其中的一些:

awk -i inplace '{[=10=]=gensub(/\s*\S+/,"",28)}1' file

sed -i -r 's/(\s+)?\S+//28' file

awk '{=""; print [=12=]}' file

或使用评论中提到的 cut